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 |
24 namespace extensions { | |
25 class BookmarkAppHelper; | |
26 class Extension; | |
27 } // namespace extensions | |
benwells
2015/06/02 05:53:35
The generic fetcher class is now polluted with des
dominickn (DO NOT USE)
2015/06/02 06:51:32
This also means either adding an AppBannerManagerD
| |
28 | |
23 namespace infobars { | 29 namespace infobars { |
24 class InfoBar; | 30 class InfoBar; |
25 } // namespace infobars | 31 } // namespace infobars |
26 | 32 |
27 namespace banners { | 33 namespace banners { |
28 class AppBannerDataFetcher; | 34 class AppBannerDataFetcher; |
29 | 35 |
30 // Fetches data required to show a web app banner for the URL currently shown by | 36 // Fetches data required to show a web app banner for the URL currently shown by |
31 // the WebContents. | 37 // the WebContents. |
32 class AppBannerDataFetcher | 38 class AppBannerDataFetcher |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 const GURL& validated_url() { return validated_url_; } | 89 const GURL& validated_url() { return validated_url_; } |
84 | 90 |
85 // WebContentsObserver overrides. | 91 // WebContentsObserver overrides. |
86 void WebContentsDestroyed() override; | 92 void WebContentsDestroyed() override; |
87 void DidNavigateMainFrame( | 93 void DidNavigateMainFrame( |
88 const content::LoadCommittedDetails& details, | 94 const content::LoadCommittedDetails& details, |
89 const content::FrameNavigateParams& params) override; | 95 const content::FrameNavigateParams& params) override; |
90 bool OnMessageReceived(const IPC::Message& message, | 96 bool OnMessageReceived(const IPC::Message& message, |
91 content::RenderFrameHost* render_frame_host) override; | 97 content::RenderFrameHost* render_frame_host) override; |
92 | 98 |
99 // Callback for finishing bookmark app creation | |
100 void FinishCreateBookmarkApp(const extensions::Extension* extension, | |
101 const WebApplicationInfo& web_app_info); | |
102 | |
93 protected: | 103 protected: |
94 ~AppBannerDataFetcher() override; | 104 ~AppBannerDataFetcher() override; |
95 | 105 |
96 // Return a string describing what type of banner is being created. Used when | 106 // Return a string describing what type of banner is being created. Used when |
97 // alerting websites that a banner is about to be created. | 107 // alerting websites that a banner is about to be created. |
98 virtual std::string GetBannerType(); | 108 virtual std::string GetBannerType(); |
99 | 109 |
100 // Called after the manager sends a message to the renderer regarding its | 110 // Called after the manager sends a message to the renderer regarding its |
101 // intention to show a prompt. The renderer will send a message back with the | 111 // intention to show a prompt. The renderer will send a message back with the |
102 // opportunity to cancel. | 112 // opportunity to cancel. |
(...skipping 12 matching lines...) Expand all Loading... | |
115 bool FetchIcon(const GURL& image_url); | 125 bool FetchIcon(const GURL& image_url); |
116 | 126 |
117 // Creates a banner for the app using the given |icon|. | 127 // Creates a banner for the app using the given |icon|. |
118 virtual infobars::InfoBar* CreateBanner(const SkBitmap* icon, | 128 virtual infobars::InfoBar* CreateBanner(const SkBitmap* icon, |
119 const base::string16& title); | 129 const base::string16& title); |
120 | 130 |
121 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR | 131 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR |
122 // metric being recorded. | 132 // metric being recorded. |
123 void RecordDidShowBanner(const std::string& event_name); | 133 void RecordDidShowBanner(const std::string& event_name); |
124 | 134 |
135 #if !defined(OS_ANDROID) | |
136 scoped_ptr<extensions::BookmarkAppHelper> bookmark_app_helper_; | |
137 #endif | |
138 | |
125 private: | 139 private: |
126 // Callbacks for data retrieval. | 140 // Callbacks for data retrieval. |
127 void OnDidGetManifest(const content::Manifest& manifest); | 141 void OnDidGetManifest(const content::Manifest& manifest); |
128 void OnDidCheckHasServiceWorker(bool has_service_worker); | 142 void OnDidCheckHasServiceWorker(bool has_service_worker); |
129 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override; | 143 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override; |
130 | 144 |
131 // Shows a banner for the app, if the given |icon| is valid. | 145 // Shows a banner for the app, if the given |icon| is valid. |
132 virtual void ShowBanner(const SkBitmap* icon); | 146 virtual void ShowBanner(const SkBitmap* icon); |
133 | 147 |
134 // Record that the banner could be shown at this point, if the triggering | 148 // Record that the banner could be shown at this point, if the triggering |
(...skipping 25 matching lines...) Expand all Loading... | |
160 content::Manifest web_app_data_; | 174 content::Manifest web_app_data_; |
161 | 175 |
162 friend class AppBannerDataFetcherUnitTest; | 176 friend class AppBannerDataFetcherUnitTest; |
163 friend class base::RefCounted<AppBannerDataFetcher>; | 177 friend class base::RefCounted<AppBannerDataFetcher>; |
164 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); | 178 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); |
165 }; | 179 }; |
166 | 180 |
167 } // namespace banners | 181 } // namespace banners |
168 | 182 |
169 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ | 183 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ |
OLD | NEW |