| 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 |
| 27 } // namespacce | 42 } // namespacce |
| 28 | 43 |
| 29 GaiaUrls* GaiaUrls::GetInstance() { | 44 GaiaUrls* GaiaUrls::GetInstance() { |
| 30 return Singleton<GaiaUrls>::get(); | 45 return Singleton<GaiaUrls>::get(); |
| 31 } | 46 } |
| 32 | 47 |
| 33 GaiaUrls::GaiaUrls() { | 48 GaiaUrls::GaiaUrls() { |
| 34 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 49 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 35 std::string host_base; | 50 std::string host_base; |
| 36 if (command_line->HasSwitch(switches::kGaiaHost)) { | 51 if (command_line->HasSwitch(switches::kGaiaHost)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 69 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
| 55 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 70 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
| 56 | 71 |
| 57 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 72 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
| 58 // so that users of Gaia URLs don't have to use static constants. | 73 // so that users of Gaia URLs don't have to use static constants. |
| 59 // http://crbug.com/97126 | 74 // http://crbug.com/97126 |
| 60 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 75 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
| 61 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; | 76 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; |
| 62 oauth_wrap_bridge_user_info_scope_ = | 77 oauth_wrap_bridge_user_info_scope_ = |
| 63 "https://www.googleapis.com/auth/userinfo.email"; | 78 "https://www.googleapis.com/auth/userinfo.email"; |
| 79 |
| 80 oauth2_chrome_client_id_ = kOAuth2ChromeClientId; |
| 81 oauth2_chrome_client_secret_ = kOAuth2ChromeClientSecret; |
| 82 client_login_to_oauth2_url_ = kClientLoginToOAuth2Url; |
| 83 oauth2_token_url_ = kOAuth2TokenUrl; |
| 64 } | 84 } |
| 65 | 85 |
| 66 GaiaUrls::~GaiaUrls() { | 86 GaiaUrls::~GaiaUrls() { |
| 67 } | 87 } |
| 68 | 88 |
| 69 const std::string& GaiaUrls::captcha_url_prefix() { | 89 const std::string& GaiaUrls::captcha_url_prefix() { |
| 70 return captcha_url_prefix_; | 90 return captcha_url_prefix_; |
| 71 } | 91 } |
| 72 | 92 |
| 73 const std::string& GaiaUrls::gaia_origin_url() { | 93 const std::string& GaiaUrls::gaia_origin_url() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return oauth1_login_url_; | 138 return oauth1_login_url_; |
| 119 } | 139 } |
| 120 | 140 |
| 121 const std::string& GaiaUrls::oauth1_login_scope() { | 141 const std::string& GaiaUrls::oauth1_login_scope() { |
| 122 return oauth1_login_scope_; | 142 return oauth1_login_scope_; |
| 123 } | 143 } |
| 124 | 144 |
| 125 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { | 145 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { |
| 126 return oauth_wrap_bridge_user_info_scope_; | 146 return oauth_wrap_bridge_user_info_scope_; |
| 127 } | 147 } |
| 148 |
| 149 const std::string& GaiaUrls::oauth2_chrome_client_id() { |
| 150 return oauth2_chrome_client_id_; |
| 151 } |
| 152 |
| 153 const std::string& GaiaUrls::oauth2_chrome_client_secret() { |
| 154 return oauth2_chrome_client_secret_; |
| 155 } |
| 156 |
| 157 const std::string& GaiaUrls::client_login_to_oauth2_url() { |
| 158 return client_login_to_oauth2_url_; |
| 159 } |
| 160 |
| 161 const std::string& GaiaUrls::oauth2_token_url() { |
| 162 return oauth2_token_url_; |
| 163 } |
| OLD | NEW |