| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" | 14 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
| 17 | 17 |
| 18 namespace content { | |
| 19 class RenderViewHost; | |
| 20 class WebContents; | |
| 21 } // namespace content | |
| 22 | |
| 23 // Registers and unregisters the IDs of renderers in single tab mode, which | 18 // Registers and unregisters the IDs of renderers in single tab mode, which |
| 24 // are disallowed from opening new windows via | 19 // are disallowed from opening new windows via |
| 25 // ChromeContentBrowserClient::CanCreateWindow(). | 20 // ChromeContentBrowserClient::CanCreateWindow(). |
| 26 class SingleTabModeTabHelper | 21 class SingleTabModeTabHelper |
| 27 : public content::WebContentsObserver, | 22 : public content::WebContentsObserver, |
| 28 public content::WebContentsUserData<SingleTabModeTabHelper> { | 23 public content::WebContentsUserData<SingleTabModeTabHelper> { |
| 29 public: | 24 public: |
| 30 // Checks if the ID pair is blocked from creating new windows. IO-thread only. | 25 // Checks if the ID pair is blocked from creating new windows. IO-thread only. |
| 31 static bool IsRegistered(int32_t process_id, int32_t routing_id); | 26 static bool IsRegistered(int32_t process_id, int32_t routing_id); |
| 32 | 27 |
| 33 ~SingleTabModeTabHelper() override; | 28 ~SingleTabModeTabHelper() override; |
| 34 | 29 |
| 35 // Handles opening the given URL through the TabModel. | 30 // Handles opening the given URL through the TabModel. |
| 36 void HandleOpenUrl(const BlockedWindowParams& params); | 31 void HandleOpenUrl(const BlockedWindowParams& params); |
| 37 | 32 |
| 38 // Permanently block this WebContents from creating new windows -- there is no | 33 // Permanently block this WebContents from creating new windows -- there is no |
| 39 // current need to allow toggling this flag on or off. | 34 // current need to allow toggling this flag on or off. |
| 40 void PermanentlyBlockAllNewWindows(); | 35 void PermanentlyBlockAllNewWindows(); |
| 41 | 36 |
| 42 // content::WebContentsObserver | 37 // content::WebContentsObserver |
| 43 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | 38 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
| 44 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | 39 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 45 | 40 |
| 46 private: | 41 private: |
| 47 explicit SingleTabModeTabHelper(content::WebContents* web_contents); | 42 explicit SingleTabModeTabHelper(content::WebContents* web_contents); |
| 48 friend class content::WebContentsUserData<SingleTabModeTabHelper>; | 43 friend class content::WebContentsUserData<SingleTabModeTabHelper>; |
| 49 | 44 |
| 50 bool block_all_new_windows_; | 45 bool block_all_new_windows_; |
| 51 | 46 |
| 52 DISALLOW_COPY_AND_ASSIGN(SingleTabModeTabHelper); | 47 DISALLOW_COPY_AND_ASSIGN(SingleTabModeTabHelper); |
| 53 }; | 48 }; |
| 54 | 49 |
| 55 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ | 50 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_ |
| OLD | NEW |