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

Side by Side Diff: chrome/browser/chromeos/login/cookie_fetcher.cc

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/login/cookie_fetcher.h" 5 #include "chrome/browser/chromeos/login/cookie_fetcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/browser/chromeos/login/client_login_response_handler.h" 9 #include "chrome/browser/chromeos/login/client_login_response_handler.h"
10 #include "chrome/browser/chromeos/login/issue_response_handler.h" 10 #include "chrome/browser/chromeos/login/issue_response_handler.h"
11 #include "chrome/browser/chromeos/login/login_utils.h" 11 #include "chrome/browser/chromeos/login/login_utils.h"
12 #include "chrome/browser/net/chrome_url_request_context.h" 12 #include "chrome/browser/net/chrome_url_request_context.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "content/common/net/url_fetcher.h"
16 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
17 18
18 namespace chromeos { 19 namespace chromeos {
19 20
20 CookieFetcher::CookieFetcher(Profile* profile) : profile_(profile) { 21 CookieFetcher::CookieFetcher(Profile* profile) : profile_(profile) {
21 CHECK(profile_); 22 CHECK(profile_);
22 client_login_handler_.reset( 23 client_login_handler_.reset(
23 new ClientLoginResponseHandler(profile_->GetRequestContext())); 24 new ClientLoginResponseHandler(profile_->GetRequestContext()));
24 issue_handler_.reset( 25 issue_handler_.reset(
25 new IssueResponseHandler(profile_->GetRequestContext())); 26 new IssueResponseHandler(profile_->GetRequestContext()));
26 } 27 }
27 28
28 CookieFetcher::CookieFetcher(Profile* profile, 29 CookieFetcher::CookieFetcher(Profile* profile,
29 AuthResponseHandler* cl_handler, 30 AuthResponseHandler* cl_handler,
30 AuthResponseHandler* i_handler) 31 AuthResponseHandler* i_handler)
31 : profile_(profile), 32 : profile_(profile),
32 client_login_handler_(cl_handler), 33 client_login_handler_(cl_handler),
33 issue_handler_(i_handler) { 34 issue_handler_(i_handler) {
34 } 35 }
35 36
36 CookieFetcher::~CookieFetcher() {} 37 CookieFetcher::~CookieFetcher() {}
37 38
38 void CookieFetcher::AttemptFetch(const std::string& credentials) { 39 void CookieFetcher::AttemptFetch(const std::string& credentials) {
39 VLOG(1) << "Getting auth token..."; 40 VLOG(1) << "Getting auth token...";
40 fetcher_.reset(client_login_handler_->Handle(credentials, this)); 41 fetcher_.reset(client_login_handler_->Handle(credentials, this));
41 } 42 }
42 43
43 void CookieFetcher::OnURLFetchComplete(const URLFetcher* source, 44 void CookieFetcher::OnURLFetchComplete(const URLFetcher* source) {
44 const GURL& url, 45 if (source->status().is_success() &&
45 const net::URLRequestStatus& status, 46 source->response_code() == kHttpSuccess) {
46 int response_code, 47 if (issue_handler_->CanHandle(source->url())) {
47 const net::ResponseCookies& cookies,
48 const std::string& data) {
49 if (status.is_success() && response_code == kHttpSuccess) {
50 if (issue_handler_->CanHandle(url)) {
51 VLOG(1) << "Handling auth token"; 48 VLOG(1) << "Handling auth token";
49 std::string data;
50 source->GetResponseAsString(&data);
52 fetcher_.reset(issue_handler_->Handle(data, this)); 51 fetcher_.reset(issue_handler_->Handle(data, this));
53 return; 52 return;
54 } 53 }
55 } 54 }
56 delete this; 55 delete this;
57 } 56 }
58 57
59 } // namespace chromeos 58 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698