| 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" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 13 #include "google_apis/gaia/gaia_urls.h" | 14 #include "google_apis/gaia/gaia_urls.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 GaiaWebAuthFlow::GaiaWebAuthFlow(Delegate* delegate, | 19 GaiaWebAuthFlow::GaiaWebAuthFlow(Delegate* delegate, |
| 19 Profile* profile, | 20 Profile* profile, |
| 20 const std::string& extension_id, | 21 const std::string& extension_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 51 } | 52 } |
| 52 | 53 |
| 53 GaiaWebAuthFlow::~GaiaWebAuthFlow() { | 54 GaiaWebAuthFlow::~GaiaWebAuthFlow() { |
| 54 if (web_flow_) | 55 if (web_flow_) |
| 55 web_flow_.release()->DetachDelegateAndDelete(); | 56 web_flow_.release()->DetachDelegateAndDelete(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void GaiaWebAuthFlow::Start() { | 59 void GaiaWebAuthFlow::Start() { |
| 59 ProfileOAuth2TokenService* token_service = | 60 ProfileOAuth2TokenService* token_service = |
| 60 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 61 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 61 ubertoken_fetcher_.reset(new UbertokenFetcher(profile_, this)); | 62 ubertoken_fetcher_.reset(new UbertokenFetcher(token_service, |
| 63 this, |
| 64 profile_->GetRequestContext())); |
| 62 ubertoken_fetcher_->StartFetchingToken(token_service->GetPrimaryAccountId()); | 65 ubertoken_fetcher_->StartFetchingToken(token_service->GetPrimaryAccountId()); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void GaiaWebAuthFlow::OnUbertokenSuccess(const std::string& token) { | 68 void GaiaWebAuthFlow::OnUbertokenSuccess(const std::string& token) { |
| 66 const char kMergeSessionQueryFormat[] = "?uberauth=%s&" | 69 const char kMergeSessionQueryFormat[] = "?uberauth=%s&" |
| 67 "continue=%s&" | 70 "continue=%s&" |
| 68 "source=appsv2"; | 71 "source=appsv2"; |
| 69 | 72 |
| 70 std::string merge_query = base::StringPrintf( | 73 std::string merge_query = base::StringPrintf( |
| 71 kMergeSessionQueryFormat, | 74 kMergeSessionQueryFormat, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 173 } |
| 171 | 174 |
| 172 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { | 175 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { |
| 173 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, | 176 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, |
| 174 profile_, | 177 profile_, |
| 175 url, | 178 url, |
| 176 WebAuthFlow::INTERACTIVE)); | 179 WebAuthFlow::INTERACTIVE)); |
| 177 } | 180 } |
| 178 | 181 |
| 179 } // namespace extensions | 182 } // namespace extensions |
| OLD | NEW |