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

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

Issue 2729020: Show Captcha dialog. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: remove debug line Created 10 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/image_downloader.h"
6
7 #include "base/logging.h"
8 #include "base/message_loop.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/profile_manager.h"
12 #include "chrome/common/net/url_fetcher.h"
13
14 namespace chromeos {
15
16 namespace {
17
18 // Template for optional authorization header.
19 const char kAuthorizationHeader[] = "Authorization: GoogleLogin auth=%s";
20
21 } // namespace
22
23 ImageDownloader::ImageDownloader(ImageDecoder::Delegate* delegate,
24 const GURL& image_url,
25 const std::string& auth_token)
26 : delegate_(delegate) {
27 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
28 image_fetcher_.reset(new URLFetcher(GURL(image_url), URLFetcher::GET, this));
29 image_fetcher_->set_request_context(
30 ProfileManager::GetDefaultProfile()->GetRequestContext());
31 if (!auth_token.empty()) {
32 image_fetcher_->set_extra_request_headers(
33 StringPrintf(kAuthorizationHeader, auth_token.c_str()));
34 }
35 image_fetcher_->Start();
36 }
37
38 void ImageDownloader::OnURLFetchComplete(const URLFetcher* source,
39 const GURL& url,
40 const URLRequestStatus& status,
41 int response_code,
42 const ResponseCookies& cookies,
43 const std::string& data) {
44 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
45 if (response_code != 200) {
46 LOG(ERROR) << "Response code is " << response_code;
47 LOG(ERROR) << "Url is " << url.spec();
48 LOG(ERROR) << "Data is " << data;
49 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
50 return;
51 }
52
53 LOG(INFO) << "Decoding the image...";
54 std::vector<unsigned char> image_data(data.begin(), data.end());
55 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder(delegate_,
56 image_data);
57 image_decoder->Start();
58 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
59 }
60
61 } // namespace chromeos
62
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/image_downloader.h ('k') | chrome/browser/chromeos/login/login_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698