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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_downloader_delegate.h" | 19 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
21 #include "chrome/browser/signin/account_fetcher_service_factory.h" | 21 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
22 #include "chrome/browser/signin/account_tracker_service_factory.h" | 22 #include "chrome/browser/signin/account_tracker_service_factory.h" |
23 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 23 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "components/data_use_measurement/core/data_use_user_data.h" |
26 #include "components/signin/core/browser/account_fetcher_service.h" | 27 #include "components/signin/core/browser/account_fetcher_service.h" |
27 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 28 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
28 #include "components/signin/core/browser/signin_client.h" | 29 #include "components/signin/core/browser/signin_client.h" |
29 #include "components/signin/core/browser/signin_manager.h" | 30 #include "components/signin/core/browser/signin_manager.h" |
30 #include "components/signin/core/common/profile_management_switches.h" | 31 #include "components/signin/core/common/profile_management_switches.h" |
31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
32 #include "google_apis/gaia/gaia_constants.h" | 33 #include "google_apis/gaia/gaia_constants.h" |
33 #include "net/base/load_flags.h" | 34 #include "net/base/load_flags.h" |
34 #include "net/url_request/url_fetcher.h" | 35 #include "net/url_request/url_fetcher.h" |
35 #include "net/url_request/url_request_status.h" | 36 #include "net/url_request/url_request_status.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 image_url_with_size == delegate_->GetCachedPictureURL()) { | 279 image_url_with_size == delegate_->GetCachedPictureURL()) { |
279 VLOG(1) << "Picture URL matches cached picture URL"; | 280 VLOG(1) << "Picture URL matches cached picture URL"; |
280 picture_status_ = PICTURE_CACHED; | 281 picture_status_ = PICTURE_CACHED; |
281 delegate_->OnProfileDownloadSuccess(this); | 282 delegate_->OnProfileDownloadSuccess(this); |
282 return; | 283 return; |
283 } | 284 } |
284 | 285 |
285 VLOG(1) << "Fetching profile image from " << image_url_with_size; | 286 VLOG(1) << "Fetching profile image from " << image_url_with_size; |
286 profile_image_fetcher_ = net::URLFetcher::Create( | 287 profile_image_fetcher_ = net::URLFetcher::Create( |
287 GURL(image_url_with_size), net::URLFetcher::GET, this); | 288 GURL(image_url_with_size), net::URLFetcher::GET, this); |
| 289 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 290 profile_image_fetcher_.get(), |
| 291 data_use_measurement::DataUseUserData::PROFILE_DOWNLOADER); |
288 profile_image_fetcher_->SetRequestContext( | 292 profile_image_fetcher_->SetRequestContext( |
289 delegate_->GetBrowserProfile()->GetRequestContext()); | 293 delegate_->GetBrowserProfile()->GetRequestContext()); |
290 profile_image_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 294 profile_image_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
291 net::LOAD_DO_NOT_SAVE_COOKIES); | 295 net::LOAD_DO_NOT_SAVE_COOKIES); |
292 | 296 |
293 if (!auth_token_.empty()) { | 297 if (!auth_token_.empty()) { |
294 profile_image_fetcher_->SetExtraRequestHeaders( | 298 profile_image_fetcher_->SetExtraRequestHeaders( |
295 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); | 299 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); |
296 } | 300 } |
297 | 301 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 account_info_ = info; | 383 account_info_ = info; |
380 | 384 |
381 // If the StartFetchingImage was called before we had valid info, the | 385 // If the StartFetchingImage was called before we had valid info, the |
382 // downloader has been waiting so we need to fetch the image data now. | 386 // downloader has been waiting so we need to fetch the image data now. |
383 if (waiting_for_account_info_) { | 387 if (waiting_for_account_info_) { |
384 FetchImageData(); | 388 FetchImageData(); |
385 waiting_for_account_info_ = false; | 389 waiting_for_account_info_ = false; |
386 } | 390 } |
387 } | 391 } |
388 } | 392 } |
OLD | NEW |