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/profiles/profile_downloader.h" | 5 #include "chrome/browser/profiles/profile_downloader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/signin/account_fetcher_service_factory.h" | 24 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
25 #include "chrome/browser/signin/account_tracker_service_factory.h" | 25 #include "chrome/browser/signin/account_tracker_service_factory.h" |
26 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 26 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
28 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
29 #include "components/data_use_measurement/core/data_use_user_data.h" | 29 #include "components/data_use_measurement/core/data_use_user_data.h" |
30 #include "components/signin/core/browser/account_fetcher_service.h" | 30 #include "components/signin/core/browser/account_fetcher_service.h" |
31 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 31 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
32 #include "components/signin/core/browser/signin_client.h" | 32 #include "components/signin/core/browser/signin_client.h" |
33 #include "components/signin/core/browser/signin_manager.h" | 33 #include "components/signin/core/browser/signin_manager.h" |
34 #include "components/signin/core/common/profile_management_switches.h" | |
35 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
36 #include "google_apis/gaia/gaia_constants.h" | 35 #include "google_apis/gaia/gaia_constants.h" |
37 #include "net/base/load_flags.h" | 36 #include "net/base/load_flags.h" |
38 #include "net/traffic_annotation/network_traffic_annotation.h" | 37 #include "net/traffic_annotation/network_traffic_annotation.h" |
39 #include "net/url_request/url_fetcher.h" | 38 #include "net/url_request/url_fetcher.h" |
40 #include "net/url_request/url_request_status.h" | 39 #include "net/url_request/url_request_status.h" |
41 #include "skia/ext/image_operations.h" | 40 #include "skia/ext/image_operations.h" |
42 #include "url/gurl.h" | 41 #include "url/gurl.h" |
43 | 42 |
44 using content::BrowserThread; | 43 using content::BrowserThread; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 FetchImageData(); | 186 FetchImageData(); |
188 } else { | 187 } else { |
189 waiting_for_account_info_ = true; | 188 waiting_for_account_info_ = true; |
190 } | 189 } |
191 } | 190 } |
192 | 191 |
193 void ProfileDownloader::StartFetchingOAuth2AccessToken() { | 192 void ProfileDownloader::StartFetchingOAuth2AccessToken() { |
194 Profile* profile = delegate_->GetBrowserProfile(); | 193 Profile* profile = delegate_->GetBrowserProfile(); |
195 OAuth2TokenService::ScopeSet scopes; | 194 OAuth2TokenService::ScopeSet scopes; |
196 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); | 195 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); |
197 // Increase scope to get hd attribute to determine if lock should be enabled. | 196 // Required to determine if lock should be enabled. |
198 if (switches::IsNewProfileManagement()) | 197 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); |
199 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); | |
200 ProfileOAuth2TokenService* token_service = | 198 ProfileOAuth2TokenService* token_service = |
201 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 199 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
202 oauth2_access_token_request_ = token_service->StartRequest( | 200 oauth2_access_token_request_ = token_service->StartRequest( |
203 account_id_, scopes, this); | 201 account_id_, scopes, this); |
204 } | 202 } |
205 | 203 |
206 ProfileDownloader::~ProfileDownloader() { | 204 ProfileDownloader::~ProfileDownloader() { |
207 // Ensures PO2TS observation is cleared when ProfileDownloader is destructed | 205 // Ensures PO2TS observation is cleared when ProfileDownloader is destructed |
208 // before refresh token is available. | 206 // before refresh token is available. |
209 ProfileOAuth2TokenService* service = | 207 ProfileOAuth2TokenService* service = |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // downloader has been waiting so we need to fetch the image data now. | 363 // downloader has been waiting so we need to fetch the image data now. |
366 if (waiting_for_account_info_) { | 364 if (waiting_for_account_info_) { |
367 waiting_for_account_info_ = false; | 365 waiting_for_account_info_ = false; |
368 // FetchImageData might call the delegate's OnProfileDownloadSuccess | 366 // FetchImageData might call the delegate's OnProfileDownloadSuccess |
369 // synchronously, causing |this| to be deleted so there should not be more | 367 // synchronously, causing |this| to be deleted so there should not be more |
370 // code after it. | 368 // code after it. |
371 FetchImageData(); | 369 FetchImageData(); |
372 } | 370 } |
373 } | 371 } |
374 } | 372 } |
OLD | NEW |