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 22 matching lines...) Expand all Loading... |
33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; | 33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; |
34 GURL::Replacements replacements; | 34 GURL::Replacements replacements; |
35 replacements.SetPathStr(kGoogleDoodleURLPath); | 35 replacements.SetPathStr(kGoogleDoodleURLPath); |
36 return google_base_url.ReplaceComponents(replacements); | 36 return google_base_url.ReplaceComponents(replacements); |
37 } | 37 } |
38 | 38 |
39 class LogoDecoderDelegate : public ImageDecoder::ImageRequest { | 39 class LogoDecoderDelegate : public ImageDecoder::ImageRequest { |
40 public: | 40 public: |
41 LogoDecoderDelegate( | 41 LogoDecoderDelegate( |
42 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) | 42 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) |
43 : ImageRequest(base::MessageLoopProxy::current()), | 43 : image_decoded_callback_(image_decoded_callback), |
44 image_decoded_callback_(image_decoded_callback), | |
45 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
46 // If the ImageDecoder crashes or otherwise never completes, call | 45 // If the ImageDecoder crashes or otherwise never completes, call |
47 // OnImageDecodeTimedOut() eventually to ensure that image_decoded_callback_ | 46 // OnImageDecodeTimedOut() eventually to ensure that image_decoded_callback_ |
48 // is run. | 47 // is run. |
49 base::MessageLoopProxy::current()->PostDelayedTask( | 48 base::MessageLoopProxy::current()->PostDelayedTask( |
50 FROM_HERE, base::Bind(&LogoDecoderDelegate::OnDecodeImageFailed, | 49 FROM_HERE, base::Bind(&LogoDecoderDelegate::OnDecodeImageFailed, |
51 weak_ptr_factory_.GetWeakPtr()), | 50 weak_ptr_factory_.GetWeakPtr()), |
52 base::TimeDelta::FromSeconds(kDecodeLogoTimeoutSeconds)); | 51 base::TimeDelta::FromSeconds(kDecodeLogoTimeoutSeconds)); |
53 } | 52 } |
54 | 53 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 148 } |
150 | 149 |
151 LogoServiceFactory::~LogoServiceFactory() {} | 150 LogoServiceFactory::~LogoServiceFactory() {} |
152 | 151 |
153 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( | 152 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( |
154 content::BrowserContext* context) const { | 153 content::BrowserContext* context) const { |
155 Profile* profile = static_cast<Profile*>(context); | 154 Profile* profile = static_cast<Profile*>(context); |
156 DCHECK(!profile->IsOffTheRecord()); | 155 DCHECK(!profile->IsOffTheRecord()); |
157 return new LogoService(profile); | 156 return new LogoService(profile); |
158 } | 157 } |
OLD | NEW |