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

Side by Side Diff: chrome/browser/banners/app_banner_manager.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 dominickn'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_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 "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 21 matching lines...) Expand all
32 public AppBannerDataFetcher::Delegate { 32 public AppBannerDataFetcher::Delegate {
33 public: 33 public:
34 static void DisableSecureSchemeCheckForTesting(); 34 static void DisableSecureSchemeCheckForTesting();
35 35
36 static void SetEngagementWeights(double direct_engagement, 36 static void SetEngagementWeights(double direct_engagement,
37 double indirect_engagement); 37 double indirect_engagement);
38 38
39 // Returns whether or not the URLs match for everything except for the ref. 39 // Returns whether or not the URLs match for everything except for the ref.
40 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); 40 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second);
41 41
42 void RequestAppBanner(content::RenderFrameHost* render_frame_host,
gone 2016/01/19 18:35:00 nit: Add a comment here?
horo 2016/01/20 02:26:34 Done.
43 const GURL& validated_url,
44 bool is_debug_mode);
45
42 AppBannerManager(); 46 AppBannerManager();
43 ~AppBannerManager() override; 47 ~AppBannerManager() override;
44 48
45 protected: 49 protected:
46 explicit AppBannerManager(content::WebContents* web_contents); 50 explicit AppBannerManager(content::WebContents* web_contents);
47 51
48 void ReplaceWebContents(content::WebContents* web_contents); 52 void ReplaceWebContents(content::WebContents* web_contents);
49 53
50 // Creates an AppBannerDataFetcher, which constructs an app banner. 54 // Creates an AppBannerDataFetcher, which constructs an app banner.
51 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher( 55 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher(
52 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate) = 0; 56 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate,
57 bool is_debug_mode) = 0;
53 58
54 // Return whether the AppBannerDataFetcher is active. 59 // Return whether the AppBannerDataFetcher is active.
55 bool IsFetcherActive(); 60 bool IsFetcherActive();
56 61
57 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; } 62 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; }
58 63
59 private: 64 private:
60 // WebContentsObserver overrides. 65 // WebContentsObserver overrides.
61 void DidNavigateMainFrame( 66 void DidNavigateMainFrame(
62 const content::LoadCommittedDetails& details, 67 const content::LoadCommittedDetails& details,
63 const content::FrameNavigateParams& params) override; 68 const content::FrameNavigateParams& params) override;
64 69
65 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 70 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
66 const GURL& validated_url) override; 71 const GURL& validated_url) override;
67 72
68 // AppBannerDataFetcher::Delegate overrides. 73 // AppBannerDataFetcher::Delegate overrides.
69 bool HandleNonWebApp(const std::string& platform, 74 bool HandleNonWebApp(const std::string& platform,
70 const GURL& url, 75 const GURL& url,
71 const std::string& id) override; 76 const std::string& id,
77 bool is_debug_mode) override;
72 78
73 // Cancels an active DataFetcher, stopping its banners from appearing. 79 // Cancels an active DataFetcher, stopping its banners from appearing.
74 void CancelActiveFetcher(); 80 void CancelActiveFetcher();
75 81
76 // The type of navigation made to the page 82 // The type of navigation made to the page
77 ui::PageTransition last_transition_type_; 83 ui::PageTransition last_transition_type_;
78 84
79 // Fetches the data required to display a banner for the current page. 85 // Fetches the data required to display a banner for the current page.
80 scoped_refptr<AppBannerDataFetcher> data_fetcher_; 86 scoped_refptr<AppBannerDataFetcher> data_fetcher_;
81 87
82 // A weak pointer is used as the lifetime of the ServiceWorkerContext is 88 // A weak pointer is used as the lifetime of the ServiceWorkerContext is
83 // longer than the lifetime of this banner manager. The banner manager 89 // longer than the lifetime of this banner manager. The banner manager
84 // might be gone when calls sent to the ServiceWorkerContext are completed. 90 // might be gone when calls sent to the ServiceWorkerContext are completed.
85 base::WeakPtrFactory<AppBannerManager> weak_factory_; 91 base::WeakPtrFactory<AppBannerManager> weak_factory_;
86 92
87 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 93 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
88 }; // class AppBannerManager 94 }; // class AppBannerManager
89 95
90 } // namespace banners 96 } // namespace banners
91 97
92 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 98 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698