| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // Return a string identifying this app for metrics. | 97 // Return a string identifying this app for metrics. |
| 98 virtual std::string GetAppIdentifier(); | 98 virtual std::string GetAppIdentifier(); |
| 99 | 99 |
| 100 // Return a string describing what type of banner is being created. Used when | 100 // Return a string describing what type of banner is being created. Used when |
| 101 // alerting websites that a banner is about to be created. | 101 // alerting websites that a banner is about to be created. |
| 102 virtual std::string GetBannerType(); | 102 virtual std::string GetBannerType(); |
| 103 | 103 |
| 104 // Returns a string parameter for a devtools console message corresponding to | 104 // Returns a string parameter for a devtools console message corresponding to |
| 105 // |code|. Returns the empty string if |code| requires no parameter. | 105 // |code|. Returns the empty string if |code| requires no parameter. |
| 106 std::string GetErrorParam(InstallableErrorCode code); | 106 std::string GetStatusParam(InstallableStatusCode code); |
| 107 | 107 |
| 108 // Returns the ideal and minimum icon sizes required for being installable. | 108 // Returns the ideal and minimum icon sizes required for being installable. |
| 109 virtual int GetIdealIconSizeInDp(); | 109 virtual int GetIdealIconSizeInDp(); |
| 110 virtual int GetMinimumIconSizeInDp(); | 110 virtual int GetMinimumIconSizeInDp(); |
| 111 | 111 |
| 112 // Returns a WeakPtr to this object. Exposed so subclasses/infobars may | 112 // Returns a WeakPtr to this object. Exposed so subclasses/infobars may |
| 113 // may bind callbacks without needing their own WeakPtrFactory. | 113 // may bind callbacks without needing their own WeakPtrFactory. |
| 114 base::WeakPtr<AppBannerManager> GetWeakPtr(); | 114 base::WeakPtr<AppBannerManager> GetWeakPtr(); |
| 115 | 115 |
| 116 // Returns true if |is_debug_mode_| is true or the | 116 // Returns true if |is_debug_mode_| is true or the |
| 117 // kBypassAppBannerEngagementChecks flag is set. | 117 // kBypassAppBannerEngagementChecks flag is set. |
| 118 bool IsDebugMode() const; | 118 virtual bool IsDebugMode() const; |
| 119 | 119 |
| 120 // Returns true if the webapp at |start_url| has already been installed. | 120 // Returns true if the webapp at |start_url| has already been installed. |
| 121 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, | 121 virtual bool IsWebAppInstalled(content::BrowserContext* browser_context, |
| 122 const GURL& start_url); | 122 const GURL& start_url); |
| 123 | 123 |
| 124 // Callback invoked by the InstallableManager once it has fetched the page's | 124 // Callback invoked by the InstallableManager once it has fetched the page's |
| 125 // manifest. | 125 // manifest. |
| 126 void OnDidGetManifest(const InstallableData& result); | 126 void OnDidGetManifest(const InstallableData& result); |
| 127 | 127 |
| 128 // Run at the conclusion of OnDidGetManifest. For web app banners, this calls | 128 // Run at the conclusion of OnDidGetManifest. For web app banners, this calls |
| 129 // back to the InstallableManager to continue checking criteria. For native | 129 // back to the InstallableManager to continue checking criteria. For native |
| 130 // app banners, this checks whether native apps are preferred in the manifest, | 130 // app banners, this checks whether native apps are preferred in the manifest, |
| 131 // and calls to Java to verify native app details. If a native banner isn't or | 131 // and calls to Java to verify native app details. If a native banner isn't or |
| 132 // can't be requested, it continues with the web app banner checks. | 132 // can't be requested, it continues with the web app banner checks. |
| 133 virtual void PerformInstallableCheck(); | 133 virtual void PerformInstallableCheck(); |
| 134 | 134 |
| 135 // Callback invoked by the InstallableManager once it has finished checking | 135 // Callback invoked by the InstallableManager once it has finished checking |
| 136 // all other installable properties. | 136 // all other installable properties. |
| 137 void OnDidPerformInstallableCheck(const InstallableData& result); | 137 void OnDidPerformInstallableCheck(const InstallableData& result); |
| 138 | 138 |
| 139 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR | 139 // Records that a banner was shown. The |event_name| corresponds to the RAPPOR |
| 140 // metric being recorded. | 140 // metric being recorded. |
| 141 void RecordDidShowBanner(const std::string& event_name); | 141 void RecordDidShowBanner(const std::string& event_name); |
| 142 | 142 |
| 143 // Logs an error message corresponding to |code| to the devtools console | 143 // Logs an error message corresponding to |code| to the devtools console |
| 144 // attached to |web_contents|. Does nothing if IsDebugMode() returns false. | 144 // attached to |web_contents|. Does nothing if IsDebugMode() returns false. |
| 145 void ReportError(content::WebContents* web_contents, | 145 void ReportStatus(content::WebContents* web_contents, |
| 146 InstallableErrorCode code); | 146 InstallableStatusCode code); |
| 147 | 147 |
| 148 // Stops the banner pipeline. Any callback currently running will terminate | 148 // Stops the banner pipeline. Any callback currently running will terminate |
| 149 // the next time they check |is_active_|. | 149 // the next time they check |is_active_|. |
| 150 virtual void Stop(); | 150 virtual void Stop(); |
| 151 | 151 |
| 152 // Sends a message to the renderer that the page has met the requirements to | 152 // Sends a message to the renderer that the page has met the requirements to |
| 153 // show a banner. The page can respond to cancel the banner (and possibly | 153 // show a banner. The page can respond to cancel the banner (and possibly |
| 154 // display it later), or otherwise allow it to be shown. This is virtual to | 154 // display it later), or otherwise allow it to be shown. This is virtual to |
| 155 // allow tests to mock out the renderer IPC. | 155 // allow tests to mock out the renderer IPC. |
| 156 virtual void SendBannerPromptRequest(); | 156 virtual void SendBannerPromptRequest(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 bool load_finished_; | 251 bool load_finished_; |
| 252 | 252 |
| 253 // Record whether the page decides to defer showing the banner, and if it | 253 // Record whether the page decides to defer showing the banner, and if it |
| 254 // requests for it to be shown later on. | 254 // requests for it to be shown later on. |
| 255 bool was_canceled_by_page_; | 255 bool was_canceled_by_page_; |
| 256 bool page_requested_prompt_; | 256 bool page_requested_prompt_; |
| 257 | 257 |
| 258 // Whether we should be logging errors to the console for this request. | 258 // Whether we should be logging errors to the console for this request. |
| 259 bool is_debug_mode_; | 259 bool is_debug_mode_; |
| 260 | 260 |
| 261 // Whether the installable status has been logged for this run. |
| 262 bool need_to_log_status_; |
| 263 |
| 261 // The concrete subclasses of this class are expected to have their lifetimes | 264 // The concrete subclasses of this class are expected to have their lifetimes |
| 262 // scoped to the WebContents which they are observing. This allows us to use | 265 // scoped to the WebContents which they are observing. This allows us to use |
| 263 // weak pointers for callbacks. | 266 // weak pointers for callbacks. |
| 264 base::WeakPtrFactory<AppBannerManager> weak_factory_; | 267 base::WeakPtrFactory<AppBannerManager> weak_factory_; |
| 265 | 268 |
| 266 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 269 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); |
| 267 }; | 270 }; |
| 268 | 271 |
| 269 } // namespace banners | 272 } // namespace banners |
| 270 | 273 |
| 271 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 274 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ |
| OLD | NEW |