OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" | 13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" |
| 14 #include "chrome/common/web_application_info.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/common/manifest.h" | 17 #include "content/public/common/manifest.h" |
17 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 18 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
18 | 19 |
19 namespace chrome { | 20 namespace chrome { |
20 class BitmapFetcher; | 21 class BitmapFetcher; |
21 } // namespace chrome | 22 } // namespace chrome |
22 | 23 |
23 namespace infobars { | 24 namespace infobars { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 virtual std::string GetAppIdentifier(); | 109 virtual std::string GetAppIdentifier(); |
109 const content::Manifest& web_app_data() { return web_app_data_; } | 110 const content::Manifest& web_app_data() { return web_app_data_; } |
110 void set_app_title(const base::string16& title) { app_title_ = title; } | 111 void set_app_title(const base::string16& title) { app_title_ = title; } |
111 int event_request_id() { return event_request_id_; } | 112 int event_request_id() { return event_request_id_; } |
112 | 113 |
113 // Fetches the icon at the given URL asynchronously, returning |false| if a | 114 // Fetches the icon at the given URL asynchronously, returning |false| if a |
114 // load could not be started. | 115 // load could not be started. |
115 bool FetchIcon(const GURL& image_url); | 116 bool FetchIcon(const GURL& image_url); |
116 | 117 |
117 // Creates a banner for the app using the given |icon|. | 118 // Creates a banner for the app using the given |icon|. |
118 virtual infobars::InfoBar* CreateBanner(const SkBitmap* icon, | 119 virtual void ShowBanner(const SkBitmap* icon, const base::string16& title); |
119 const base::string16& title); | |
120 | 120 |
121 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR | 121 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR |
122 // metric being recorded. | 122 // metric being recorded. |
123 void RecordDidShowBanner(const std::string& event_name); | 123 void RecordDidShowBanner(const std::string& event_name); |
124 | 124 |
125 private: | 125 private: |
126 // Callbacks for data retrieval. | 126 // Callbacks for data retrieval. |
127 void OnDidGetManifest(const content::Manifest& manifest); | 127 void OnDidGetManifest(const content::Manifest& manifest); |
128 void OnDidCheckHasServiceWorker(bool has_service_worker); | 128 void OnDidCheckHasServiceWorker(bool has_service_worker); |
129 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override; | 129 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override; |
130 | 130 |
131 // Shows a banner for the app, if the given |icon| is valid. | 131 // Shows a banner for the app, if the given |icon| is valid. |
132 virtual void ShowBanner(const SkBitmap* icon); | 132 virtual void RequestShowBanner(const SkBitmap* icon); |
133 | 133 |
134 // Record that the banner could be shown at this point, if the triggering | 134 // Record that the banner could be shown at this point, if the triggering |
135 // heuristic allowed. | 135 // heuristic allowed. |
136 void RecordCouldShowBanner(); | 136 void RecordCouldShowBanner(); |
137 | 137 |
138 // Returns whether the banner should be shown. | 138 // Returns whether the banner should be shown. |
139 bool CheckIfShouldShowBanner(); | 139 bool CheckIfShouldShowBanner(); |
140 | 140 |
141 // Returns whether the fetcher is active and web contents have not been | 141 // Returns whether the fetcher is active and web contents have not been |
142 // closed. | 142 // closed. |
(...skipping 17 matching lines...) Expand all Loading... |
160 content::Manifest web_app_data_; | 160 content::Manifest web_app_data_; |
161 | 161 |
162 friend class AppBannerDataFetcherUnitTest; | 162 friend class AppBannerDataFetcherUnitTest; |
163 friend class base::RefCounted<AppBannerDataFetcher>; | 163 friend class base::RefCounted<AppBannerDataFetcher>; |
164 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); | 164 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace banners | 167 } // namespace banners |
168 | 168 |
169 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 169 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
OLD | NEW |