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

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

Issue 1569893003: Add "Request app banner" context menu in DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated pfeldman's comment Created 4 years, 11 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/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 bool will_show) = 0; 42 bool will_show) = 0;
43 virtual void OnFetcherDestroyed(AppBannerDataFetcher* fetcher) = 0; 43 virtual void OnFetcherDestroyed(AppBannerDataFetcher* fetcher) = 0;
44 }; 44 };
45 45
46 class Delegate { 46 class Delegate {
47 public: 47 public:
48 // Called to handle a non-web app. Returns |true| if the non-web app can be 48 // Called to handle a non-web app. Returns |true| if the non-web app can be
49 // handled, and the fetcher needs to remain active and wait for a callback. 49 // handled, and the fetcher needs to remain active and wait for a callback.
50 virtual bool HandleNonWebApp(const std::string& platform, 50 virtual bool HandleNonWebApp(const std::string& platform,
51 const GURL& url, 51 const GURL& url,
52 const std::string& id) = 0; 52 const std::string& id,
53 bool is_debug_mode) = 0;
53 }; 54 };
54 55
55 // Returns the current time. 56 // Returns the current time.
56 static base::Time GetCurrentTime(); 57 static base::Time GetCurrentTime();
57 58
58 // Fast-forwards the current time for testing. 59 // Fast-forwards the current time for testing.
59 static void SetTimeDeltaForTesting(int days); 60 static void SetTimeDeltaForTesting(int days);
60 61
61 AppBannerDataFetcher(content::WebContents* web_contents, 62 AppBannerDataFetcher(content::WebContents* web_contents,
62 base::WeakPtr<Delegate> weak_delegate, 63 base::WeakPtr<Delegate> weak_delegate,
63 int ideal_icon_size_in_dp, 64 int ideal_icon_size_in_dp,
64 int minimum_icon_size_in_dp); 65 int minimum_icon_size_in_dp,
66 bool is_debug_mode);
65 67
66 // Begins creating a banner for the URL being displayed by the Delegate's 68 // Begins creating a banner for the URL being displayed by the Delegate's
67 // WebContents. 69 // WebContents.
68 void Start(const GURL& validated_url, ui::PageTransition transition_type); 70 void Start(const GURL& validated_url, ui::PageTransition transition_type);
69 71
70 // Stops the pipeline when any asynchronous calls return. 72 // Stops the pipeline when any asynchronous calls return.
71 void Cancel(); 73 void Cancel();
72 74
73 // Replaces the WebContents that is being observed. 75 // Replaces the WebContents that is being observed.
74 void ReplaceWebContents(content::WebContents* web_contents); 76 void ReplaceWebContents(content::WebContents* web_contents);
75 77
76 // Adds an observer to the list. 78 // Adds an observer to the list.
77 void AddObserverForTesting(Observer* observer); 79 void AddObserverForTesting(Observer* observer);
78 80
79 // Removes an observer from the list. 81 // Removes an observer from the list.
80 void RemoveObserverForTesting(Observer* observer); 82 void RemoveObserverForTesting(Observer* observer);
81 83
82 // Returns whether or not the pipeline has been stopped. 84 // Returns whether or not the pipeline has been stopped.
83 bool is_active() { return is_active_; } 85 bool is_active() { return is_active_; }
84 86
85 // Returns whether the beforeinstallprompt Javascript event was canceled. 87 // Returns whether the beforeinstallprompt Javascript event was canceled.
86 bool was_canceled_by_page() { return was_canceled_by_page_; } 88 bool was_canceled_by_page() { return was_canceled_by_page_; }
87 89
88 // Returns whether the page has validly requested that the banner be shown 90 // Returns whether the page has validly requested that the banner be shown
89 // by calling prompt() on the beforeinstallprompt Javascript event. 91 // by calling prompt() on the beforeinstallprompt Javascript event.
90 bool page_requested_prompt() { return page_requested_prompt_; } 92 bool page_requested_prompt() { return page_requested_prompt_; }
91 93
94 // Returns true when it was created by the user action in DevTools or
95 // "bypass-app-banner-engagement-checks" flag is set.
96 bool is_debug_mode() const { return is_debug_mode_; }
97
92 // Returns the type of transition which triggered this fetch. 98 // Returns the type of transition which triggered this fetch.
93 ui::PageTransition transition_type() { return transition_type_; } 99 ui::PageTransition transition_type() { return transition_type_; }
94 100
95 // Returns the URL that kicked off the banner data retrieval. 101 // Returns the URL that kicked off the banner data retrieval.
96 const GURL& validated_url() { return validated_url_; } 102 const GURL& validated_url() { return validated_url_; }
97 103
98 // WebContentsObserver overrides. 104 // WebContentsObserver overrides.
99 void WebContentsDestroyed() override; 105 void WebContentsDestroyed() override;
100 void DidNavigateMainFrame( 106 void DidNavigateMainFrame(
101 const content::LoadCommittedDetails& details, 107 const content::LoadCommittedDetails& details,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Returns whether the banner should be shown. 171 // Returns whether the banner should be shown.
166 bool CheckIfShouldShowBanner(); 172 bool CheckIfShouldShowBanner();
167 173
168 // Returns whether the fetcher is active and web contents have not been 174 // Returns whether the fetcher is active and web contents have not been
169 // closed. 175 // closed.
170 bool CheckFetcherIsStillAlive(content::WebContents* web_contents); 176 bool CheckFetcherIsStillAlive(content::WebContents* web_contents);
171 177
172 // Returns whether the given Manifest is following the requirements to show 178 // Returns whether the given Manifest is following the requirements to show
173 // a web app banner. 179 // a web app banner.
174 static bool IsManifestValidForWebApp(const content::Manifest& manifest, 180 static bool IsManifestValidForWebApp(const content::Manifest& manifest,
175 content::WebContents* web_contents); 181 content::WebContents* web_contents,
182 bool is_debug_mode);
176 183
177 const base::WeakPtr<Delegate> weak_delegate_; 184 const base::WeakPtr<Delegate> weak_delegate_;
178 const int ideal_icon_size_in_dp_; 185 const int ideal_icon_size_in_dp_;
179 const int minimum_icon_size_in_dp_; 186 const int minimum_icon_size_in_dp_;
180 base::ObserverList<Observer> observer_list_; 187 base::ObserverList<Observer> observer_list_;
181 bool is_active_; 188 bool is_active_;
182 bool was_canceled_by_page_; 189 bool was_canceled_by_page_;
183 bool page_requested_prompt_; 190 bool page_requested_prompt_;
191 const bool is_debug_mode_;
184 ui::PageTransition transition_type_; 192 ui::PageTransition transition_type_;
185 int event_request_id_; 193 int event_request_id_;
186 scoped_ptr<SkBitmap> app_icon_; 194 scoped_ptr<SkBitmap> app_icon_;
187 std::string referrer_; 195 std::string referrer_;
188 196
189 GURL validated_url_; 197 GURL validated_url_;
190 base::string16 app_title_; 198 base::string16 app_title_;
191 content::Manifest web_app_data_; 199 content::Manifest web_app_data_;
192 200
193 friend struct content::BrowserThread::DeleteOnThread< 201 friend struct content::BrowserThread::DeleteOnThread<
194 content::BrowserThread::UI>; 202 content::BrowserThread::UI>;
195 friend class base::DeleteHelper<AppBannerDataFetcher>; 203 friend class base::DeleteHelper<AppBannerDataFetcher>;
196 friend class AppBannerDataFetcherUnitTest; 204 friend class AppBannerDataFetcherUnitTest;
197 friend class base::RefCounted<AppBannerDataFetcher>; 205 friend class base::RefCounted<AppBannerDataFetcher>;
198 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher); 206 DISALLOW_COPY_AND_ASSIGN(AppBannerDataFetcher);
199 }; 207 };
200 208
201 } // namespace banners 209 } // namespace banners
202 210
203 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_ 211 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_DATA_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_web_contents_delegate_android.cc ('k') | chrome/browser/banners/app_banner_data_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698