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" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 blink::WebAppBannerPromptReply reply, | 114 blink::WebAppBannerPromptReply reply, |
115 std::string referrer); | 115 std::string referrer); |
116 | 116 |
117 // Called when the client has prevented a banner from being shown, and is | 117 // Called when the client has prevented a banner from being shown, and is |
118 // now requesting that it be shown later. | 118 // now requesting that it be shown later. |
119 void OnRequestShowAppBanner(content::RenderFrameHost* render_frame_host, | 119 void OnRequestShowAppBanner(content::RenderFrameHost* render_frame_host, |
120 int request_id); | 120 int request_id); |
121 | 121 |
122 // Called when it is determined that the webapp has fulfilled the initial | 122 // Called when it is determined that the webapp has fulfilled the initial |
123 // criteria of having a manifest and a service worker. | 123 // criteria of having a manifest and a service worker. |
124 void OnHasServiceWorker(content::WebContents* web_contents); | 124 virtual void OnHasServiceWorker(content::WebContents* web_contents); |
Lalit Maganti
2015/08/26 13:11:56
Reverted this change as it is not necessary and al
| |
125 | 125 |
126 content::WebContents* GetWebContents(); | 126 content::WebContents* GetWebContents(); |
127 virtual std::string GetAppIdentifier(); | 127 virtual std::string GetAppIdentifier(); |
128 const content::Manifest& web_app_data() { return web_app_data_; } | 128 const content::Manifest& web_app_data() { return web_app_data_; } |
129 void set_app_title(const base::string16& title) { app_title_ = title; } | 129 void set_app_title(const base::string16& title) { app_title_ = title; } |
130 int event_request_id() { return event_request_id_; } | 130 int event_request_id() { return event_request_id_; } |
131 | 131 |
132 // Fetches the icon at the given URL asynchronously, returning |false| if a | 132 // Fetches the icon at the given URL asynchronously, returning |false| if a |
133 // load could not be started. | 133 // load could not be started. |
134 bool FetchAppIcon(content::WebContents* web_contents, const GURL& url); | 134 bool FetchAppIcon(content::WebContents* web_contents, const GURL& url); |
135 | 135 |
136 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR | 136 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR |
137 // metric being recorded. | 137 // metric being recorded. |
138 void RecordDidShowBanner(const std::string& event_name); | 138 void RecordDidShowBanner(const std::string& event_name); |
139 | 139 |
140 // Returns whether the fetcher is active and web contents have not been | |
141 // closed. | |
142 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); | |
Lalit Maganti
2015/08/26 13:11:56
Reverted as no longer necessary.
| |
143 | |
140 private: | 144 private: |
141 // Callbacks for data retrieval. | 145 // Callbacks for data retrieval. |
142 void OnDidGetManifest(const content::Manifest& manifest); | 146 void OnDidGetManifest(const content::Manifest& manifest); |
143 void OnDidCheckHasServiceWorker(bool has_service_worker); | 147 void OnDidCheckHasServiceWorker(bool has_service_worker); |
144 void OnAppIconFetched(const SkBitmap& bitmap); | 148 void OnAppIconFetched(const SkBitmap& bitmap); |
145 | 149 |
146 // Returns whether the given web app has already been installed. | 150 // Returns whether the given web app has already been installed. |
147 // Implemented on desktop platforms only. | 151 // Implemented on desktop platforms only. |
148 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, | 152 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, |
149 const GURL& start_url); | 153 const GURL& start_url); |
150 | 154 |
151 // Record that the banner could be shown at this point, if the triggering | 155 // Record that the banner could be shown at this point, if the triggering |
152 // heuristic allowed. | 156 // heuristic allowed. |
153 void RecordCouldShowBanner(); | 157 void RecordCouldShowBanner(); |
154 | 158 |
155 // Creates a banner for the app using the given |icon|. | 159 // Creates a banner for the app using the given |icon|. |
156 virtual void ShowBanner(const SkBitmap* icon, | 160 virtual void ShowBanner(const SkBitmap* icon, |
157 const base::string16& title, | 161 const base::string16& title, |
158 const std::string& referrer) = 0; | 162 const std::string& referrer) = 0; |
159 | 163 |
160 // Returns whether the banner should be shown. | 164 // Returns whether the banner should be shown. |
161 bool CheckIfShouldShowBanner(); | 165 bool CheckIfShouldShowBanner(); |
162 | 166 |
163 // Returns whether the fetcher is active and web contents have not been | |
164 // closed. | |
165 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); | |
166 | |
167 // Returns whether the given Manifest is following the requirements to show | 167 // Returns whether the given Manifest is following the requirements to show |
168 // a web app banner. | 168 // a web app banner. |
169 static bool IsManifestValidForWebApp(const content::Manifest& manifest, | 169 static bool IsManifestValidForWebApp(const content::Manifest& manifest, |
170 content::WebContents* web_contents); | 170 content::WebContents* web_contents); |
171 | 171 |
172 const int ideal_icon_size_; | 172 const int ideal_icon_size_; |
173 const base::WeakPtr<Delegate> weak_delegate_; | 173 const base::WeakPtr<Delegate> weak_delegate_; |
174 base::ObserverList<Observer> observer_list_; | 174 base::ObserverList<Observer> observer_list_; |
175 bool is_active_; | 175 bool is_active_; |
176 bool was_canceled_by_page_; | 176 bool was_canceled_by_page_; |
177 bool page_requested_prompt_; | 177 bool page_requested_prompt_; |
178 ui::PageTransition transition_type_; | 178 ui::PageTransition transition_type_; |
179 int event_request_id_; | 179 int event_request_id_; |
180 scoped_ptr<SkBitmap> app_icon_; | 180 scoped_ptr<SkBitmap> app_icon_; |
181 std::string referrer_; | 181 std::string referrer_; |
182 | 182 |
183 GURL validated_url_; | 183 GURL validated_url_; |
184 base::string16 app_title_; | 184 base::string16 app_title_; |
185 content::Manifest web_app_data_; | 185 content::Manifest web_app_data_; |
186 | 186 |
187 friend class AppBannerDataFetcherUnitTest; | 187 friend class AppBannerDataFetcherUnitTest; |
188 friend class base::RefCounted<AppBannerDataFetcher>; | 188 friend class base::RefCounted<AppBannerDataFetcher>; |
189 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); | 189 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); |
190 }; | 190 }; |
191 | 191 |
192 } // namespace banners | 192 } // namespace banners |
193 | 193 |
194 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 194 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
OLD | NEW |