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

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

Issue 2553013004: Remove the app banner navigation heuristic. (Closed)
Patch Set: Add comments Created 4 years 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_MANAGER_H_ 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 class AppBannerManager : public content::WebContentsObserver, 51 class AppBannerManager : public content::WebContentsObserver,
52 public blink::mojom::AppBannerService, 52 public blink::mojom::AppBannerService,
53 public SiteEngagementObserver { 53 public SiteEngagementObserver {
54 public: 54 public:
55 // Returns the current time. 55 // Returns the current time.
56 static base::Time GetCurrentTime(); 56 static base::Time GetCurrentTime();
57 57
58 // Fast-forwards the current time for testing. 58 // Fast-forwards the current time for testing.
59 static void SetTimeDeltaForTesting(int days); 59 static void SetTimeDeltaForTesting(int days);
60 60
61 // Sets the weights applied to direct and indirect navigations for triggering 61 // Sets the total engagement required for triggering the banner in testing.
62 // the banner. Deprecated and will be removed when app banners fully migrates 62 static void SetTotalEngagementToTrigger(double engagement);
63 // to using site engagement as a trigger.
64 static void SetEngagementWeights(double direct_engagement,
65 double indirect_engagement);
66 63
67 // Returns whether or not the URLs match for everything except for the ref. 64 // Returns whether or not the URLs match for everything except for the ref.
68 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); 65 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second);
69 66
70 // Requests an app banner. If |is_debug_mode| is true, any failure in the 67 // Requests an app banner. If |is_debug_mode| is true, any failure in the
71 // pipeline will be reported to the devtools console. 68 // pipeline will be reported to the devtools console.
72 virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode); 69 virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode);
73 70
74 // Sends a message to the renderer that the user accepted the banner. Does 71 // Sends a message to the renderer that the user accepted the banner. Does
75 // nothing if |request_id| does not match the current request. 72 // nothing if |request_id| does not match the current request.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void ReportStatus(content::WebContents* web_contents, 150 void ReportStatus(content::WebContents* web_contents,
154 InstallableStatusCode code); 151 InstallableStatusCode code);
155 152
156 // Stops the banner pipeline, preventing any outstanding callbacks from 153 // Stops the banner pipeline, preventing any outstanding callbacks from
157 // running and resetting the manager state. This method is virtual to allow 154 // running and resetting the manager state. This method is virtual to allow
158 // tests to intercept it and verify correct behaviour. 155 // tests to intercept it and verify correct behaviour.
159 virtual void Stop(); 156 virtual void Stop();
160 157
161 // Sends a message to the renderer that the page has met the requirements to 158 // Sends a message to the renderer that the page has met the requirements to
162 // show a banner. The page can respond to cancel the banner (and possibly 159 // show a banner. The page can respond to cancel the banner (and possibly
163 // display it later), or otherwise allow it to be shown. This is virtual to 160 // display it later), or otherwise allow it to be shown.
164 // allow tests to mock out the renderer IPC. 161 void SendBannerPromptRequest();
165 virtual void SendBannerPromptRequest();
166 162
167 // content::WebContentsObserver overrides. 163 // content::WebContentsObserver overrides.
168 void DidStartNavigation(content::NavigationHandle* handle) override; 164 void DidStartNavigation(content::NavigationHandle* handle) override;
169 void DidFinishNavigation(content::NavigationHandle* handle) override; 165 void DidFinishNavigation(content::NavigationHandle* handle) override;
170 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 166 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
171 const GURL& validated_url) override; 167 const GURL& validated_url) override;
172 void MediaStartedPlaying(const MediaPlayerInfo& media_info, 168 void MediaStartedPlaying(const MediaPlayerInfo& media_info,
173 const MediaPlayerId& id) override; 169 const MediaPlayerId& id) override;
174 void MediaStoppedPlaying(const MediaPlayerInfo& media_info, 170 void MediaStoppedPlaying(const MediaPlayerInfo& media_info,
175 const MediaPlayerId& id) override; 171 const MediaPlayerId& id) override;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // intention to show a prompt. The renderer will send a message back with the 222 // intention to show a prompt. The renderer will send a message back with the
227 // opportunity to cancel. 223 // opportunity to cancel.
228 void OnBannerPromptReply(blink::mojom::AppBannerPromptReply reply, 224 void OnBannerPromptReply(blink::mojom::AppBannerPromptReply reply,
229 const std::string& referrer); 225 const std::string& referrer);
230 226
231 // blink::mojom::AppBannerService overrides. 227 // blink::mojom::AppBannerService overrides.
232 // Called when Blink has prevented a banner from being shown, and is now 228 // Called when Blink has prevented a banner from being shown, and is now
233 // requesting that it be shown later. 229 // requesting that it be shown later.
234 void DisplayAppBanner() override; 230 void DisplayAppBanner() override;
235 231
236 // The type of navigation made to the page
237 ui::PageTransition last_transition_type_;
238
239 // Fetches the data required to display a banner for the current page. 232 // Fetches the data required to display a banner for the current page.
240 InstallableManager* manager_; 233 InstallableManager* manager_;
241 234
242 // A monotonically increasing id to verify the response to the 235 // A monotonically increasing id to verify the response to the
243 // beforeinstallprompt event from the renderer. 236 // beforeinstallprompt event from the renderer.
244 int event_request_id_; 237 int event_request_id_;
245 238
246 // We do not want to trigger a banner when the manager is attached to 239 // We do not want to trigger a banner when the manager is attached to
247 // a WebContents that is playing video. Banners triggering on a site in the 240 // a WebContents that is playing video. Banners triggering on a site in the
248 // background will appear when the tab is reactivated. 241 // background will appear when the tab is reactivated.
(...skipping 27 matching lines...) Expand all
276 // scoped to the WebContents which they are observing. This allows us to use 269 // scoped to the WebContents which they are observing. This allows us to use
277 // weak pointers for callbacks. 270 // weak pointers for callbacks.
278 base::WeakPtrFactory<AppBannerManager> weak_factory_; 271 base::WeakPtrFactory<AppBannerManager> weak_factory_;
279 272
280 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 273 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
281 }; 274 };
282 275
283 } // namespace banners 276 } // namespace banners
284 277
285 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 278 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_manager_android.cc ('k') | chrome/browser/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698