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 "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "chrome/browser/image_decoder.h" | 9 #include "chrome/browser/image_decoder.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
14 #include "components/search_engines/template_url_service.h" | 14 #include "components/search_engines/template_url_service.h" |
15 #include "components/search_provider_logos/google_logo_api.h" | 15 #include "components/search_provider_logos/google_logo_api.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
18 | 18 |
19 using content::BrowserThread; | 19 using content::BrowserThread; |
20 using search_provider_logos::AnimatedLogoTracker; | |
20 using search_provider_logos::Logo; | 21 using search_provider_logos::Logo; |
21 using search_provider_logos::LogoDelegate; | 22 using search_provider_logos::LogoDelegate; |
22 using search_provider_logos::LogoTracker; | 23 using search_provider_logos::LogoTracker; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
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. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 BrowserThread::GetBlockingPool(), | 119 BrowserThread::GetBlockingPool(), |
119 profile_->GetRequestContext(), | 120 profile_->GetRequestContext(), |
120 scoped_ptr<search_provider_logos::LogoDelegate>( | 121 scoped_ptr<search_provider_logos::LogoDelegate>( |
121 new ChromeLogoDelegate()))); | 122 new ChromeLogoDelegate()))); |
122 } | 123 } |
123 | 124 |
124 logo_tracker_->SetServerAPI( | 125 logo_tracker_->SetServerAPI( |
125 GetGoogleDoodleURL(profile_), | 126 GetGoogleDoodleURL(profile_), |
126 base::Bind(&search_provider_logos::GoogleParseLogoResponse), | 127 base::Bind(&search_provider_logos::GoogleParseLogoResponse), |
127 base::Bind(&search_provider_logos::GoogleAppendQueryparamsToLogoURL), | 128 base::Bind(&search_provider_logos::GoogleAppendQueryparamsToLogoURL), |
128 false); | 129 true); |
newt (away)
2015/09/18 20:46:03
as a later step, we can remove this parameter from
Ian Wen
2015/09/22 21:39:06
I added a todo to clean this up.
| |
129 logo_tracker_->GetLogo(observer); | 130 logo_tracker_->GetLogo(observer); |
130 } | 131 } |
131 | 132 |
133 void LogoService::GetAnimatedLogo( | |
134 const GURL& animated_logo_url, | |
135 const search_provider_logos::AnimatedLogoCallback& callback) { | |
136 | |
137 if (!animated_logo_tracker_) { | |
138 animated_logo_tracker_.reset( | |
139 new AnimatedLogoTracker(profile_->GetRequestContext())); | |
140 } | |
141 animated_logo_tracker_->GetAnimatedLogo(animated_logo_url, callback); | |
142 } | |
143 | |
132 // LogoServiceFactory --------------------------------------------------------- | 144 // LogoServiceFactory --------------------------------------------------------- |
133 | 145 |
134 // static | 146 // static |
135 LogoService* LogoServiceFactory::GetForProfile(Profile* profile) { | 147 LogoService* LogoServiceFactory::GetForProfile(Profile* profile) { |
136 return static_cast<LogoService*>( | 148 return static_cast<LogoService*>( |
137 GetInstance()->GetServiceForBrowserContext(profile, true)); | 149 GetInstance()->GetServiceForBrowserContext(profile, true)); |
138 } | 150 } |
139 | 151 |
140 // static | 152 // static |
141 LogoServiceFactory* LogoServiceFactory::GetInstance() { | 153 LogoServiceFactory* LogoServiceFactory::GetInstance() { |
142 return base::Singleton<LogoServiceFactory>::get(); | 154 return base::Singleton<LogoServiceFactory>::get(); |
143 } | 155 } |
144 | 156 |
145 LogoServiceFactory::LogoServiceFactory() | 157 LogoServiceFactory::LogoServiceFactory() |
146 : BrowserContextKeyedServiceFactory( | 158 : BrowserContextKeyedServiceFactory( |
147 "LogoService", | 159 "LogoService", |
148 BrowserContextDependencyManager::GetInstance()) { | 160 BrowserContextDependencyManager::GetInstance()) { |
149 } | 161 } |
150 | 162 |
151 LogoServiceFactory::~LogoServiceFactory() {} | 163 LogoServiceFactory::~LogoServiceFactory() {} |
152 | 164 |
153 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( | 165 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( |
154 content::BrowserContext* context) const { | 166 content::BrowserContext* context) const { |
155 Profile* profile = static_cast<Profile*>(context); | 167 Profile* profile = static_cast<Profile*>(context); |
156 DCHECK(!profile->IsOffTheRecord()); | 168 DCHECK(!profile->IsOffTheRecord()); |
157 return new LogoService(profile); | 169 return new LogoService(profile); |
158 } | 170 } |
OLD | NEW |