diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 03:05:55 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 03:05:55 +0000 |
commit | 808c096eeadb6b7d701a76fb660fd18c4b1a9497 (patch) | |
tree | 7d80a2097013588ab0e68d03c73f852ba4dacdb3 /content/test | |
parent | 75185918cc565c908ce16346644d3008bb0ff91f (diff) | |
download | chromium_src-808c096eeadb6b7d701a76fb660fd18c4b1a9497.zip chromium_src-808c096eeadb6b7d701a76fb660fd18c4b1a9497.tar.gz chromium_src-808c096eeadb6b7d701a76fb660fd18c4b1a9497.tar.bz2 |
Add support to download web store promo logos over https.
This lets you define apps promo logos as https URLs in the promo feed. The AppsPromoLogoDownloader only downloads the image over https and from *.google.com domains. AppsPromo caches the image until the URL changes in the promo feed.
BUG=84506
TEST=*Promo*
Review URL: http://codereview.chromium.org/7820003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test')
-rw-r--r-- | content/test/test_url_fetcher_factory.cc | 42 | ||||
-rw-r--r-- | content/test/test_url_fetcher_factory.h | 2 |
2 files changed, 36 insertions, 8 deletions
diff --git a/content/test/test_url_fetcher_factory.cc b/content/test/test_url_fetcher_factory.cc index d95fbf2..5062b46 100644 --- a/content/test/test_url_fetcher_factory.cc +++ b/content/test/test_url_fetcher_factory.cc @@ -125,17 +125,47 @@ class FakeURLFetcher : public URLFetcher { url_(url), response_data_(response_data), success_(success), + status_(success ? net::URLRequestStatus::SUCCESS : + net::URLRequestStatus::FAILED, 0), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } // Start the request. This will call the given delegate asynchronously // with the pre-baked response as parameter. - virtual void Start() { + virtual void Start() OVERRIDE { MessageLoop::current()->PostTask( FROM_HERE, method_factory_.NewRunnableMethod(&FakeURLFetcher::RunDelegate)); } + // These methods are overriden so we can use the version of + // OnURLFetchComplete that only has a single URLFetcher argument. + virtual const net::ResponseCookies& cookies() const OVERRIDE { + return cookies_; + } + + virtual const std::string& GetResponseStringRef() const OVERRIDE { + return response_data_; + } + + virtual bool GetResponseAsString( + std::string* out_response_string) const OVERRIDE { + *out_response_string = response_data_; + return true; + } + + virtual int response_code() const OVERRIDE { + return success_ ? 200 : 500; + } + + virtual const net::URLRequestStatus& status() const OVERRIDE { + return status_; + } + + virtual const GURL& url() const OVERRIDE { + return url_; + } + private: virtual ~FakeURLFetcher() { } @@ -143,11 +173,7 @@ class FakeURLFetcher : public URLFetcher { // This is the method which actually calls the delegate that is passed in the // constructor. void RunDelegate() { - net::URLRequestStatus status; - status.set_status(success_ ? net::URLRequestStatus::SUCCESS : - net::URLRequestStatus::FAILED); - delegate()->OnURLFetchComplete(this, url_, status, success_ ? 200 : 500, - net::ResponseCookies(), response_data_); + delegate()->OnURLFetchComplete(this); } // Pre-baked response data and flag which indicates whether the request should @@ -155,6 +181,8 @@ class FakeURLFetcher : public URLFetcher { GURL url_; std::string response_data_; bool success_; + net::URLRequestStatus status_; + net::ResponseCookies cookies_; // Method factory used to run the delegate. ScopedRunnableMethodFactory<FakeURLFetcher> method_factory_; @@ -200,7 +228,7 @@ void FakeURLFetcherFactory::SetFakeResponse(const std::string& url, fake_responses_[GURL(url)] = std::make_pair(response_data, success); } -void FakeURLFetcherFactory::ClearFakeReponses() { +void FakeURLFetcherFactory::ClearFakeResponses() { fake_responses_.clear(); } diff --git a/content/test/test_url_fetcher_factory.h b/content/test/test_url_fetcher_factory.h index 8b60fd7..a286bad 100644 --- a/content/test/test_url_fetcher_factory.h +++ b/content/test/test_url_fetcher_factory.h @@ -210,7 +210,7 @@ class FakeURLFetcherFactory : public URLFetcher::Factory, // Clear all the fake responses that were previously set via // SetFakeResponse(). - void ClearFakeReponses(); + void ClearFakeResponses(); private: typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap; |