0

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 <jamiewalch@chromium.org>
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107876}
This commit is contained in:
Mikel Astiz
2023-02-21 19:30:11 +00:00
committed by Chromium LUCI CQ
parent e2f91c6353
commit a08ea663bb
25 changed files with 243 additions and 187 deletions

@ -110,100 +110,88 @@ config("key_defines") {
}
}
# Variables:
# deps: Extra dependencies
template("google_apis_tmpl") {
source_set(target_name) {
sources = [
"gaia/core_account_id.cc",
"gaia/core_account_id.h",
"gaia/gaia_access_token_fetcher.cc",
"gaia/gaia_access_token_fetcher.h",
"gaia/gaia_auth_consumer.cc",
"gaia/gaia_auth_consumer.h",
"gaia/gaia_auth_fetcher.cc",
"gaia/gaia_auth_fetcher.h",
"gaia/gaia_auth_util.cc",
"gaia/gaia_auth_util.h",
"gaia/gaia_config.cc",
"gaia/gaia_config.h",
"gaia/gaia_constants.cc",
"gaia/gaia_constants.h",
"gaia/gaia_oauth_client.cc",
"gaia/gaia_oauth_client.h",
"gaia/gaia_switches.cc",
"gaia/gaia_switches.h",
"gaia/gaia_urls.cc",
"gaia/gaia_urls.h",
"gaia/google_service_auth_error.cc",
"gaia/google_service_auth_error.h",
"gaia/oauth2_access_token_consumer.cc",
"gaia/oauth2_access_token_consumer.h",
"gaia/oauth2_access_token_fetcher.cc",
"gaia/oauth2_access_token_fetcher.h",
"gaia/oauth2_access_token_fetcher_immediate_error.cc",
"gaia/oauth2_access_token_fetcher_immediate_error.h",
"gaia/oauth2_access_token_fetcher_impl.cc",
"gaia/oauth2_access_token_fetcher_impl.h",
"gaia/oauth2_access_token_manager.cc",
"gaia/oauth2_access_token_manager.h",
"gaia/oauth2_api_call_flow.cc",
"gaia/oauth2_api_call_flow.h",
"gaia/oauth2_id_token_decoder.cc",
"gaia/oauth2_id_token_decoder.h",
"gaia/oauth2_mint_token_flow.cc",
"gaia/oauth2_mint_token_flow.h",
"gaia/oauth_multilogin_result.cc",
"gaia/oauth_multilogin_result.h",
"gaia/oauth_request_signer.cc",
"gaia/oauth_request_signer.h",
"google_api_keys.cc",
"google_api_keys.h",
]
component("google_apis") {
sources = [
"gaia/core_account_id.cc",
"gaia/core_account_id.h",
"gaia/gaia_access_token_fetcher.cc",
"gaia/gaia_access_token_fetcher.h",
"gaia/gaia_auth_consumer.cc",
"gaia/gaia_auth_consumer.h",
"gaia/gaia_auth_fetcher.cc",
"gaia/gaia_auth_fetcher.h",
"gaia/gaia_auth_util.cc",
"gaia/gaia_auth_util.h",
"gaia/gaia_config.cc",
"gaia/gaia_config.h",
"gaia/gaia_constants.cc",
"gaia/gaia_constants.h",
"gaia/gaia_oauth_client.cc",
"gaia/gaia_oauth_client.h",
"gaia/gaia_switches.cc",
"gaia/gaia_switches.h",
"gaia/gaia_urls.cc",
"gaia/gaia_urls.h",
"gaia/google_service_auth_error.cc",
"gaia/google_service_auth_error.h",
"gaia/oauth2_access_token_consumer.cc",
"gaia/oauth2_access_token_consumer.h",
"gaia/oauth2_access_token_fetcher.cc",
"gaia/oauth2_access_token_fetcher.h",
"gaia/oauth2_access_token_fetcher_immediate_error.cc",
"gaia/oauth2_access_token_fetcher_immediate_error.h",
"gaia/oauth2_access_token_fetcher_impl.cc",
"gaia/oauth2_access_token_fetcher_impl.h",
"gaia/oauth2_access_token_manager.cc",
"gaia/oauth2_access_token_manager.h",
"gaia/oauth2_api_call_flow.cc",
"gaia/oauth2_api_call_flow.h",
"gaia/oauth2_id_token_decoder.cc",
"gaia/oauth2_id_token_decoder.h",
"gaia/oauth2_mint_token_flow.cc",
"gaia/oauth2_mint_token_flow.h",
"gaia/oauth_multilogin_result.cc",
"gaia/oauth_multilogin_result.h",
"gaia/oauth_request_signer.cc",
"gaia/oauth_request_signer.h",
"google_api_keys.cc",
"google_api_keys.h",
]
configs += [ ":key_defines" ]
configs += [ ":key_defines" ]
public_deps = [
":buildflags",
"//build:chromeos_buildflags",
]
public_deps = [
":buildflags",
"//base",
"//build:chromeos_buildflags",
]
deps = [
":oauth2_mint_token_consent_result_proto",
"//base",
"//base/third_party/dynamic_annotations",
"//build:branding_buildflags",
"//build:chromeos_buildflags",
"//crypto",
"//mojo/public/cpp/bindings:struct_traits",
"//services/network/public/cpp",
]
if (_use_official_google_keys_and_generate_metrics_key_header) {
deps += [ "internal:generate_metrics_key_header" ]
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (is_apple) {
sources += [
"google_api_keys_mac.h",
"google_api_keys_mac.mm",
]
frameworks = [ "Foundation.framework" ]
}
}
}
google_apis_tmpl("google_apis") {
deps = [
":oauth2_mint_token_consent_result_proto",
"//base/third_party/dynamic_annotations",
"//build:branding_buildflags",
"//build:chromeos_buildflags",
"//crypto",
"//mojo/public/cpp/bindings:struct_traits",
"//net",
"//services/network/public/cpp",
"//services/network/public/mojom",
]
if (_use_official_google_keys_and_generate_metrics_key_header) {
deps += [ "internal:generate_metrics_key_header" ]
}
if (is_apple) {
sources += [
"google_api_keys_mac.h",
"google_api_keys_mac.mm",
]
frameworks = [ "Foundation.framework" ]
}
defines = [ "IS_GOOGLE_APIS_IMPL" ]
}
proto_library("oauth2_mint_token_consent_result_proto") {

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
@ -24,7 +25,7 @@
// change on start-up.
// --------------------------------------------------------------------------
struct CoreAccountId {
struct COMPONENT_EXPORT(GOOGLE_APIS) CoreAccountId {
CoreAccountId();
CoreAccountId(const CoreAccountId&);
CoreAccountId(CoreAccountId&&) noexcept;
@ -96,16 +97,21 @@ struct CoreAccountId {
std::string id_;
};
COMPONENT_EXPORT(GOOGLE_APIS)
bool operator<(const CoreAccountId& lhs, const CoreAccountId& rhs);
COMPONENT_EXPORT(GOOGLE_APIS)
bool operator==(const CoreAccountId& lhs, const CoreAccountId& rhs);
COMPONENT_EXPORT(GOOGLE_APIS)
bool operator!=(const CoreAccountId& lhs, const CoreAccountId& rhs);
COMPONENT_EXPORT(GOOGLE_APIS)
std::ostream& operator<<(std::ostream& out, const CoreAccountId& a);
// Returns the values of the account ids in a vector. Useful especially for
// logs.
COMPONENT_EXPORT(GOOGLE_APIS)
std::vector<std::string> ToStringList(
const std::vector<CoreAccountId>& account_ids);

@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
@ -21,7 +22,8 @@ class SharedURLLoaderFactory;
// tokens from Google's authorization server. See "Refreshing an access token"
// for more Google specific info:
// https://developers.google.com/identity/protocols/oauth2/web-server?csw=1#obtainingaccesstokens
class GaiaAccessTokenFetcher : public OAuth2AccessTokenFetcherImpl {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAccessTokenFetcher
: public OAuth2AccessTokenFetcherImpl {
public:
static const char kOAuth2NetResponseCodeHistogramName[];
static const char kOAuth2ResponseHistogramName[];

@ -9,14 +9,16 @@
#include <string>
#include <vector>
#include "base/component_export.h"
class GoogleServiceAuthError;
class OAuthMultiloginResult;
// An interface that defines the callbacks for objects that
// GaiaAuthFetcher can return data to.
class GaiaAuthConsumer {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAuthConsumer {
public:
struct ClientOAuthResult {
struct COMPONENT_EXPORT(GOOGLE_APIS) ClientOAuthResult {
ClientOAuthResult(const std::string& new_refresh_token,
const std::string& new_access_token,
int new_expires_in_secs,

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
@ -43,7 +44,7 @@ enum class MultiloginMode {
};
// Specifies the "source" parameter for Gaia calls.
class GaiaSource {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaSource {
public:
enum Type {
kChrome,
@ -72,9 +73,9 @@ class SimpleURLLoader;
class SharedURLLoaderFactory;
} // namespace network
class GaiaAuthFetcher {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaAuthFetcher {
public:
struct MultiloginTokenIDPair {
struct COMPONENT_EXPORT(GOOGLE_APIS) MultiloginTokenIDPair {
std::string token_;
std::string gaia_id_;

@ -9,13 +9,14 @@
#include <utility>
#include <vector>
#include "base/component_export.h"
#include "google_apis/gaia/core_account_id.h"
class GURL;
namespace gaia {
struct ListedAccount {
struct COMPONENT_EXPORT(GOOGLE_APIS) ListedAccount {
// The account's ID, as per Chrome, will be determined in the
// CookieManagerService.
CoreAccountId id;
@ -35,34 +36,41 @@ struct ListedAccount {
// gmail does not consider '.' or caps inside a username to matter.
// If |email_address| is not a valid, returns it in lower case without
// additional canonicalization.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string CanonicalizeEmail(const std::string& email_address);
// Returns the canonical form of the given domain.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string CanonicalizeDomain(const std::string& domain);
// Sanitize emails. Currently, it only ensures all emails have a domain by
// adding gmail.com if no domain is present.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string SanitizeEmail(const std::string& email_address);
// Returns true if the two specified email addresses are the same. Both
// addresses are first sanitized and then canonicalized before comparing.
COMPONENT_EXPORT(GOOGLE_APIS)
bool AreEmailsSame(const std::string& email1, const std::string& email2);
// Extract the domain part from the canonical form of the given email.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string ExtractDomainName(const std::string& email);
// Returns whether the user's email is Google internal. This check is meant
// to be used sparingly since it ship Googler-only code to all users.
COMPONENT_EXPORT(GOOGLE_APIS)
bool IsGoogleInternalAccountEmail(const std::string& email);
// Returns true if |email| correspnds to the email of a robot account.
COMPONENT_EXPORT(GOOGLE_APIS)
bool IsGoogleRobotAccountEmail(const std::string& email);
// Mechanically compares the scheme, host, and port of the |url| against the
// GAIA url in GaiaUrls. This means that this function will *not* work for
// determining whether a frame with an "about:blank" URL or "blob:..." URL has
// a GAIA origin and will in that case return false.
bool HasGaiaSchemeHostPort(const GURL& url);
COMPONENT_EXPORT(GOOGLE_APIS) bool HasGaiaSchemeHostPort(const GURL& url);
// Parses JSON data returned by /ListAccounts call, returning a vector of
// email/valid pairs. An email addresses is considered valid if a passive
@ -70,6 +78,7 @@ bool HasGaiaSchemeHostPort(const GURL& url);
// If there an error parsing the JSON, then false is returned.
// If either |accounts| or |signed_out_accounts| is null, the corresponding
// accounts returned from /ListAccounts will be ignored.
COMPONENT_EXPORT(GOOGLE_APIS)
bool ParseListAccountsData(const std::string& data,
std::vector<ListedAccount>* accounts,
std::vector<ListedAccount>* signed_out_accounts);
@ -79,6 +88,7 @@ bool ParseListAccountsData(const std::string& data,
// that was shown the consent page.
// Returns false if the method failed to decode the protobuf.
// |approved| and |gaia_id| must not be null.
COMPONENT_EXPORT(GOOGLE_APIS)
bool ParseOAuth2MintTokenConsentResult(const std::string& consent_result,
bool* approved,
std::string* gaia_id);

@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/strings/string_piece_forward.h"
#include "base/values.h"
@ -38,7 +39,7 @@ class FilePath;
// ...
// }
// }
class GaiaConfig {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaConfig {
public:
// Returns a global instance of GaiaConfig.
// This may return nullptr if the config file was not specified by a command

@ -7,68 +7,79 @@
#ifndef GOOGLE_APIS_GAIA_GAIA_CONSTANTS_H_
#define GOOGLE_APIS_GAIA_GAIA_CONSTANTS_H_
#include "base/component_export.h"
namespace GaiaConstants {
// Gaia sources for accounting
extern const char kChromeOSSource[];
extern const char kChromeSource[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kChromeOSSource[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kChromeSource[];
// Used as Gaia source suffix to detect retry requests because of
// |GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE|.
extern const char kUnexpectedServiceResponse[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kUnexpectedServiceResponse[];
// OAuth2 scopes.
extern const char kOAuth1LoginScope[];
extern const char kDeviceManagementServiceOAuth[];
extern const char kAnyApiOAuth2Scope[];
extern const char kChromeSyncOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kOAuth1LoginScope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kDeviceManagementServiceOAuth[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAnyApiOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kChromeSyncOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kChromeSyncSupervisedOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kKidManagementPrivilegedOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kKidsSupervisionSetupChildOAuth2Scope[];
extern const char kGoogleTalkOAuth2Scope[];
extern const char kGoogleUserInfoEmail[];
extern const char kGoogleUserInfoProfile[];
extern const char kParentApprovalOAuth2Scope[];
extern const char kPeopleApiReadOnlyOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGoogleTalkOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGoogleUserInfoEmail[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGoogleUserInfoProfile[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kParentApprovalOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kPeopleApiReadOnlyOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kProgrammaticChallengeOAuth2Scope[];
extern const char kAccountsReauthOAuth2Scope[];
extern const char kAuditRecordingOAuth2Scope[];
extern const char kClearCutOAuth2Scope[];
extern const char kFCMOAuthScope[];
extern const char kTachyonOAuthScope[];
extern const char kPhotosOAuth2Scope[];
extern const char kCastBackdropOAuth2Scope[];
extern const char kCloudTranslationOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAccountsReauthOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAuditRecordingOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kClearCutOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kFCMOAuthScope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kTachyonOAuthScope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kPhotosOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kCastBackdropOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kCloudTranslationOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kPasswordsLeakCheckOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kChromeSafeBrowsingOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kClassifyUrlKidPermissionOAuth2Scope[];
extern const char kKidFamilyReadonlyOAuth2Scope[];
extern const char kPaymentsOAuth2Scope[];
extern const char kCryptAuthOAuth2Scope[];
extern const char kDriveOAuth2Scope[];
extern const char kDriveReadOnlyOAuth2Scope[];
extern const char kAssistantOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kKidFamilyReadonlyOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kPaymentsOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kCryptAuthOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kDriveOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kDriveReadOnlyOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAssistantOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kCloudPlatformProjectsOAuth2Scope[];
extern const char kNearbyShareOAuth2Scope[];
extern const char kGCMGroupServerOAuth2Scope[];
extern const char kGCMCheckinServerOAuth2Scope[];
extern const char kChromeWebstoreOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kNearbyShareOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGCMGroupServerOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGCMCheckinServerOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kChromeWebstoreOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kAccountCapabilitiesOAuth2Scope[];
extern const char kSupportContentOAuth2Scope[];
extern const char kPhotosModuleOAuth2Scope[];
extern const char kPhotosModuleImageOAuth2Scope[];
extern const char kSecureConnectOAuth2Scope[];
extern const char kFeedOAuth2Scope[];
extern const char kKAnonymityServiceOAuth2Scope[];
extern const char kCalendarReadOnlyOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kSupportContentOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kPhotosModuleOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kPhotosModuleImageOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kSecureConnectOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kFeedOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kKAnonymityServiceOAuth2Scope[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kCalendarReadOnlyOAuth2Scope[];
// Used by wallet sign in helper.
extern const char kClientOAuthEmailKey[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kClientOAuthEmailKey[];
// Refresh token that is guaranteed to be invalid.
extern const char kInvalidRefreshToken[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kInvalidRefreshToken[];
// Name of the Google authentication cookie.
extern const char kGaiaSigninCookieName[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGaiaSigninCookieName[];
} // namespace GaiaConstants
#endif // GOOGLE_APIS_GAIA_GAIA_CONSTANTS_H_

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "base/values.h"
@ -23,15 +24,15 @@ class SharedURLLoaderFactory;
// instances.
namespace gaia {
struct OAuthClientInfo {
struct COMPONENT_EXPORT(GOOGLE_APIS) OAuthClientInfo {
std::string client_id;
std::string client_secret;
std::string redirect_uri;
};
class GaiaOAuthClient {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaOAuthClient {
public:
class Delegate {
class COMPONENT_EXPORT(GOOGLE_APIS) Delegate {
public:
// Invoked on a successful response to the GetTokensFromAuthCode request.
virtual void OnGetTokensResponse(const std::string& refresh_token,
@ -154,6 +155,7 @@ class GaiaOAuthClient {
class Core;
scoped_refptr<Core> core_;
};
}
} // namespace gaia
#endif // GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_

@ -5,42 +5,44 @@
#ifndef GOOGLE_APIS_GAIA_GAIA_SWITCHES_H_
#define GOOGLE_APIS_GAIA_GAIA_SWITCHES_H_
#include "base/component_export.h"
namespace switches {
// Specifies the path to a config file containing GAIA urls.
// See "google_apis/test/data/gaia/all_urls.json" for a format example.
extern const char kGaiaConfigPath[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGaiaConfigPath[];
// Specifies a string containing the JSON config for GAIA urls. This is
// equivalent to pointing to a file with the same content via kGaiaConfigPath.
// See "google_apis/test/data/gaia/all_urls.json" for a format example.
extern const char kGaiaConfigContents[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGaiaConfigContents[];
// Specifies the domain of the SAPISID cookie. The default value is
// "http://.google.com".
extern const char kGoogleUrl[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGoogleUrl[];
// Specifies the path for GAIA authentication URL. The default value is
// "https://accounts.google.com".
extern const char kGaiaUrl[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGaiaUrl[];
// Specifies the backend server used for Google API calls.
// "https://www.googleapis.com".
extern const char kGoogleApisUrl[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kGoogleApisUrl[];
// Specifies the backend server used for lso authentication calls.
// "https://accounts.google.com".
extern const char kLsoUrl[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kLsoUrl[];
// Specifies the backend server used for OAuth issue token calls.
// "https://oauthaccountmanager.googleapis.com".
extern const char kOAuthAccountManagerUrl[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kOAuthAccountManagerUrl[];
// Specifies custom OAuth2 client id for testing purposes.
extern const char kOAuth2ClientID[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kOAuth2ClientID[];
// Specifies custom OAuth2 client secret for testing purposes.
extern const char kOAuth2ClientSecret[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kOAuth2ClientSecret[];
} // namespace switches

@ -7,6 +7,7 @@
#include <string>
#include "base/component_export.h"
#include "base/memory/singleton.h"
#include "url/gurl.h"
#include "url/origin.h"
@ -14,7 +15,7 @@
// A singleton that provides all the URLs that are used for connecting to GAIA.
//
// Please update InitializeFromConfig() when adding new URLs.
class GaiaUrls {
class COMPONENT_EXPORT(GOOGLE_APIS) GaiaUrls {
public:
static GaiaUrls* GetInstance();

@ -13,9 +13,10 @@
#include <string>
#include "base/component_export.h"
#include "url/gurl.h"
class GoogleServiceAuthError {
class COMPONENT_EXPORT(GOOGLE_APIS) GoogleServiceAuthError {
public:
//
// These enumerations are referenced by integer value in HTML login code and

@ -7,16 +7,17 @@
#include <string>
#include "base/component_export.h"
#include "base/time/time.h"
class GoogleServiceAuthError;
// An interface that defines the callbacks for consumers to which
// OAuth2AccessTokenFetcher can return results.
class OAuth2AccessTokenConsumer {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenConsumer {
public:
// Structure representing information contained in OAuth2 access token.
struct TokenResponse {
struct COMPONENT_EXPORT(GOOGLE_APIS) TokenResponse {
TokenResponse();
TokenResponse(const TokenResponse& response);
TokenResponse(TokenResponse&& response);
@ -39,7 +40,7 @@ class OAuth2AccessTokenConsumer {
std::string id_token;
// Helper class to make building TokenResponse objects clearer.
class Builder {
class COMPONENT_EXPORT(GOOGLE_APIS) Builder {
public:
Builder();
~Builder();

@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/memory/raw_ptr.h"
#include "google_apis/gaia/oauth2_access_token_consumer.h"
@ -21,7 +22,7 @@
//
// This class can handle one request at a time. To parallelize requests,
// create multiple instances.
class OAuth2AccessTokenFetcher {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenFetcher {
public:
explicit OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer);

@ -5,6 +5,7 @@
#ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_IMMEDIATE_ERROR_H_
#define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_IMMEDIATE_ERROR_H_
#include "base/component_export.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "google_apis/gaia/google_service_auth_error.h"
@ -28,7 +29,8 @@
//
// This class can handle one request at a time. To parallelize requests,
// create multiple instances.
class OAuth2AccessTokenFetcherImmediateError : public OAuth2AccessTokenFetcher {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenFetcherImmediateError
: public OAuth2AccessTokenFetcher {
public:
OAuth2AccessTokenFetcherImmediateError(OAuth2AccessTokenConsumer* consumer,
const GoogleServiceAuthError& error);
@ -47,7 +49,8 @@ class OAuth2AccessTokenFetcherImmediateError : public OAuth2AccessTokenFetcher {
void CancelRequest() override;
private:
class FailCaller : public base::RefCounted<FailCaller> {
class COMPONENT_EXPORT(GOOGLE_APIS) FailCaller
: public base::RefCounted<FailCaller> {
public:
FailCaller(OAuth2AccessTokenFetcherImmediateError* fetcher);

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "google_apis/gaia/oauth2_access_token_consumer.h"
@ -39,7 +40,8 @@ class SharedURLLoaderFactory;
// This class can handle one request at a time. To parallelize requests,
// create multiple instances. Prefer `GaiaAccessTokenFetcher` over this class
// while talking to Google's OAuth servers.
class OAuth2AccessTokenFetcherImpl : public OAuth2AccessTokenFetcher {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenFetcherImpl
: public OAuth2AccessTokenFetcher {
public:
// Enumerated constants of server responses, matching RFC 6749.
// These values are persisted to logs. Entries should not be renumbered and

@ -8,6 +8,7 @@
#include <map>
#include <set>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
@ -24,13 +25,13 @@ class SharedURLLoaderFactory;
class OAuth2AccessTokenFetcher;
// Class that manages requests for OAuth2 access tokens.
class OAuth2AccessTokenManager {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenManager {
public:
// A set of scopes in OAuth2 authentication.
typedef std::set<std::string> ScopeSet;
class RequestImpl;
class Delegate {
class COMPONENT_EXPORT(GOOGLE_APIS) Delegate {
public:
Delegate();
virtual ~Delegate();
@ -79,7 +80,7 @@ class OAuth2AccessTokenManager {
};
// Class representing a request that fetches an OAuth2 access token.
class Request {
class COMPONENT_EXPORT(GOOGLE_APIS) Request {
public:
virtual ~Request();
virtual CoreAccountId GetAccountId() const = 0;
@ -90,7 +91,7 @@ class OAuth2AccessTokenManager {
// Class representing the consumer of a Request passed to |StartRequest|,
// which will be called back when the request completes.
class Consumer {
class COMPONENT_EXPORT(GOOGLE_APIS) Consumer {
public:
explicit Consumer(const std::string& id);
virtual ~Consumer();
@ -112,8 +113,9 @@ class OAuth2AccessTokenManager {
// Implements a cancelable |OAuth2AccessTokenManager::Request|, which should
// be operated on the UI thread.
// TODO(davidroche): move this out of header file.
class RequestImpl : public base::SupportsWeakPtr<RequestImpl>,
public Request {
class COMPONENT_EXPORT(GOOGLE_APIS) RequestImpl
: public base::SupportsWeakPtr<RequestImpl>,
public Request {
public:
// |consumer| is required to outlive this.
RequestImpl(const CoreAccountId& account_id, Consumer* consumer);
@ -140,7 +142,7 @@ class OAuth2AccessTokenManager {
// Classes that want to monitor status of access token and access token
// request should implement this interface and register with the
// AddDiagnosticsObserver() call.
class DiagnosticsObserver {
class COMPONENT_EXPORT(GOOGLE_APIS) DiagnosticsObserver {
public:
// Called when receiving request for access token.
virtual void OnAccessTokenRequested(const CoreAccountId& account_id,
@ -162,7 +164,7 @@ class OAuth2AccessTokenManager {
};
// The parameters used to fetch an OAuth2 access token.
struct RequestParameters {
struct COMPONENT_EXPORT(GOOGLE_APIS) RequestParameters {
RequestParameters(const std::string& client_id,
const CoreAccountId& account_id,
const ScopeSet& scopes);

@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include "base/component_export.h"
#include "base/memory/scoped_refptr.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/mojom/url_response_head.mojom-forward.h"
@ -26,7 +27,7 @@ class HttpRequestHeaders;
// given an access token to the service. This class abstracts the basic steps
// and exposes template methods for sub-classes to implement for API specific
// details.
class OAuth2ApiCallFlow {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2ApiCallFlow {
public:
OAuth2ApiCallFlow();

@ -8,6 +8,8 @@
#include <string>
#include <vector>
#include "base/component_export.h"
// This file holds methods decodes the id token received for OAuth2 token
// endpoint, and derive useful information from it, such as whether the account
// is a child account, and whether this account is under advanced protection.
@ -15,12 +17,13 @@
namespace gaia {
// Service flags extracted from ID token.
struct TokenServiceFlags {
struct COMPONENT_EXPORT(GOOGLE_APIS) TokenServiceFlags {
bool is_child_account = false;
bool is_under_advanced_protection = false;
};
// Parses service flag from ID token.
COMPONENT_EXPORT(GOOGLE_APIS)
TokenServiceFlags ParseServiceFlags(const std::string& id_token);
} // namespace gaia

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
@ -21,6 +22,7 @@
class GoogleServiceAuthError;
class OAuth2MintTokenFlowTest;
COMPONENT_EXPORT(GOOGLE_APIS)
extern const char kOAuth2MintTokenApiCallResultHistogram[];
// Values carrying the result of processing a successful API call.
@ -48,7 +50,7 @@ enum class OAuth2MintTokenApiCallResult {
// Data for the remote consent resolution:
// - URL of the consent page to be displayed to the user.
// - Cookies that should be set before navigating to that URL.
struct RemoteConsentResolutionData {
struct COMPONENT_EXPORT(GOOGLE_APIS) RemoteConsentResolutionData {
RemoteConsentResolutionData();
~RemoteConsentResolutionData();
@ -65,7 +67,8 @@ struct RemoteConsentResolutionData {
// This class implements the OAuth2 flow to Google to mint an OAuth2 access
// token for the given client and the given set of scopes from the OAuthLogin
// scoped "master" OAuth2 token for the user logged in to Chrome.
class OAuth2MintTokenFlow : public OAuth2ApiCallFlow {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2MintTokenFlow
: public OAuth2ApiCallFlow {
public:
// There are four different modes when minting a token to grant
// access to third-party app for a user.
@ -81,7 +84,7 @@ class OAuth2MintTokenFlow : public OAuth2ApiCallFlow {
};
// Parameters needed to mint a token.
struct Parameters {
struct COMPONENT_EXPORT(GOOGLE_APIS) Parameters {
public:
Parameters();
Parameters(const std::string& eid,
@ -109,7 +112,7 @@ class OAuth2MintTokenFlow : public OAuth2ApiCallFlow {
Mode mode;
};
class Delegate {
class COMPONENT_EXPORT(GOOGLE_APIS) Delegate {
public:
virtual void OnMintTokenSuccess(const std::string& access_token,
const std::set<std::string>& granted_scopes,

@ -7,6 +7,7 @@
#include <string>
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/values.h"
#include "google_apis/gaia/gaia_auth_util.h"
@ -49,10 +50,11 @@ enum class OAuthMultiloginResponseStatus {
};
// Parses the status field of the response.
COMPONENT_EXPORT(GOOGLE_APIS)
OAuthMultiloginResponseStatus ParseOAuthMultiloginResponseStatus(
const std::string& status);
class OAuthMultiloginResult {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuthMultiloginResult {
public:
// Parses cookies and status from JSON response. Maps status to
// GoogleServiceAuthError::State values or sets error to

@ -8,13 +8,15 @@
#include <map>
#include <string>
#include "base/component_export.h"
class GURL;
// Implements the OAuth request signing process as described here:
// http://oauth.net/core/1.0/#signing_process
//
// NOTE: Currently the only supported SignatureMethod is HMAC_SHA1_SIGNATURE
class OAuthRequestSigner {
class COMPONENT_EXPORT(GOOGLE_APIS) OAuthRequestSigner {
public:
enum SignatureMethod {
HMAC_SHA1_SIGNATURE,

@ -9,6 +9,7 @@
// google_api_keys_unittest.cc.
#include <string>
#include "base/component_export.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "google_apis/buildflags.h"
@ -61,47 +62,47 @@
namespace google_apis {
extern const char kAPIKeysDevelopersHowToURL[];
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAPIKeysDevelopersHowToURL[];
// Returns true if no dummy API key is set.
bool HasAPIKeyConfigured();
COMPONENT_EXPORT(GOOGLE_APIS) bool HasAPIKeyConfigured();
// Retrieves the API key, a.k.a. developer key, or a dummy string
// if not set.
//
// Note that the key should be escaped for the context you use it in,
// e.g. URL-escaped if you use it in a URL.
std::string GetAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetAPIKey();
// Non-stable channels may have a different Google API key.
std::string GetNonStableAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetNonStableAPIKey();
// Retrieves the Chrome Remote Desktop API key.
std::string GetRemotingAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetRemotingAPIKey();
// Retrieves the Speech On-Device API (SODA) API Key.
std::string GetSodaAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetSodaAPIKey();
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Retrieves the Sharing API Key.
std::string GetSharingAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetSharingAPIKey();
// Retrieves the ReadAloud API Key.
std::string GetReadAloudAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetReadAloudAPIKey();
// Retrieves the Fresnel API Key.
std::string GetFresnelAPIKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetFresnelAPIKey();
#endif
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
// Sets the API key. This should be called as early as possible before this
// API key is even accessed. It must be called before GetAPIKey.
// TODO(https://crbug.com/1166007): Enforce this is called before GetAPIKey.
void SetAPIKey(const std::string& api_key);
COMPONENT_EXPORT(GOOGLE_APIS) void SetAPIKey(const std::string& api_key);
#endif
// Retrieves the key used to sign metrics (UMA/UKM) uploads.
std::string GetMetricsKey();
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetMetricsKey();
// Represents the different sets of client IDs and secrets in use.
enum OAuth2Client {
@ -113,13 +114,14 @@ enum OAuth2Client {
};
// Returns true if no dummy OAuth2 client ID and secret are set.
bool HasOAuthClientConfigured();
COMPONENT_EXPORT(GOOGLE_APIS) bool HasOAuthClientConfigured();
// Retrieves the OAuth2 client ID for the specified client, or the
// empty string if not set.
//
// Note that the ID should be escaped for the context you use it in,
// e.g. URL-escaped if you use it in a URL.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string GetOAuth2ClientID(OAuth2Client client);
// Retrieves the OAuth2 client secret for the specified client, or the
@ -127,22 +129,25 @@ std::string GetOAuth2ClientID(OAuth2Client client);
//
// Note that the secret should be escaped for the context you use it
// in, e.g. URL-escaped if you use it in a URL.
COMPONENT_EXPORT(GOOGLE_APIS)
std::string GetOAuth2ClientSecret(OAuth2Client client);
#if BUILDFLAG(IS_IOS)
// Sets the client id for the specified client. Should be called as early as
// possible before these ids are accessed.
COMPONENT_EXPORT(GOOGLE_APIS)
void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id);
// Sets the client secret for the specified client. Should be called as early as
// possible before these secrets are accessed.
COMPONENT_EXPORT(GOOGLE_APIS)
void SetOAuth2ClientSecret(OAuth2Client client,
const std::string& client_secret);
#endif
// Returns if the API key using in the current build is the one for official
// Google Chrome.
bool IsGoogleChromeAPIKeyUsed();
COMPONENT_EXPORT(GOOGLE_APIS) bool IsGoogleChromeAPIKeyUsed();
} // namespace google_apis

@ -7,8 +7,11 @@
#include <string>
#include "base/component_export.h"
namespace google_apis {
COMPONENT_EXPORT(GOOGLE_APIS)
std::string GetAPIKeyFromInfoPlist(const std::string& key_name);
} // namespace google_apis

@ -166,6 +166,7 @@ source_set("breakpad") {
if (is_mac) {
sources += [ "breakpad_mac.mm" ]
deps += [ "//third_party/breakpad" ]
frameworks = [ "Foundation.framework" ]
}
if (is_win) {