| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/net/gaia/gaia_urls.h" | 5 #include "chrome/common/net/gaia/gaia_urls.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 const char kDefaultGaiaBaseUrl[] = "www.google.com"; | 12 const char kDefaultGaiaBaseUrl[] = "www.google.com"; |
| 13 | 13 |
| 14 const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; | 14 const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; |
| 15 const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; | 15 const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; |
| 16 const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; | 16 const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; |
| 17 const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; | 17 const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; |
| 18 const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; | 18 const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; |
| 19 const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; | 19 const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; |
| 20 | 20 |
| 21 const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; | 21 const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; |
| 22 const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; | 22 const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; |
| 23 const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; | 23 const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; |
| 24 const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; | 24 const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; |
| 25 const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; | 25 const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; |
| 26 | 26 |
| 27 // OAuth2 client id for Google Chrome which is registered as an | |
| 28 // installed application. | |
| 29 static const char kOAuth2ChromeClientId[] = | |
| 30 "77185425430.apps.googleusercontent.com"; | |
| 31 // For an installed application, client secret is not really a secret since | |
| 32 // it is expected to be embeeded in the application. | |
| 33 // See documentation at | |
| 34 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html | |
| 35 static const char kOAuth2ChromeClientSecret[] = | |
| 36 "OTJgUOQcT7lO7GsGZq2G4IlT"; | |
| 37 const char kClientLoginToOAuth2Url[] = | |
| 38 "https://accounts.google.com/o/oauth2/programmatic_auth"; | |
| 39 const char kOAuth2TokenUrl[] = | |
| 40 "https://accounts.google.com/o/oauth2/token"; | |
| 41 } // namespacce | 27 } // namespacce |
| 42 | 28 |
| 43 GaiaUrls* GaiaUrls::GetInstance() { | 29 GaiaUrls* GaiaUrls::GetInstance() { |
| 44 return Singleton<GaiaUrls>::get(); | 30 return Singleton<GaiaUrls>::get(); |
| 45 } | 31 } |
| 46 | 32 |
| 47 GaiaUrls::GaiaUrls() { | 33 GaiaUrls::GaiaUrls() { |
| 48 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 34 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 49 std::string host_base; | 35 std::string host_base; |
| 50 if (command_line->HasSwitch(switches::kGaiaHost)) { | 36 if (command_line->HasSwitch(switches::kGaiaHost)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 54 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
| 69 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 55 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
| 70 | 56 |
| 71 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 57 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
| 72 // so that users of Gaia URLs don't have to use static constants. | 58 // so that users of Gaia URLs don't have to use static constants. |
| 73 // http://crbug.com/97126 | 59 // http://crbug.com/97126 |
| 74 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 60 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
| 75 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; | 61 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; |
| 76 oauth_wrap_bridge_user_info_scope_ = | 62 oauth_wrap_bridge_user_info_scope_ = |
| 77 "https://www.googleapis.com/auth/userinfo.email"; | 63 "https://www.googleapis.com/auth/userinfo.email"; |
| 78 | |
| 79 oauth2_chrome_client_id_ = kOAuth2ChromeClientId; | |
| 80 oauth2_chrome_client_secret_ = kOAuth2ChromeClientSecret; | |
| 81 client_login_to_oauth2_url_ = kClientLoginToOAuth2Url; | |
| 82 oauth2_token_url_ = kOAuth2TokenUrl; | |
| 83 } | 64 } |
| 84 | 65 |
| 85 GaiaUrls::~GaiaUrls() { | 66 GaiaUrls::~GaiaUrls() { |
| 86 } | 67 } |
| 87 | 68 |
| 88 const std::string& GaiaUrls::captcha_url_prefix() { | 69 const std::string& GaiaUrls::captcha_url_prefix() { |
| 89 return captcha_url_prefix_; | 70 return captcha_url_prefix_; |
| 90 } | 71 } |
| 91 | 72 |
| 92 const std::string& GaiaUrls::gaia_origin_url() { | 73 const std::string& GaiaUrls::gaia_origin_url() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return oauth1_login_url_; | 118 return oauth1_login_url_; |
| 138 } | 119 } |
| 139 | 120 |
| 140 const std::string& GaiaUrls::oauth1_login_scope() { | 121 const std::string& GaiaUrls::oauth1_login_scope() { |
| 141 return oauth1_login_scope_; | 122 return oauth1_login_scope_; |
| 142 } | 123 } |
| 143 | 124 |
| 144 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { | 125 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { |
| 145 return oauth_wrap_bridge_user_info_scope_; | 126 return oauth_wrap_bridge_user_info_scope_; |
| 146 } | 127 } |
| 147 | |
| 148 const std::string& GaiaUrls::oauth2_chrome_client_id() { | |
| 149 return oauth2_chrome_client_id_; | |
| 150 } | |
| 151 | |
| 152 const std::string& GaiaUrls::oauth2_chrome_client_secret() { | |
| 153 return oauth2_chrome_client_secret_; | |
| 154 } | |
| 155 | |
| 156 const std::string& GaiaUrls::client_login_to_oauth2_url() { | |
| 157 return client_login_to_oauth2_url_; | |
| 158 } | |
| 159 | |
| 160 const std::string& GaiaUrls::oauth2_token_url() { | |
| 161 return oauth2_token_url_; | |
| 162 } | |
| OLD | NEW |