| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 virtual void OnAppIconFetched(const SkBitmap& bitmap) {} | 94 virtual void OnAppIconFetched(const SkBitmap& bitmap) {} |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 enum class State { | 97 enum class State { |
| 98 // The banner pipeline has not yet been triggered for this page load. | 98 // The banner pipeline has not yet been triggered for this page load. |
| 99 INACTIVE, | 99 INACTIVE, |
| 100 | 100 |
| 101 // The banner pipeline is currently running for this page load. | 101 // The banner pipeline is currently running for this page load. |
| 102 ACTIVE, | 102 ACTIVE, |
| 103 | 103 |
| 104 // The banner pipeline is currently waiting for the page manifest to be |
| 105 // fetched. |
| 106 PENDING_MANIFEST, |
| 107 |
| 108 // The banner pipeline is currently waiting for the installability criteria |
| 109 // to be checked. |
| 110 PENDING_INSTALLABLE_CHECK, |
| 111 |
| 104 // The banner pipeline has finished running, but is waiting for sufficient | 112 // The banner pipeline has finished running, but is waiting for sufficient |
| 105 // engagement to trigger the banner. | 113 // engagement to trigger the banner. |
| 106 PENDING_ENGAGEMENT, | 114 PENDING_ENGAGEMENT, |
| 107 | 115 |
| 108 // The banner pipeline has finished running, but is waiting for an event to | 116 // The banner pipeline has finished running, but is waiting for an event to |
| 109 // trigger the banner. | 117 // trigger the banner. |
| 110 PENDING_EVENT, | 118 PENDING_EVENT, |
| 111 | 119 |
| 112 // The banner pipeline has finished running for this page load and no more | 120 // The banner pipeline has finished running for this page load and no more |
| 113 // processing is to be done. | 121 // processing is to be done. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void OnEngagementIncreased(content::WebContents* web_contents, | 213 void OnEngagementIncreased(content::WebContents* web_contents, |
| 206 const GURL& url, | 214 const GURL& url, |
| 207 double score) override; | 215 double score) override; |
| 208 | 216 |
| 209 // Subclass accessors for private fields which should not be changed outside | 217 // Subclass accessors for private fields which should not be changed outside |
| 210 // this class. | 218 // this class. |
| 211 InstallableManager* manager() const { return manager_; } | 219 InstallableManager* manager() const { return manager_; } |
| 212 int event_request_id() const { return event_request_id_; } | 220 int event_request_id() const { return event_request_id_; } |
| 213 bool is_active() const { return state_ == State::ACTIVE; } | 221 bool is_active() const { return state_ == State::ACTIVE; } |
| 214 bool is_active_or_pending() const { | 222 bool is_active_or_pending() const { |
| 215 return state_ == State::ACTIVE || state_ == State::PENDING_ENGAGEMENT || | 223 switch (state_) { |
| 216 state_ == State::PENDING_EVENT; | 224 case State::ACTIVE: |
| 225 case State::PENDING_MANIFEST: |
| 226 case State::PENDING_INSTALLABLE_CHECK: |
| 227 case State::PENDING_ENGAGEMENT: |
| 228 case State::PENDING_EVENT: |
| 229 return true; |
| 230 case State::INACTIVE: |
| 231 case State::COMPLETE: |
| 232 return false; |
| 233 } |
| 234 return false; |
| 217 } | 235 } |
| 218 bool is_complete() const { return state_ == State::COMPLETE; } | 236 bool is_complete() const { return state_ == State::COMPLETE; } |
| 219 bool is_pending_engagement() const { | 237 bool is_pending_engagement() const { |
| 220 return state_ == State::PENDING_ENGAGEMENT; | 238 return state_ == State::PENDING_ENGAGEMENT; |
| 221 } | 239 } |
| 222 bool is_pending_event() const { | 240 bool is_pending_event() const { |
| 223 return state_ == State::PENDING_EVENT || page_requested_prompt_; | 241 return state_ == State::PENDING_EVENT || page_requested_prompt_; |
| 224 } | 242 } |
| 225 | 243 |
| 226 // The title to display in the banner. | 244 // The title to display in the banner. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // scoped to the WebContents which they are observing. This allows us to use | 323 // scoped to the WebContents which they are observing. This allows us to use |
| 306 // weak pointers for callbacks. | 324 // weak pointers for callbacks. |
| 307 base::WeakPtrFactory<AppBannerManager> weak_factory_; | 325 base::WeakPtrFactory<AppBannerManager> weak_factory_; |
| 308 | 326 |
| 309 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 327 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); |
| 310 }; | 328 }; |
| 311 | 329 |
| 312 } // namespace banners | 330 } // namespace banners |
| 313 | 331 |
| 314 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 332 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ |
| OLD | NEW |