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

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 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_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 // Requests an app banner. Set |is_debug_mode| when it is triggered by the
43 // developer's action in DevTools.
44 void RequestAppBanner(content::RenderFrameHost* render_frame_host,
45 const GURL& validated_url,
46 bool is_debug_mode);
47
42 AppBannerManager(); 48 AppBannerManager();
43 ~AppBannerManager() override; 49 ~AppBannerManager() override;
44 50
45 protected: 51 protected:
46 explicit AppBannerManager(content::WebContents* web_contents); 52 explicit AppBannerManager(content::WebContents* web_contents);
47 53
48 void ReplaceWebContents(content::WebContents* web_contents); 54 void ReplaceWebContents(content::WebContents* web_contents);
49 55
50 // Creates an AppBannerDataFetcher, which constructs an app banner. 56 // Creates an AppBannerDataFetcher, which constructs an app banner.
51 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher( 57 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher(
52 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate) = 0; 58 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate,
59 bool is_debug_mode) = 0;
53 60
54 // Return whether the AppBannerDataFetcher is active. 61 // Return whether the AppBannerDataFetcher is active.
55 bool IsFetcherActive(); 62 bool IsFetcherActive();
56 63
57 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; } 64 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; }
58 65
59 private: 66 private:
60 // WebContentsObserver overrides. 67 // WebContentsObserver overrides.
61 void DidNavigateMainFrame( 68 void DidNavigateMainFrame(
62 const content::LoadCommittedDetails& details, 69 const content::LoadCommittedDetails& details,
63 const content::FrameNavigateParams& params) override; 70 const content::FrameNavigateParams& params) override;
64 71
65 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 72 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
66 const GURL& validated_url) override; 73 const GURL& validated_url) override;
67 74
68 // AppBannerDataFetcher::Delegate overrides. 75 // AppBannerDataFetcher::Delegate overrides.
69 bool HandleNonWebApp(const std::string& platform, 76 bool HandleNonWebApp(const std::string& platform,
70 const GURL& url, 77 const GURL& url,
71 const std::string& id) override; 78 const std::string& id,
79 bool is_debug_mode) override;
72 80
73 // Cancels an active DataFetcher, stopping its banners from appearing. 81 // Cancels an active DataFetcher, stopping its banners from appearing.
74 void CancelActiveFetcher(); 82 void CancelActiveFetcher();
75 83
76 // The type of navigation made to the page 84 // The type of navigation made to the page
77 ui::PageTransition last_transition_type_; 85 ui::PageTransition last_transition_type_;
78 86
79 // Fetches the data required to display a banner for the current page. 87 // Fetches the data required to display a banner for the current page.
80 scoped_refptr<AppBannerDataFetcher> data_fetcher_; 88 scoped_refptr<AppBannerDataFetcher> data_fetcher_;
81 89
82 // A weak pointer is used as the lifetime of the ServiceWorkerContext is 90 // A weak pointer is used as the lifetime of the ServiceWorkerContext is
83 // longer than the lifetime of this banner manager. The banner manager 91 // longer than the lifetime of this banner manager. The banner manager
84 // might be gone when calls sent to the ServiceWorkerContext are completed. 92 // might be gone when calls sent to the ServiceWorkerContext are completed.
85 base::WeakPtrFactory<AppBannerManager> weak_factory_; 93 base::WeakPtrFactory<AppBannerManager> weak_factory_;
86 94
87 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 95 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
88 }; // class AppBannerManager 96 }; // class AppBannerManager
89 97
90 } // namespace banners 98 } // namespace banners
91 99
92 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 100 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_debug_log.cc ('k') | chrome/browser/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698