Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / android / webapps / single_tab_mode_tab_helper.h
bloba79fd2e4359d3f7cb7348efe1520dadebe206d1c
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/ui/blocked_content/blocked_window_params.h"
13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h"
16 namespace content {
17 class RenderViewHost;
18 class WebContents;
19 } // namespace content
21 class GURL;
23 // Registers and unregisters the IDs of renderers in single tab mode, which
24 // are disallowed from opening new windows via
25 // ChromeContentBrowserClient::CanCreateWindow().
26 class SingleTabModeTabHelper
27 : public content::WebContentsObserver,
28 public content::WebContentsUserData<SingleTabModeTabHelper> {
29 public:
30 // Checks if the ID pair is blocked from creating new windows. IO-thread only.
31 static bool IsRegistered(int32 process_id, int32 routing_id);
33 virtual ~SingleTabModeTabHelper();
35 // Handles opening the given URL through the TabModel.
36 void HandleOpenUrl(const BlockedWindowParams& params);
38 // Permanently block this WebContents from creating new windows -- there is no
39 // current need to allow toggling this flag on or off.
40 void PermanentlyBlockAllNewWindows();
42 // content::WebContentsObserver
43 virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
44 override;
45 virtual void RenderViewDeleted(content::RenderViewHost* render_view_host)
46 override;
48 private:
49 explicit SingleTabModeTabHelper(content::WebContents* web_contents);
50 friend class content::WebContentsUserData<SingleTabModeTabHelper>;
52 bool block_all_new_windows_;
54 DISALLOW_COPY_AND_ASSIGN(SingleTabModeTabHelper);
57 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_SINGLE_TAB_MODE_TAB_HELPER_H_