Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: chrome/browser/profiles/profile_downloader.cc

Issue 9572001: Do cookie checks in NetworkDelegate instead of the URLRequest::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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.h" 12 #include "base/message_loop.h"
13 #include "base/string_split.h" 13 #include "base/string_split.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_downloader_delegate.h" 17 #include "chrome/browser/profiles/profile_downloader_delegate.h"
18 #include "chrome/browser/signin/token_service.h" 18 #include "chrome/browser/signin/token_service.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/net/gaia/gaia_constants.h" 20 #include "chrome/common/net/gaia/gaia_constants.h"
21 #include "chrome/common/net/gaia/gaia_urls.h" 21 #include "chrome/common/net/gaia/gaia_urls.h"
22 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h" 22 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/common/content_url_request_user_data.h"
29 #include "content/public/common/url_fetcher.h" 30 #include "content/public/common/url_fetcher.h"
30 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
31 #include "net/base/load_flags.h" 32 #include "net/base/load_flags.h"
32 #include "skia/ext/image_operations.h" 33 #include "skia/ext/image_operations.h"
33 34
34 using content::BrowserThread; 35 using content::BrowserThread;
35 36
36 namespace { 37 namespace {
37 38
38 // Template for optional authorization header when using an OAuth access token. 39 // Template for optional authorization header when using an OAuth access token.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 std::string ProfileDownloader::GetProfilePictureURL() const { 239 std::string ProfileDownloader::GetProfilePictureURL() const {
239 return picture_url_; 240 return picture_url_;
240 } 241 }
241 242
242 void ProfileDownloader::StartFetchingImage() { 243 void ProfileDownloader::StartFetchingImage() {
243 VLOG(1) << "Fetching user entry with token: " << auth_token_; 244 VLOG(1) << "Fetching user entry with token: " << auth_token_;
244 user_entry_fetcher_.reset(content::URLFetcher::Create( 245 user_entry_fetcher_.reset(content::URLFetcher::Create(
245 GURL(kUserEntryURL), content::URLFetcher::GET, this)); 246 GURL(kUserEntryURL), content::URLFetcher::GET, this));
246 user_entry_fetcher_->SetRequestContext( 247 user_entry_fetcher_->SetRequestContext(
247 delegate_->GetBrowserProfile()->GetRequestContext()); 248 delegate_->GetBrowserProfile()->GetRequestContext());
249 // TODO(jochen): Do cookie audit.
250 user_entry_fetcher_->SetContentURLRequestUserData(
251 new content::ContentURLRequestUserData());
248 user_entry_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 252 user_entry_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
249 if (!auth_token_.empty()) { 253 if (!auth_token_.empty()) {
250 user_entry_fetcher_->SetExtraRequestHeaders( 254 user_entry_fetcher_->SetExtraRequestHeaders(
251 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); 255 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
252 } 256 }
253 user_entry_fetcher_->Start(); 257 user_entry_fetcher_->Start();
254 } 258 }
255 259
256 void ProfileDownloader::StartFetchingOAuth2AccessToken() { 260 void ProfileDownloader::StartFetchingOAuth2AccessToken() {
257 TokenService* service = delegate_->GetBrowserProfile()->GetTokenService(); 261 TokenService* service = delegate_->GetBrowserProfile()->GetTokenService();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 picture_status_ = PICTURE_CACHED; 304 picture_status_ = PICTURE_CACHED;
301 delegate_->OnDownloadComplete(this, true); 305 delegate_->OnDownloadComplete(this, true);
302 return; 306 return;
303 } 307 }
304 VLOG(1) << "Fetching profile image from " << image_url; 308 VLOG(1) << "Fetching profile image from " << image_url;
305 picture_url_ = image_url; 309 picture_url_ = image_url;
306 profile_image_fetcher_.reset(content::URLFetcher::Create( 310 profile_image_fetcher_.reset(content::URLFetcher::Create(
307 GURL(image_url), content::URLFetcher::GET, this)); 311 GURL(image_url), content::URLFetcher::GET, this));
308 profile_image_fetcher_->SetRequestContext( 312 profile_image_fetcher_->SetRequestContext(
309 delegate_->GetBrowserProfile()->GetRequestContext()); 313 delegate_->GetBrowserProfile()->GetRequestContext());
314 // TODO(jochen): Do cookie audit.
315 profile_image_fetcher_->SetContentURLRequestUserData(
316 new content::ContentURLRequestUserData());
310 profile_image_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 317 profile_image_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
311 if (!auth_token_.empty()) { 318 if (!auth_token_.empty()) {
312 profile_image_fetcher_->SetExtraRequestHeaders( 319 profile_image_fetcher_->SetExtraRequestHeaders(
313 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str())); 320 base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
314 } 321 }
315 profile_image_fetcher_->Start(); 322 profile_image_fetcher_->Start();
316 } else if (source == profile_image_fetcher_.get()) { 323 } else if (source == profile_image_fetcher_.get()) {
317 VLOG(1) << "Decoding the image..."; 324 VLOG(1) << "Decoding the image...";
318 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( 325 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder(
319 this, data); 326 this, data);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token) { 376 void ProfileDownloader::OnGetTokenSuccess(const std::string& access_token) {
370 auth_token_ = access_token; 377 auth_token_ = access_token;
371 StartFetchingImage(); 378 StartFetchingImage();
372 } 379 }
373 380
374 // Callback for OAuth2AccessTokenFetcher on failure. 381 // Callback for OAuth2AccessTokenFetcher on failure.
375 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) { 382 void ProfileDownloader::OnGetTokenFailure(const GoogleServiceAuthError& error) {
376 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed"; 383 LOG(WARNING) << "ProfileDownloader: token request using refresh token failed";
377 delegate_->OnDownloadComplete(this, false); 384 delegate_->OnDownloadComplete(this, false);
378 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698