13f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_IMAGE_DOWNLOADER_H_ 6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define CHROME_BROWSER_CHROMEOS_LOGIN_IMAGE_DOWNLOADER_H_ 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string> 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/basictypes.h" 12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h" 13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/chromeos/login/image_decoder.h" 14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/common/net/url_fetcher.h" 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "googleurl/src/gurl.h" 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace chromeos { 18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Downloads the image, decodes it in a sandboxed process. 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// This objects deletes itself after OnURLFetchComplete. 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass ImageDownloader : public URLFetcher::Delegate { 22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public: 23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Starts downloading the picture. Optional auth_token could be passed. 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Object is deleted as reference counted object. 25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ImageDownloader(ImageDecoder::Delegate* delegate, 26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const GURL& image_url, 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const std::string& auth_token); 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch virtual ~ImageDownloader() {} 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private: 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Overriden from URLFetcher::Delegate: 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch virtual void OnURLFetchComplete(const URLFetcher* source, 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const GURL& url, 343f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen const net::URLRequestStatus& status, 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch int response_code, 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const ResponseCookies& cookies, 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const std::string& data); 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ImageDecoder::Delegate* delegate_; 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_ptr<URLFetcher> image_fetcher_; 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch DISALLOW_COPY_AND_ASSIGN(ImageDownloader); 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} // namespace chromeos 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif // CHROME_BROWSER_CHROMEOS_LOGIN_IMAGE_DOWNLOADER_H_ 48