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"; |
27 } // namespacce | 41 } // namespacce |
28 | 42 |
29 GaiaUrls* GaiaUrls::GetInstance() { | 43 GaiaUrls* GaiaUrls::GetInstance() { |
30 return Singleton<GaiaUrls>::get(); | 44 return Singleton<GaiaUrls>::get(); |
31 } | 45 } |
32 | 46 |
33 GaiaUrls::GaiaUrls() { | 47 GaiaUrls::GaiaUrls() { |
34 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 48 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
35 std::string host_base; | 49 std::string host_base; |
36 if (command_line->HasSwitch(switches::kGaiaHost)) { | 50 if (command_line->HasSwitch(switches::kGaiaHost)) { |
(...skipping 17 matching lines...) Expand all Loading... |
54 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 68 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
55 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 69 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
56 | 70 |
57 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 71 // 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. | 72 // so that users of Gaia URLs don't have to use static constants. |
59 // http://crbug.com/97126 | 73 // http://crbug.com/97126 |
60 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 74 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
61 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; | 75 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo"; |
62 oauth_wrap_bridge_user_info_scope_ = | 76 oauth_wrap_bridge_user_info_scope_ = |
63 "https://www.googleapis.com/auth/userinfo.email"; | 77 "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; |
64 } | 83 } |
65 | 84 |
66 GaiaUrls::~GaiaUrls() { | 85 GaiaUrls::~GaiaUrls() { |
67 } | 86 } |
68 | 87 |
69 const std::string& GaiaUrls::captcha_url_prefix() { | 88 const std::string& GaiaUrls::captcha_url_prefix() { |
70 return captcha_url_prefix_; | 89 return captcha_url_prefix_; |
71 } | 90 } |
72 | 91 |
73 const std::string& GaiaUrls::gaia_origin_url() { | 92 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_; | 137 return oauth1_login_url_; |
119 } | 138 } |
120 | 139 |
121 const std::string& GaiaUrls::oauth1_login_scope() { | 140 const std::string& GaiaUrls::oauth1_login_scope() { |
122 return oauth1_login_scope_; | 141 return oauth1_login_scope_; |
123 } | 142 } |
124 | 143 |
125 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { | 144 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() { |
126 return oauth_wrap_bridge_user_info_scope_; | 145 return oauth_wrap_bridge_user_info_scope_; |
127 } | 146 } |
| 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 |