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

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

Issue 1308533006: webapps: allow callers of icon downloader/selector to specify a minimum size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-splashscreen-icon
Patch Set: Fix test failure Created 5 years, 3 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/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"
(...skipping 20 matching lines...) Expand all
31 public AppBannerDataFetcher::Delegate { 31 public AppBannerDataFetcher::Delegate {
32 public: 32 public:
33 static void DisableSecureSchemeCheckForTesting(); 33 static void DisableSecureSchemeCheckForTesting();
34 34
35 static void SetEngagementWeights(double direct_engagement, 35 static void SetEngagementWeights(double direct_engagement,
36 double indirect_engagement); 36 double indirect_engagement);
37 37
38 // Returns whether or not the URLs match for everything except for the ref. 38 // Returns whether or not the URLs match for everything except for the ref.
39 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); 39 static bool URLsAreForTheSamePage(const GURL& first, const GURL& second);
40 40
41 explicit AppBannerManager(int ideal_icon_size_in_dp); 41 AppBannerManager();
42 ~AppBannerManager() override; 42 ~AppBannerManager() override;
43 43
44 // WebContentsObserver overrides. 44 // WebContentsObserver overrides.
45 void DidCommitProvisionalLoadForFrame( 45 void DidCommitProvisionalLoadForFrame(
46 content::RenderFrameHost* render_frame_host, 46 content::RenderFrameHost* render_frame_host,
47 const GURL& url, 47 const GURL& url,
48 ui::PageTransition transition_type) override; 48 ui::PageTransition transition_type) override;
49 49
50 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 50 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
51 const GURL& validated_url) override; 51 const GURL& validated_url) override;
52 52
53 protected: 53 protected:
54 AppBannerManager(content::WebContents* web_contents, 54 explicit AppBannerManager(content::WebContents* web_contents);
55 int ideal_icon_size_in_dp);
56 55
57 void ReplaceWebContents(content::WebContents* web_contents); 56 void ReplaceWebContents(content::WebContents* web_contents);
58 57
59 // Creates an AppBannerDataFetcher, which constructs an app banner. 58 // Creates an AppBannerDataFetcher, which constructs an app banner.
60 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher( 59 virtual AppBannerDataFetcher* CreateAppBannerDataFetcher(
61 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate, 60 base::WeakPtr<AppBannerDataFetcher::Delegate> weak_delegate) = 0;
62 const int ideal_icon_size_in_dp) = 0;
63 61
64 // Return whether the AppBannerDataFetcher is active. 62 // Return whether the AppBannerDataFetcher is active.
65 bool IsFetcherActive(); 63 bool IsFetcherActive();
66 64
67 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; } 65 scoped_refptr<AppBannerDataFetcher> data_fetcher() { return data_fetcher_; }
68 int ideal_icon_size_in_dp() const { return ideal_icon_size_in_dp_; }
69 66
70 private: 67 private:
71 // AppBannerDataFetcher::Delegate overrides. 68 // AppBannerDataFetcher::Delegate overrides.
72 bool HandleNonWebApp(const std::string& platform, 69 bool HandleNonWebApp(const std::string& platform,
73 const GURL& url, 70 const GURL& url,
74 const std::string& id) override; 71 const std::string& id) override;
75 72
76 // Called after the manager sends a message to the renderer regarding its 73 // Called after the manager sends a message to the renderer regarding its
77 // intention to show a prompt. The renderer will send a message back with the 74 // intention to show a prompt. The renderer will send a message back with the
78 // opportunity to cancel. 75 // opportunity to cancel.
79 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host, 76 void OnBannerPromptReply(content::RenderFrameHost* render_frame_host,
80 int request_id, 77 int request_id,
81 blink::WebAppBannerPromptReply reply); 78 blink::WebAppBannerPromptReply reply);
82 79
83 // Cancels an active DataFetcher, stopping its banners from appearing. 80 // Cancels an active DataFetcher, stopping its banners from appearing.
84 void CancelActiveFetcher(); 81 void CancelActiveFetcher();
85 82
86 // Ideal icon size to use.
87 const int ideal_icon_size_in_dp_;
88
89 // The type of navigation made to the page 83 // The type of navigation made to the page
90 ui::PageTransition last_transition_type_; 84 ui::PageTransition last_transition_type_;
91 85
92 // Fetches the data required to display a banner for the current page. 86 // Fetches the data required to display a banner for the current page.
93 scoped_refptr<AppBannerDataFetcher> data_fetcher_; 87 scoped_refptr<AppBannerDataFetcher> data_fetcher_;
94 88
95 // A weak pointer is used as the lifetime of the ServiceWorkerContext is 89 // A weak pointer is used as the lifetime of the ServiceWorkerContext is
96 // longer than the lifetime of this banner manager. The banner manager 90 // longer than the lifetime of this banner manager. The banner manager
97 // might be gone when calls sent to the ServiceWorkerContext are completed. 91 // might be gone when calls sent to the ServiceWorkerContext are completed.
98 base::WeakPtrFactory<AppBannerManager> weak_factory_; 92 base::WeakPtrFactory<AppBannerManager> weak_factory_;
99 93
100 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); 94 DISALLOW_COPY_AND_ASSIGN(AppBannerManager);
101 }; // class AppBannerManager 95 }; // class AppBannerManager
102 96
103 } // namespace banners 97 } // namespace banners
104 98
105 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ 99 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher_desktop.cc ('k') | chrome/browser/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698