Skip to content

Commit a08ea66

Browse files
Mikel AstizChromium LUCI CQ
Mikel Astiz
authored and
Chromium LUCI CQ
committed
Make //google_apis a component
Multiple components depend on build target //google_apis which is against recommended practices in [1] and specifically runs into issues when new singleton-like state, include base::Feature instances, are added to //google_apis. Following recommended practices, this patch makes //google_apis a component itself, as all targets it depends on are already components. [1] https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md#dependencies-between-targets Change-Id: I9c14050314b208791d7d5773ab76a7913c422bd9 Fixed: 1417961 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272614 Reviewed-by: Jamie Walch <[email protected]> Reviewed-by: Alex Ilin <[email protected]> Commit-Queue: Mikel Astiz <[email protected]> Cr-Commit-Position: refs/heads/main@{#1107876}
1 parent e2f91c6 commit a08ea66

25 files changed

+243
-187
lines changed

google_apis/BUILD.gn

+74-86
Original file line numberDiff line numberDiff line change
@@ -110,100 +110,88 @@ config("key_defines") {
110110
}
111111
}
112112

113-
# Variables:
114-
# deps: Extra dependencies
115-
template("google_apis_tmpl") {
116-
source_set(target_name) {
117-
sources = [
118-
"gaia/core_account_id.cc",
119-
"gaia/core_account_id.h",
120-
"gaia/gaia_access_token_fetcher.cc",
121-
"gaia/gaia_access_token_fetcher.h",
122-
"gaia/gaia_auth_consumer.cc",
123-
"gaia/gaia_auth_consumer.h",
124-
"gaia/gaia_auth_fetcher.cc",
125-
"gaia/gaia_auth_fetcher.h",
126-
"gaia/gaia_auth_util.cc",
127-
"gaia/gaia_auth_util.h",
128-
"gaia/gaia_config.cc",
129-
"gaia/gaia_config.h",
130-
"gaia/gaia_constants.cc",
131-
"gaia/gaia_constants.h",
132-
"gaia/gaia_oauth_client.cc",
133-
"gaia/gaia_oauth_client.h",
134-
"gaia/gaia_switches.cc",
135-
"gaia/gaia_switches.h",
136-
"gaia/gaia_urls.cc",
137-
"gaia/gaia_urls.h",
138-
"gaia/google_service_auth_error.cc",
139-
"gaia/google_service_auth_error.h",
140-
"gaia/oauth2_access_token_consumer.cc",
141-
"gaia/oauth2_access_token_consumer.h",
142-
"gaia/oauth2_access_token_fetcher.cc",
143-
"gaia/oauth2_access_token_fetcher.h",
144-
"gaia/oauth2_access_token_fetcher_immediate_error.cc",
145-
"gaia/oauth2_access_token_fetcher_immediate_error.h",
146-
"gaia/oauth2_access_token_fetcher_impl.cc",
147-
"gaia/oauth2_access_token_fetcher_impl.h",
148-
"gaia/oauth2_access_token_manager.cc",
149-
"gaia/oauth2_access_token_manager.h",
150-
"gaia/oauth2_api_call_flow.cc",
151-
"gaia/oauth2_api_call_flow.h",
152-
"gaia/oauth2_id_token_decoder.cc",
153-
"gaia/oauth2_id_token_decoder.h",
154-
"gaia/oauth2_mint_token_flow.cc",
155-
"gaia/oauth2_mint_token_flow.h",
156-
"gaia/oauth_multilogin_result.cc",
157-
"gaia/oauth_multilogin_result.h",
158-
"gaia/oauth_request_signer.cc",
159-
"gaia/oauth_request_signer.h",
160-
"google_api_keys.cc",
161-
"google_api_keys.h",
162-
]
163-
164-
configs += [ ":key_defines" ]
165-
166-
public_deps = [
167-
":buildflags",
168-
"//build:chromeos_buildflags",
169-
]
170-
171-
deps = [
172-
":oauth2_mint_token_consent_result_proto",
173-
"//base",
174-
"//base/third_party/dynamic_annotations",
175-
"//build:branding_buildflags",
176-
"//build:chromeos_buildflags",
177-
"//crypto",
178-
"//mojo/public/cpp/bindings:struct_traits",
179-
"//services/network/public/cpp",
180-
]
181-
182-
if (_use_official_google_keys_and_generate_metrics_key_header) {
183-
deps += [ "internal:generate_metrics_key_header" ]
184-
}
185-
186-
if (defined(invoker.deps)) {
187-
deps += invoker.deps
188-
}
113+
component("google_apis") {
114+
sources = [
115+
"gaia/core_account_id.cc",
116+
"gaia/core_account_id.h",
117+
"gaia/gaia_access_token_fetcher.cc",
118+
"gaia/gaia_access_token_fetcher.h",
119+
"gaia/gaia_auth_consumer.cc",
120+
"gaia/gaia_auth_consumer.h",
121+
"gaia/gaia_auth_fetcher.cc",
122+
"gaia/gaia_auth_fetcher.h",
123+
"gaia/gaia_auth_util.cc",
124+
"gaia/gaia_auth_util.h",
125+
"gaia/gaia_config.cc",
126+
"gaia/gaia_config.h",
127+
"gaia/gaia_constants.cc",
128+
"gaia/gaia_constants.h",
129+
"gaia/gaia_oauth_client.cc",
130+
"gaia/gaia_oauth_client.h",
131+
"gaia/gaia_switches.cc",
132+
"gaia/gaia_switches.h",
133+
"gaia/gaia_urls.cc",
134+
"gaia/gaia_urls.h",
135+
"gaia/google_service_auth_error.cc",
136+
"gaia/google_service_auth_error.h",
137+
"gaia/oauth2_access_token_consumer.cc",
138+
"gaia/oauth2_access_token_consumer.h",
139+
"gaia/oauth2_access_token_fetcher.cc",
140+
"gaia/oauth2_access_token_fetcher.h",
141+
"gaia/oauth2_access_token_fetcher_immediate_error.cc",
142+
"gaia/oauth2_access_token_fetcher_immediate_error.h",
143+
"gaia/oauth2_access_token_fetcher_impl.cc",
144+
"gaia/oauth2_access_token_fetcher_impl.h",
145+
"gaia/oauth2_access_token_manager.cc",
146+
"gaia/oauth2_access_token_manager.h",
147+
"gaia/oauth2_api_call_flow.cc",
148+
"gaia/oauth2_api_call_flow.h",
149+
"gaia/oauth2_id_token_decoder.cc",
150+
"gaia/oauth2_id_token_decoder.h",
151+
"gaia/oauth2_mint_token_flow.cc",
152+
"gaia/oauth2_mint_token_flow.h",
153+
"gaia/oauth_multilogin_result.cc",
154+
"gaia/oauth_multilogin_result.h",
155+
"gaia/oauth_request_signer.cc",
156+
"gaia/oauth_request_signer.h",
157+
"google_api_keys.cc",
158+
"google_api_keys.h",
159+
]
189160

190-
if (is_apple) {
191-
sources += [
192-
"google_api_keys_mac.h",
193-
"google_api_keys_mac.mm",
194-
]
161+
configs += [ ":key_defines" ]
195162

196-
frameworks = [ "Foundation.framework" ]
197-
}
198-
}
199-
}
163+
public_deps = [
164+
":buildflags",
165+
"//base",
166+
"//build:chromeos_buildflags",
167+
]
200168

201-
google_apis_tmpl("google_apis") {
202169
deps = [
170+
":oauth2_mint_token_consent_result_proto",
171+
"//base/third_party/dynamic_annotations",
172+
"//build:branding_buildflags",
173+
"//build:chromeos_buildflags",
174+
"//crypto",
175+
"//mojo/public/cpp/bindings:struct_traits",
203176
"//net",
204177
"//services/network/public/cpp",
205178
"//services/network/public/mojom",
206179
]
180+
181+
if (_use_official_google_keys_and_generate_metrics_key_header) {
182+
deps += [ "internal:generate_metrics_key_header" ]
183+
}
184+
185+
if (is_apple) {
186+
sources += [
187+
"google_api_keys_mac.h",
188+
"google_api_keys_mac.mm",
189+
]
190+
191+
frameworks = [ "Foundation.framework" ]
192+
}
193+
194+
defines = [ "IS_GOOGLE_APIS_IMPL" ]
207195
}
208196

209197
proto_library("oauth2_mint_token_consent_result_proto") {

google_apis/gaia/core_account_id.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string>
1010
#include <vector>
1111

12+
#include "base/component_export.h"
1213
#include "build/build_config.h"
1314
#include "build/chromeos_buildflags.h"
1415

@@ -24,7 +25,7 @@
2425
// change on start-up.
2526
// --------------------------------------------------------------------------
2627

27-
struct CoreAccountId {
28+
struct COMPONENT_EXPORT(GOOGLE_APIS) CoreAccountId {
2829
CoreAccountId();
2930
CoreAccountId(const CoreAccountId&);
3031
CoreAccountId(CoreAccountId&&) noexcept;
@@ -96,16 +97,21 @@ struct CoreAccountId {
9697
std::string id_;
9798
};
9899

100+
COMPONENT_EXPORT(GOOGLE_APIS)
99101
bool operator<(const CoreAccountId& lhs, const CoreAccountId& rhs);
100102

103+
COMPONENT_EXPORT(GOOGLE_APIS)
101104
bool operator==(const CoreAccountId& lhs, const CoreAccountId& rhs);
102105

106+
COMPONENT_EXPORT(GOOGLE_APIS)
103107
bool operator!=(const CoreAccountId& lhs, const CoreAccountId& rhs);
104108

109+
COMPONENT_EXPORT(GOOGLE_APIS)
105110
std::ostream& operator<<(std::ostream& out, const CoreAccountId& a);
106111

107112
// Returns the values of the account ids in a vector. Useful especially for
108113
// logs.
114+
COMPONENT_EXPORT(GOOGLE_APIS)
109115
std::vector<std::string> ToStringList(
110116
const std::vector<CoreAccountId>& account_ids);
111117

google_apis/gaia/gaia_access_token_fetcher.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <memory>
99
#include <string>
1010

11+
#include "base/component_export.h"
1112
#include "base/memory/ref_counted.h"
1213
#include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
1314

@@ -21,7 +22,8 @@ class SharedURLLoaderFactory;
2122
// tokens from Google's authorization server. See "Refreshing an access token"
2223
// for more Google specific info:
2324
// https://developers.google.com/identity/protocols/oauth2/web-server?csw=1#obtainingaccesstokens
24-
class GaiaAccessTokenFetcher : public OAuth2AccessTokenFetcherImpl {
25+
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAccessTokenFetcher
26+
: public OAuth2AccessTokenFetcherImpl {
2527
public:
2628
static const char kOAuth2NetResponseCodeHistogramName[];
2729
static const char kOAuth2ResponseHistogramName[];

google_apis/gaia/gaia_auth_consumer.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
#include <string>
1010
#include <vector>
1111

12+
#include "base/component_export.h"
13+
1214
class GoogleServiceAuthError;
1315
class OAuthMultiloginResult;
1416

1517
// An interface that defines the callbacks for objects that
1618
// GaiaAuthFetcher can return data to.
17-
class GaiaAuthConsumer {
19+
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAuthConsumer {
1820
public:
19-
struct ClientOAuthResult {
21+
struct COMPONENT_EXPORT(GOOGLE_APIS) ClientOAuthResult {
2022
ClientOAuthResult(const std::string& new_refresh_token,
2123
const std::string& new_access_token,
2224
int new_expires_in_secs,

google_apis/gaia/gaia_auth_fetcher.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string>
1010
#include <vector>
1111

12+
#include "base/component_export.h"
1213
#include "base/gtest_prod_util.h"
1314
#include "base/memory/raw_ptr.h"
1415
#include "base/memory/ref_counted.h"
@@ -43,7 +44,7 @@ enum class MultiloginMode {
4344
};
4445

4546
// Specifies the "source" parameter for Gaia calls.
46-
class GaiaSource {
47+
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaSource {
4748
public:
4849
enum Type {
4950
kChrome,
@@ -72,9 +73,9 @@ class SimpleURLLoader;
7273
class SharedURLLoaderFactory;
7374
} // namespace network
7475

75-
class GaiaAuthFetcher {
76+
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAuthFetcher {
7677
public:
77-
struct MultiloginTokenIDPair {
78+
struct COMPONENT_EXPORT(GOOGLE_APIS) MultiloginTokenIDPair {
7879
std::string token_;
7980
std::string gaia_id_;
8081

google_apis/gaia/gaia_auth_util.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#include <utility>
1010
#include <vector>
1111

12+
#include "base/component_export.h"
1213
#include "google_apis/gaia/core_account_id.h"
1314

1415
class GURL;
1516

1617
namespace gaia {
1718

18-
struct ListedAccount {
19+
struct COMPONENT_EXPORT(GOOGLE_APIS) ListedAccount {
1920
// The account's ID, as per Chrome, will be determined in the
2021
// CookieManagerService.
2122
CoreAccountId id;
@@ -35,41 +36,49 @@ struct ListedAccount {
3536
// gmail does not consider '.' or caps inside a username to matter.
3637
// If |email_address| is not a valid, returns it in lower case without
3738
// additional canonicalization.
39+
COMPONENT_EXPORT(GOOGLE_APIS)
3840
std::string CanonicalizeEmail(const std::string& email_address);
3941

4042
// Returns the canonical form of the given domain.
43+
COMPONENT_EXPORT(GOOGLE_APIS)
4144
std::string CanonicalizeDomain(const std::string& domain);
4245

4346
// Sanitize emails. Currently, it only ensures all emails have a domain by
4447
// adding gmail.com if no domain is present.
48+
COMPONENT_EXPORT(GOOGLE_APIS)
4549
std::string SanitizeEmail(const std::string& email_address);
4650

4751
// Returns true if the two specified email addresses are the same. Both
4852
// addresses are first sanitized and then canonicalized before comparing.
53+
COMPONENT_EXPORT(GOOGLE_APIS)
4954
bool AreEmailsSame(const std::string& email1, const std::string& email2);
5055

5156
// Extract the domain part from the canonical form of the given email.
57+
COMPONENT_EXPORT(GOOGLE_APIS)
5258
std::string ExtractDomainName(const std::string& email);
5359

5460
// Returns whether the user's email is Google internal. This check is meant
5561
// to be used sparingly since it ship Googler-only code to all users.
62+
COMPONENT_EXPORT(GOOGLE_APIS)
5663
bool IsGoogleInternalAccountEmail(const std::string& email);
5764

5865
// Returns true if |email| correspnds to the email of a robot account.
66+
COMPONENT_EXPORT(GOOGLE_APIS)
5967
bool IsGoogleRobotAccountEmail(const std::string& email);
6068

6169
// Mechanically compares the scheme, host, and port of the |url| against the
6270
// GAIA url in GaiaUrls. This means that this function will *not* work for
6371
// determining whether a frame with an "about:blank" URL or "blob:..." URL has
6472
// a GAIA origin and will in that case return false.
65-
bool HasGaiaSchemeHostPort(const GURL& url);
73+
COMPONENT_EXPORT(GOOGLE_APIS) bool HasGaiaSchemeHostPort(const GURL& url);
6674

6775
// Parses JSON data returned by /ListAccounts call, returning a vector of
6876
// email/valid pairs. An email addresses is considered valid if a passive
6977
// login would succeed (i.e. the user does not need to reauthenticate).
7078
// If there an error parsing the JSON, then false is returned.
7179
// If either |accounts| or |signed_out_accounts| is null, the corresponding
7280
// accounts returned from /ListAccounts will be ignored.
81+
COMPONENT_EXPORT(GOOGLE_APIS)
7382
bool ParseListAccountsData(const std::string& data,
7483
std::vector<ListedAccount>* accounts,
7584
std::vector<ListedAccount>* signed_out_accounts);
@@ -79,6 +88,7 @@ bool ParseListAccountsData(const std::string& data,
7988
// that was shown the consent page.
8089
// Returns false if the method failed to decode the protobuf.
8190
// |approved| and |gaia_id| must not be null.
91+
COMPONENT_EXPORT(GOOGLE_APIS)
8292
bool ParseOAuth2MintTokenConsentResult(const std::string& consent_result,
8393
bool* approved,
8494
std::string* gaia_id);

google_apis/gaia/gaia_config.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <memory>
99
#include <string>
1010

11+
#include "base/component_export.h"
1112
#include "base/gtest_prod_util.h"
1213
#include "base/strings/string_piece_forward.h"
1314
#include "base/values.h"
@@ -38,7 +39,7 @@ class FilePath;
3839
// ...
3940
// }
4041
// }
41-
class GaiaConfig {
42+
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaConfig {
4243
public:
4344
// Returns a global instance of GaiaConfig.
4445
// This may return nullptr if the config file was not specified by a command

0 commit comments

Comments
 (0)