OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Gaia service constants | 12 const char kDefaultGaiaBaseUrl[] = "www.google.com"; |
13 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; | |
14 | 13 |
15 const char kCaptchaUrlPrefixSuffix[] = "/"; | 14 const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; |
16 const char kClientLoginUrlSuffix[] = "/ClientLogin"; | 15 const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; |
17 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; | 16 const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; |
18 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; | 17 const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; |
19 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; | 18 const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; |
20 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; | 19 const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; |
21 const char kMergeSessionUrlSuffix[] = "/MergeSession"; | |
22 | 20 |
23 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; | 21 const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; |
24 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; | 22 const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; |
25 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; | 23 const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; |
26 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; | 24 const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; |
27 | 25 const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; |
28 // Federated login constants | |
29 const char kDefaultFederatedLoginBaseUrl[] = "https://www.google.com/accounts"; | |
30 const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken"; | |
31 | 26 |
32 // OAuth2 client id for Google Chrome which is registered as an | 27 // OAuth2 client id for Google Chrome which is registered as an |
33 // installed application. | 28 // installed application. |
34 static const char kOAuth2ChromeClientId[] = | 29 static const char kOAuth2ChromeClientId[] = |
35 "77185425430.apps.googleusercontent.com"; | 30 "77185425430.apps.googleusercontent.com"; |
36 // For an installed application, client secret is not really a secret since | 31 // For an installed application, client secret is not really a secret since |
37 // it is expected to be embeeded in the application. | 32 // it is expected to be embeeded in the application. |
38 // See documentation at | 33 // See documentation at |
39 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html | 34 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html |
40 static const char kOAuth2ChromeClientSecret[] = | 35 static const char kOAuth2ChromeClientSecret[] = |
41 "OTJgUOQcT7lO7GsGZq2G4IlT"; | 36 "OTJgUOQcT7lO7GsGZq2G4IlT"; |
42 const char kClientLoginToOAuth2Url[] = | 37 const char kClientLoginToOAuth2Url[] = |
43 "https://accounts.google.com/o/oauth2/programmatic_auth"; | 38 "https://accounts.google.com/o/oauth2/programmatic_auth"; |
44 const char kOAuth2TokenUrl[] = | 39 const char kOAuth2TokenUrl[] = |
45 "https://accounts.google.com/o/oauth2/token"; | 40 "https://accounts.google.com/o/oauth2/token"; |
46 const char kOAuth2IssueTokenUrl[] = | 41 const char kOAuth2IssueTokenUrl[] = |
47 "https://www.googleapis.com/oauth2/v2/IssueToken"; | 42 "https://www.googleapis.com/oauth2/v2/IssueToken"; |
48 | |
49 } // namespacce | 43 } // namespacce |
50 | 44 |
51 GaiaUrls* GaiaUrls::GetInstance() { | 45 GaiaUrls* GaiaUrls::GetInstance() { |
52 return Singleton<GaiaUrls>::get(); | 46 return Singleton<GaiaUrls>::get(); |
53 } | 47 } |
54 | 48 |
55 GaiaUrls::GaiaUrls() { | 49 GaiaUrls::GaiaUrls() { |
56 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 50 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
57 std::string host_base; | 51 std::string host_base; |
58 if (command_line->HasSwitch(switches::kGaiaHost)) { | 52 if (command_line->HasSwitch(switches::kGaiaHost)) { |
59 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); | 53 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); |
60 } else { | 54 } else { |
61 host_base = kDefaultGaiaBaseUrl; | 55 host_base = kDefaultGaiaBaseUrl; |
62 } | 56 } |
63 | 57 |
64 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; | 58 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; |
65 gaia_origin_url_ = "https://" + host_base; | 59 gaia_origin_url_ = "https://" + host_base; |
66 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; | 60 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; |
67 service_login_url_ = gaia_origin_url_ + kServiceLoginUrlSuffix; | |
68 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; | 61 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; |
69 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; | 62 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; |
70 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; | 63 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; |
71 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; | 64 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; |
72 | 65 |
73 // Federated login is not part of Gaia and has its own endpoints. | 66 get_oauth_token_url_ = gaia_origin_url_ + kGetOAuthTokenUrlSuffix; |
74 get_oauth_token_url_ = std::string(kDefaultFederatedLoginBaseUrl) + | |
75 kGetOAuthTokenUrlSuffix; | |
76 | |
77 oauth_get_access_token_url_ = gaia_origin_url_ + | 67 oauth_get_access_token_url_ = gaia_origin_url_ + |
78 kOAuthGetAccessTokenUrlSuffix; | 68 kOAuthGetAccessTokenUrlSuffix; |
79 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; | 69 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; |
80 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 70 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
81 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 71 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
82 | 72 |
83 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 73 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
84 // so that users of Gaia URLs don't have to use static constants. | 74 // so that users of Gaia URLs don't have to use static constants. |
85 // http://crbug.com/97126 | 75 // http://crbug.com/97126 |
86 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 76 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
(...skipping 20 matching lines...) Expand all Loading... |
107 } | 97 } |
108 | 98 |
109 const std::string& GaiaUrls::gaia_origin_url() { | 99 const std::string& GaiaUrls::gaia_origin_url() { |
110 return gaia_origin_url_; | 100 return gaia_origin_url_; |
111 } | 101 } |
112 | 102 |
113 const std::string& GaiaUrls::client_login_url() { | 103 const std::string& GaiaUrls::client_login_url() { |
114 return client_login_url_; | 104 return client_login_url_; |
115 } | 105 } |
116 | 106 |
117 const std::string& GaiaUrls::service_login_url() { | |
118 return service_login_url_; | |
119 } | |
120 | |
121 const std::string& GaiaUrls::issue_auth_token_url() { | 107 const std::string& GaiaUrls::issue_auth_token_url() { |
122 return issue_auth_token_url_; | 108 return issue_auth_token_url_; |
123 } | 109 } |
124 | 110 |
125 const std::string& GaiaUrls::get_user_info_url() { | 111 const std::string& GaiaUrls::get_user_info_url() { |
126 return get_user_info_url_; | 112 return get_user_info_url_; |
127 } | 113 } |
128 | 114 |
129 const std::string& GaiaUrls::token_auth_url() { | 115 const std::string& GaiaUrls::token_auth_url() { |
130 return token_auth_url_; | 116 return token_auth_url_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 173 } |
188 | 174 |
189 const std::string& GaiaUrls::oauth2_issue_token_url() { | 175 const std::string& GaiaUrls::oauth2_issue_token_url() { |
190 return oauth2_issue_token_url_; | 176 return oauth2_issue_token_url_; |
191 } | 177 } |
192 | 178 |
193 | 179 |
194 const std::string& GaiaUrls::gaia_login_form_realm() { | 180 const std::string& GaiaUrls::gaia_login_form_realm() { |
195 return gaia_login_form_realm_; | 181 return gaia_login_form_realm_; |
196 } | 182 } |
OLD | NEW |