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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher.h

Issue 1161233005: Implement app banner info bars on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stop-icon-overgeneration
Patch Set: Moving feature enabling to existing #ifs Created 5 years, 6 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
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
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,
119 const base::string16& title); 120 const base::string16& title) = 0;
120 121
121 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR 122 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR
122 // metric being recorded. 123 // metric being recorded.
123 void RecordDidShowBanner(const std::string& event_name); 124 void RecordDidShowBanner(const std::string& event_name);
124 125
125 private: 126 private:
126 // Callbacks for data retrieval. 127 // Callbacks for data retrieval.
127 void OnDidGetManifest(const content::Manifest& manifest); 128 void OnDidGetManifest(const content::Manifest& manifest);
128 void OnDidCheckHasServiceWorker(bool has_service_worker); 129 void OnDidCheckHasServiceWorker(bool has_service_worker);
129 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override; 130 void OnFetchComplete(const GURL& url, const SkBitmap* icon) override;
130 131
131 // Shows a banner for the app, if the given |icon| is valid. 132 // Shows a banner for the app, if the given |icon| is valid.
132 virtual void ShowBanner(const SkBitmap* icon); 133 virtual void RequestShowBanner(const SkBitmap* icon);
133 134
134 // Record that the banner could be shown at this point, if the triggering 135 // Record that the banner could be shown at this point, if the triggering
135 // heuristic allowed. 136 // heuristic allowed.
136 void RecordCouldShowBanner(); 137 void RecordCouldShowBanner();
137 138
138 // Returns whether the banner should be shown. 139 // Returns whether the banner should be shown.
139 bool CheckIfShouldShowBanner(); 140 bool CheckIfShouldShowBanner();
140 141
141 // Returns whether the fetcher is active and web contents have not been 142 // Returns whether the fetcher is active and web contents have not been
142 // closed. 143 // closed.
(...skipping 17 matching lines...) Expand all
160 content::Manifest web_app_data_; 161 content::Manifest web_app_data_;
161 162
162 friend class AppBannerDataFetcherUnitTest; 163 friend class AppBannerDataFetcherUnitTest;
163 friend class base::RefCounted<AppBannerDataFetcher>; 164 friend class base::RefCounted<AppBannerDataFetcher>;
164 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); 165 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher);
165 }; 166 };
166 167
167 } // namespace banners 168 } // namespace banners
168 169
169 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ 170 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698