| 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 #ifndef CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ | 6 #define CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 9 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
| 11 #include "components/search_provider_logos/animated_logo_tracker.h" |
| 11 #include "components/search_provider_logos/logo_tracker.h" | 12 #include "components/search_provider_logos/logo_tracker.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 | 14 |
| 14 class Profile; | 15 class Profile; |
| 15 | 16 |
| 16 // Provides the logo for a profile's default search provider. | 17 // Provides the logo for a profile's default search provider. |
| 17 // | 18 // |
| 18 // Example usage: | 19 // Example usage: |
| 19 // LogoService* logo_service = LogoServiceFactory::GetForProfile(profile); | 20 // LogoService* logo_service = LogoServiceFactory::GetForProfile(profile); |
| 20 // logo_service->GetLogo(...); | 21 // logo_service->GetLogo(...); |
| 21 // | 22 // |
| 22 class LogoService : public KeyedService { | 23 class LogoService : public KeyedService { |
| 23 public: | 24 public: |
| 24 explicit LogoService(Profile* profile); | 25 explicit LogoService(Profile* profile); |
| 25 ~LogoService() override; | 26 ~LogoService() override; |
| 26 | 27 |
| 27 // Gets the logo for the default search provider and notifies |observer| | 28 // Gets the logo for the default search provider and notifies |observer| |
| 28 // with the results. | 29 // with the results. |
| 29 void GetLogo(search_provider_logos::LogoObserver* observer); | 30 void GetLogo(search_provider_logos::LogoObserver* observer); |
| 30 | 31 |
| 32 // Gets the animated logo for the default search provider. If downloaded |
| 33 // successfully, the given callback will be called. |
| 34 void GetAnimatedLogo( |
| 35 const GURL& animated_logo_url, |
| 36 const search_provider_logos::AnimatedLogoCallback& callback); |
| 37 |
| 31 private: | 38 private: |
| 32 Profile* profile_; | 39 Profile* profile_; |
| 33 scoped_ptr<search_provider_logos::LogoTracker> logo_tracker_; | 40 scoped_ptr<search_provider_logos::LogoTracker> logo_tracker_; |
| 41 scoped_ptr<search_provider_logos::AnimatedLogoTracker> animated_logo_tracker_; |
| 34 | 42 |
| 35 DISALLOW_COPY_AND_ASSIGN(LogoService); | 43 DISALLOW_COPY_AND_ASSIGN(LogoService); |
| 36 }; | 44 }; |
| 37 | 45 |
| 38 // Singleton that owns all LogoServices and associates them with Profiles. | 46 // Singleton that owns all LogoServices and associates them with Profiles. |
| 39 class LogoServiceFactory : public BrowserContextKeyedServiceFactory { | 47 class LogoServiceFactory : public BrowserContextKeyedServiceFactory { |
| 40 public: | 48 public: |
| 41 static LogoService* GetForProfile(Profile* profile); | 49 static LogoService* GetForProfile(Profile* profile); |
| 42 | 50 |
| 43 static LogoServiceFactory* GetInstance(); | 51 static LogoServiceFactory* GetInstance(); |
| 44 | 52 |
| 45 private: | 53 private: |
| 46 friend struct base::DefaultSingletonTraits<LogoServiceFactory>; | 54 friend struct base::DefaultSingletonTraits<LogoServiceFactory>; |
| 47 | 55 |
| 48 LogoServiceFactory(); | 56 LogoServiceFactory(); |
| 49 ~LogoServiceFactory() override; | 57 ~LogoServiceFactory() override; |
| 50 | 58 |
| 51 // BrowserContextKeyedServiceFactory: | 59 // BrowserContextKeyedServiceFactory: |
| 52 KeyedService* BuildServiceInstanceFor( | 60 KeyedService* BuildServiceInstanceFor( |
| 53 content::BrowserContext* context) const override; | 61 content::BrowserContext* context) const override; |
| 54 }; | 62 }; |
| 55 | 63 |
| 56 #endif // CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ | 64 #endif // CHROME_BROWSER_ANDROID_LOGO_SERVICE_H_ |
| OLD | NEW |