| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/extensions/api/identity/gaia_web_auth_flow.h" | 5 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 "origin=chrome-extension://%s/&" | 45 "origin=chrome-extension://%s/&" |
| 46 "redirect_uri=%s:/%s&" | 46 "redirect_uri=%s:/%s&" |
| 47 "hl=%s"; | 47 "hl=%s"; |
| 48 // Additional parameters to pass if device_id is enabled. | 48 // Additional parameters to pass if device_id is enabled. |
| 49 const char kOAuth2AuthorizeFormatDeviceIdAddendum[] = | 49 const char kOAuth2AuthorizeFormatDeviceIdAddendum[] = |
| 50 "&device_id=%s&" | 50 "&device_id=%s&" |
| 51 "device_type=chrome"; | 51 "device_type=chrome"; |
| 52 | 52 |
| 53 std::vector<std::string> scopes(token_key->scopes.begin(), | 53 std::vector<std::string> scopes(token_key->scopes.begin(), |
| 54 token_key->scopes.end()); | 54 token_key->scopes.end()); |
| 55 std::vector<std::string> client_id_parts; | 55 std::vector<std::string> client_id_parts = base::SplitString( |
| 56 base::SplitString(oauth2_client_id, '.', &client_id_parts); | 56 oauth2_client_id, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 57 std::reverse(client_id_parts.begin(), client_id_parts.end()); | 57 std::reverse(client_id_parts.begin(), client_id_parts.end()); |
| 58 redirect_scheme_ = base::JoinString(client_id_parts, "."); | 58 redirect_scheme_ = base::JoinString(client_id_parts, "."); |
| 59 std::string signin_scoped_device_id; | 59 std::string signin_scoped_device_id; |
| 60 // profile_ can be nullptr in unittests. | 60 // profile_ can be nullptr in unittests. |
| 61 SigninClient* signin_client = | 61 SigninClient* signin_client = |
| 62 profile_ ? ChromeSigninClientFactory::GetForProfile(profile_) : nullptr; | 62 profile_ ? ChromeSigninClientFactory::GetForProfile(profile_) : nullptr; |
| 63 if (signin_client) | 63 if (signin_client) |
| 64 signin_scoped_device_id = signin_client->GetSigninScopedDeviceId(); | 64 signin_scoped_device_id = signin_client->GetSigninScopedDeviceId(); |
| 65 | 65 |
| 66 redirect_path_prefix_ = base::StringPrintf(kOAuth2RedirectPathFormat, | 66 redirect_path_prefix_ = base::StringPrintf(kOAuth2RedirectPathFormat, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { | 234 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { |
| 235 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, | 235 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, |
| 236 profile_, | 236 profile_, |
| 237 url, | 237 url, |
| 238 WebAuthFlow::INTERACTIVE)); | 238 WebAuthFlow::INTERACTIVE)); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace extensions | 241 } // namespace extensions |
| OLD | NEW |