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

Side by Side Diff: chrome/browser/android/logo_service.cc

Issue 264713013: Allow overriding Google doodle URL on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/android/logo_service.h" 5 #include "chrome/browser/android/logo_service.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "chrome/browser/google/google_url_tracker.h" 8 #include "chrome/browser/google/google_url_tracker.h"
9 #include "chrome/browser/google/google_util.h"
9 #include "chrome/browser/image_decoder.h" 10 #include "chrome/browser/image_decoder.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search_engines/template_url_service.h" 12 #include "chrome/browser/search_engines/template_url_service.h"
12 #include "chrome/browser/search_engines/template_url_service_factory.h" 13 #include "chrome/browser/search_engines/template_url_service_factory.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" 14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/search_provider_logos/google_logo_api.h" 15 #include "components/search_provider_logos/google_logo_api.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 using search_provider_logos::Logo; 20 using search_provider_logos::Logo;
20 using search_provider_logos::LogoDelegate; 21 using search_provider_logos::LogoDelegate;
21 using search_provider_logos::LogoTracker; 22 using search_provider_logos::LogoTracker;
22 23
23 namespace { 24 namespace {
24 25
25 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; 26 const char kGoogleDoodleURLPath[] = "async/newtab_mobile";
26 const char kCachedLogoDirectory[] = "Search Logo"; 27 const char kCachedLogoDirectory[] = "Search Logo";
27 const int kDecodeLogoTimeoutSeconds = 30; 28 const int kDecodeLogoTimeoutSeconds = 30;
28 29
29 // Returns the URL where the doodle can be downloaded, e.g. 30 // Returns the URL where the doodle can be downloaded, e.g.
30 // https://www.google.com/async/newtab_mobile. This depends on the user's 31 // https://www.google.com/async/newtab_mobile. This depends on the user's
31 // Google domain. 32 // Google domain.
32 GURL GetGoogleDoodleURL(Profile* profile) { 33 GURL GetGoogleDoodleURL(Profile* profile) {
33 // SetPathStr() requires its argument to stay in scope as long as 34 // SetPathStr() requires its argument to stay in scope as long as
34 // |replacements| is, so a std::string is needed, instead of a char*. 35 // |replacements| is, so a std::string is needed, instead of a char*.
35 std::string path = kGoogleDoodleURLPath; 36 std::string path = kGoogleDoodleURLPath;
36 GURL::Replacements replacements; 37 GURL::Replacements replacements;
37 replacements.SetPathStr(path); 38 replacements.SetPathStr(path);
38 return GoogleURLTracker::GoogleURL(profile).ReplaceComponents(replacements); 39
40 GURL base_url(google_util::CommandLineGoogleBaseURL());
41 if (!base_url.is_valid())
42 base_url = GoogleURLTracker::GoogleURL(profile);
43 return base_url.ReplaceComponents(replacements);
39 } 44 }
40 45
41 class LogoDecoderDelegate : public ImageDecoder::Delegate { 46 class LogoDecoderDelegate : public ImageDecoder::Delegate {
42 public: 47 public:
43 LogoDecoderDelegate( 48 LogoDecoderDelegate(
44 const scoped_refptr<ImageDecoder>& image_decoder, 49 const scoped_refptr<ImageDecoder>& image_decoder,
45 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) 50 const base::Callback<void(const SkBitmap&)>& image_decoded_callback)
46 : image_decoder_(image_decoder), 51 : image_decoder_(image_decoder),
47 image_decoded_callback_(image_decoded_callback), 52 image_decoded_callback_(image_decoded_callback),
48 weak_ptr_factory_(this) { 53 weak_ptr_factory_(this) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 166 }
162 167
163 LogoServiceFactory::~LogoServiceFactory() {} 168 LogoServiceFactory::~LogoServiceFactory() {}
164 169
165 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( 170 KeyedService* LogoServiceFactory::BuildServiceInstanceFor(
166 content::BrowserContext* context) const { 171 content::BrowserContext* context) const {
167 Profile* profile = static_cast<Profile*>(context); 172 Profile* profile = static_cast<Profile*>(context);
168 DCHECK(!profile->IsOffTheRecord()); 173 DCHECK(!profile->IsOffTheRecord());
169 return new LogoService(profile); 174 return new LogoService(profile);
170 } 175 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698