OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_TAB_HELPER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "content/public/browser/web_contents_user_data.h" |
| 11 |
| 12 class GURL; |
| 13 |
| 14 namespace content { |
| 15 class RenderFrameHost; |
| 16 } |
| 17 |
| 18 // Tracks whether a previews infobar has been shown for a page. Handles showing |
| 19 // the infobar when the main frame response indicates a Lite Page. |
| 20 class PreviewsInfoBarTabHelper |
| 21 : public content::WebContentsObserver, |
| 22 public content::WebContentsUserData<PreviewsInfoBarTabHelper> { |
| 23 public: |
| 24 ~PreviewsInfoBarTabHelper() override; |
| 25 |
| 26 // Indicates whether the InfoBar for a preview has been shown for the page. |
| 27 bool displayed_preview_infobar() const { |
| 28 return displayed_preview_infobar_; |
| 29 } |
| 30 |
| 31 // Sets whether the InfoBar for a preview has been shown for the page. |
| 32 // |displayed_preview_infobar_| is reset to false on |
| 33 // DidStartProvisionalLoadForFrame for the main frame. |
| 34 void set_displayed_preview_infobar(bool displayed) { |
| 35 displayed_preview_infobar_ = displayed; |
| 36 } |
| 37 |
| 38 private: |
| 39 friend class content::WebContentsUserData<PreviewsInfoBarTabHelper>; |
| 40 |
| 41 explicit PreviewsInfoBarTabHelper(content::WebContents* web_contents); |
| 42 |
| 43 // Overridden from content::WebContentsObserver: |
| 44 void DidStartProvisionalLoadForFrame( |
| 45 content::RenderFrameHost* render_frame_host, |
| 46 const GURL& validated_url, |
| 47 bool is_error_page, |
| 48 bool is_iframe_srcdoc) override; |
| 49 void DidFinishNavigation( |
| 50 content::NavigationHandle* navigation_handle) override; |
| 51 |
| 52 // True if the InfoBar for a preview has been shown for the page. |
| 53 bool displayed_preview_infobar_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarTabHelper); |
| 56 }; |
| 57 |
| 58 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_TAB_HELPER_H_ |
OLD | NEW |