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

Side by Side Diff: ios/chrome/browser/google/google_logo_service.h

Issue 2434143003: [ios] Adds GoogleLogoService to help with fetching doodles. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_GOOGLE_GOOGLE_LOGO_SERVICE_H_
6 #define IOS_CHROME_BROWSER_GOOGLE_GOOGLE_LOGO_SERVICE_H_
7
8 #include <memory>
9
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "components/search_provider_logos/logo_tracker.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13
14 namespace ios {
15 class ChromeBrowserState;
16 }
17
18 // Provides the logo if a BrowserState's default search provider is Google.
19 //
20 // Example usage:
21 // GoogleLogoService* logo_service =
22 // GoogleLogoServiceFactory::GetForBrowserState(browser_state);
23 // logo_service->GetLogo(...);
24 //
25 class GoogleLogoService : public KeyedService {
26 public:
27 explicit GoogleLogoService(ios::ChromeBrowserState* browser_state);
28 ~GoogleLogoService() override;
29
30 // Gets the logo for the default search provider and notifies |observer|
31 // with the results.
32 void GetLogo(search_provider_logos::LogoObserver* observer);
33
34 // |LogoTracker| does everything on callbacks, and iOS needs to load the logo
35 // immediately on page load. This caches the SkBitmap so we can immediately
36 // load. This prevents showing the google logo on every new tab page and
37 // immediately animating to the logo. Only one SkBitmap is cached per
38 // BrowserState.
39 void SetCachedLogo(const search_provider_logos::Logo* logo);
40 search_provider_logos::Logo GetCachedLogo();
41
42 private:
43 ios::ChromeBrowserState* browser_state_;
44 std::unique_ptr<search_provider_logos::LogoTracker> logo_tracker_;
45 SkBitmap cached_image_;
46 search_provider_logos::LogoMetadata cached_metadata_;
47 const search_provider_logos::LogoMetadata empty_metadata;
48
49 DISALLOW_COPY_AND_ASSIGN(GoogleLogoService);
50 };
51
52 #endif // IOS_CHROME_BROWSER_GOOGLE_GOOGLE_LOGO_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698