1 // Copyright (c) 2012 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_EXTERNAL_TAB_EXTERNAL_TAB_CONTAINER_H_
6 #define CHROME_BROWSER_EXTERNAL_TAB_EXTERNAL_TAB_CONTAINER_H_
10 #include "base/memory/ref_counted.h"
11 #include "ui/gfx/native_widget_types.h"
13 class AutomationProvider;
14 class AutomationResourceMessageFilter;
30 class ExternalTabContainer : public base::RefCounted<ExternalTabContainer> {
32 static ExternalTabContainer* Create(
33 AutomationProvider* automation_provider,
34 AutomationResourceMessageFilter* filter);
36 // A helper method that retrieves the ExternalTabContainer object that
37 // hosts the given WebContents.
38 static ExternalTabContainer* GetContainerForTab(
39 content::WebContents* web_contents);
41 // Returns the ExternalTabContainer instance associated with the cookie
42 // passed in. It also erases the corresponding reference from the map.
43 // Returns NULL if we fail to find the cookie in the map.
44 static scoped_refptr<ExternalTabContainer> RemovePendingTab(uintptr_t cookie);
46 // Initializes the instance. This must be invoked before any other member
48 virtual bool Init(Profile* profile,
50 const gfx::Rect& bounds,
52 bool load_requests_via_automation,
53 bool handle_top_level_requests,
54 content::WebContents* existing_contents,
55 const GURL& initial_url,
57 bool infobars_enabled,
58 bool supports_full_tab_mode) = 0;
60 // Unhook the keystroke listener and notify about the closing WebContents.
61 // This function gets called from three places, which is fine.
63 // 2. In the destructor.
64 // 3. In AutomationProvider::CreateExternalTab
65 virtual void Uninitialize() = 0;
67 // Used to reinitialize the automation channel and related information
68 // for this container. Typically used when an ExternalTabContainer
69 // instance is created by Chrome and attached to an automation client.
70 virtual bool Reinitialize(AutomationProvider* automation_provider,
71 AutomationResourceMessageFilter* filter,
72 HWND parent_window) = 0;
74 // This is invoked when the external host reflects back to us a keyboard
75 // message it did not process.
76 virtual void ProcessUnhandledAccelerator(const MSG& msg) = 0;
78 // See WebContents::FocusThroughTabTraversal. Called from AutomationProvider.
79 virtual void FocusThroughTabTraversal(bool reverse,
80 bool restore_focus_to_view) = 0;
82 virtual void RunUnloadHandlers(IPC::Message* reply_message) = 0;
84 virtual content::WebContents* GetWebContents() const = 0;
85 virtual HWND GetExternalTabHWND() const = 0;
86 virtual HWND GetContentHWND() const = 0;
88 virtual void SetTabHandle(int handle) = 0;
89 virtual int GetTabHandle() const = 0;
91 // Returns true if the context menu command was handled
92 virtual bool ExecuteContextMenuCommand(int command) = 0;
95 virtual ~ExternalTabContainer() {}
98 friend class base::RefCounted<ExternalTabContainer>;
101 #endif // CHROME_BROWSER_EXTERNAL_TAB_EXTERNAL_TAB_CONTAINER_H_