| OLD | NEW |
| 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/image_decoder.h" | 8 #include "chrome/browser/image_decoder.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 const char kCachedLogoDirectory[] = "Search Logo"; | 25 const char kCachedLogoDirectory[] = "Search Logo"; |
| 26 const int kDecodeLogoTimeoutSeconds = 30; | 26 const int kDecodeLogoTimeoutSeconds = 30; |
| 27 | 27 |
| 28 // Returns the URL where the doodle can be downloaded, e.g. | 28 // Returns the URL where the doodle can be downloaded, e.g. |
| 29 // https://www.google.com/async/newtab_mobile. This depends on the user's | 29 // https://www.google.com/async/newtab_mobile. This depends on the user's |
| 30 // Google domain. | 30 // Google domain. |
| 31 GURL GetGoogleDoodleURL(Profile* profile) { | 31 GURL GetGoogleDoodleURL(Profile* profile) { |
| 32 GURL google_base_url(UIThreadSearchTermsData(profile).GoogleBaseURLValue()); | 32 GURL google_base_url(UIThreadSearchTermsData(profile).GoogleBaseURLValue()); |
| 33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; | 33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; |
| 34 // The string passed to SetPathStr() must stay alive until after | |
| 35 // ReplaceComponents(), so declare it on the stack here instead of inline. | |
| 36 std::string path(kGoogleDoodleURLPath); | |
| 37 GURL::Replacements replacements; | 34 GURL::Replacements replacements; |
| 38 replacements.SetPathStr(path); | 35 replacements.SetPathStr(kGoogleDoodleURLPath); |
| 39 return google_base_url.ReplaceComponents(replacements); | 36 return google_base_url.ReplaceComponents(replacements); |
| 40 } | 37 } |
| 41 | 38 |
| 42 class LogoDecoderDelegate : public ImageDecoder::Delegate { | 39 class LogoDecoderDelegate : public ImageDecoder::Delegate { |
| 43 public: | 40 public: |
| 44 LogoDecoderDelegate( | 41 LogoDecoderDelegate( |
| 45 const scoped_refptr<ImageDecoder>& image_decoder, | 42 const scoped_refptr<ImageDecoder>& image_decoder, |
| 46 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) | 43 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) |
| 47 : image_decoder_(image_decoder), | 44 : image_decoder_(image_decoder), |
| 48 image_decoded_callback_(image_decoded_callback), | 45 image_decoded_callback_(image_decoded_callback), |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 158 } |
| 162 | 159 |
| 163 LogoServiceFactory::~LogoServiceFactory() {} | 160 LogoServiceFactory::~LogoServiceFactory() {} |
| 164 | 161 |
| 165 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( | 162 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( |
| 166 content::BrowserContext* context) const { | 163 content::BrowserContext* context) const { |
| 167 Profile* profile = static_cast<Profile*>(context); | 164 Profile* profile = static_cast<Profile*>(context); |
| 168 DCHECK(!profile->IsOffTheRecord()); | 165 DCHECK(!profile->IsOffTheRecord()); |
| 169 return new LogoService(profile); | 166 return new LogoService(profile); |
| 170 } | 167 } |
| OLD | NEW |