Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/external_tab_container.h

Issue 200003: Chrome side of the fix for http://b/issue?id=1694574, which is a bug caused w... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_EXTERNAL_TAB_CONTAINER_H_ 5 #ifndef CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_
6 #define CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_ 6 #define CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include <map>
9 10
10 #include "chrome/browser/automation/automation_resource_message_filter.h" 11 #include "chrome/browser/automation/automation_resource_message_filter.h"
11 #include "chrome/browser/automation/automation_profile_impl.h" 12 #include "chrome/browser/automation/automation_profile_impl.h"
12 #include "chrome/browser/browser.h" 13 #include "chrome/browser/browser.h"
13 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 14 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
14 #include "chrome/common/navigation_types.h" 15 #include "chrome/common/navigation_types.h"
15 #include "chrome/common/notification_observer.h" 16 #include "chrome/common/notification_observer.h"
16 #include "chrome/common/notification_registrar.h" 17 #include "chrome/common/notification_registrar.h"
17 #include "views/widget/widget_win.h" 18 #include "views/widget/widget_win.h"
18 19
19 class AutomationProvider; 20 class AutomationProvider;
20 class Profile; 21 class Profile;
21 class TabContentsContainer; 22 class TabContentsContainer;
22 class RenderViewContextMenuExternalWin; 23 class RenderViewContextMenuExternalWin;
23 24
24 namespace IPC { 25 namespace IPC {
25 struct NavigationInfo; 26 struct NavigationInfo;
26 } 27 }
27 28
28 // This class serves as the container window for an external tab. 29 // This class serves as the container window for an external tab.
29 // An external tab is a Chrome tab that is meant to displayed in an 30 // An external tab is a Chrome tab that is meant to displayed in an
30 // external process. This class provides the FocusManger needed by the 31 // external process. This class provides the FocusManger needed by the
31 // TabContents as well as an implementation of TabContentsDelagate. 32 // TabContents as well as an implementation of TabContentsDelagate.
32 // TODO(beng): Should override WidgetWin instead of Widget. 33 // TODO(beng): Should override WidgetWin instead of Widget.
33 class ExternalTabContainer : public TabContentsDelegate, 34 class ExternalTabContainer : public TabContentsDelegate,
34 public NotificationObserver, 35 public NotificationObserver,
35 public views::WidgetWin { 36 public views::WidgetWin,
37 public base::RefCounted<ExternalTabContainer> {
36 public: 38 public:
39 typedef std::map<intptr_t, scoped_refptr<ExternalTabContainer> > PendingTabs;
40
37 ExternalTabContainer(AutomationProvider* automation, 41 ExternalTabContainer(AutomationProvider* automation,
38 AutomationResourceMessageFilter* filter); 42 AutomationResourceMessageFilter* filter);
39 ~ExternalTabContainer(); 43 ~ExternalTabContainer();
40 44
41 TabContents* tab_contents() const { return tab_contents_; } 45 TabContents* tab_contents() const { return tab_contents_; }
42 46
43 // Temporary hack so we can send notifications back 47 // Temporary hack so we can send notifications back
44 void set_tab_handle(int handle) { 48 void set_tab_handle(int handle) {
45 tab_handle_ = handle; 49 tab_handle_ = handle;
46 if (automation_profile_.get()) 50 if (automation_profile_.get())
47 automation_profile_->set_tab_handle(handle); 51 automation_profile_->set_tab_handle(handle);
48 } 52 }
49 53
50 int tab_handle() const { 54 int tab_handle() const {
51 return tab_handle_; 55 return tab_handle_;
52 } 56 }
53 57
54 bool Init(Profile* profile, 58 bool Init(Profile* profile,
55 HWND parent, 59 HWND parent,
56 const gfx::Rect& bounds, 60 const gfx::Rect& bounds,
57 DWORD style, 61 DWORD style,
58 bool load_requests_via_automation, 62 bool load_requests_via_automation,
59 bool handle_top_level_requests, 63 bool handle_top_level_requests,
60 TabContents* existing_tab_contents); 64 TabContents* existing_tab_contents);
61 65
66 // Unhook the keystroke listener and notify about the closing TabContents.
67 // This function gets called from three places, which is fine.
68 // 1. OnFinalMessage
69 // 2. In the destructor.
70 // 3. In AutomationProvider::CreateExternalTab
71 void Uninitialize();
72
73 // Used to reinitialize the automation channel and related information
74 // for this container. Typically used when an ExternalTabContainer
75 // instance is created by Chrome and attached to an automation client.
76 bool Reinitialize(AutomationProvider* automation_provider,
77 AutomationResourceMessageFilter* filter);
78
62 // This is invoked when the external host reflects back to us a keyboard 79 // This is invoked when the external host reflects back to us a keyboard
63 // message it did not process 80 // message it did not process
64 void ProcessUnhandledAccelerator(const MSG& msg); 81 void ProcessUnhandledAccelerator(const MSG& msg);
65 82
66 // See TabContents::FocusThroughTabTraversal. Called from AutomationProvider. 83 // See TabContents::FocusThroughTabTraversal. Called from AutomationProvider.
67 void FocusThroughTabTraversal(bool reverse); 84 void FocusThroughTabTraversal(bool reverse);
68 85
69 // A helper method that tests whether the given window is an 86 // A helper method that tests whether the given window is an
70 // ExternalTabContainer window 87 // ExternalTabContainer window
71 static bool IsExternalTabContainer(HWND window); 88 static bool IsExternalTabContainer(HWND window);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // parameter. 137 // parameter.
121 virtual bool ExecuteContextMenuCommand(int command); 138 virtual bool ExecuteContextMenuCommand(int command);
122 139
123 // Show a dialog with HTML content. |delegate| contains a pointer to the 140 // Show a dialog with HTML content. |delegate| contains a pointer to the
124 // delegate who knows how to display the dialog (which file URL and JSON 141 // delegate who knows how to display the dialog (which file URL and JSON
125 // string input to use during initialization). |parent_window| is the window 142 // string input to use during initialization). |parent_window| is the window
126 // that should be parent of the dialog, or NULL for the default. 143 // that should be parent of the dialog, or NULL for the default.
127 virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, 144 virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate,
128 gfx::NativeWindow parent_window); 145 gfx::NativeWindow parent_window);
129 146
147 // Returns the ExternalTabContainer instance associated with the cookie
148 // passed in. It also erases the corresponding reference from the map.
149 // Returns NULL if we fail to find the cookie in the map.
150 static ExternalTabContainer* RemovePendingTab(intptr_t cookie);
130 151
131 protected: 152 protected:
132 // Overridden from views::WidgetWin: 153 // Overridden from views::WidgetWin:
154 virtual LRESULT OnCreate(LPCREATESTRUCT create_struct);
133 virtual void OnDestroy(); 155 virtual void OnDestroy();
156 virtual void OnFinalMessage(HWND window);
157
134 bool InitNavigationInfo(IPC::NavigationInfo* nav_info, 158 bool InitNavigationInfo(IPC::NavigationInfo* nav_info,
135 NavigationType::Type nav_type, 159 NavigationType::Type nav_type,
136 int relative_offset); 160 int relative_offset);
137 161
138 private: 162 private:
139 // Unhook the keystroke listener and notify about the closing TabContents.
140 // This function gets called from two places, which is fine.
141 // 1. OnFinalMessage
142 // 2. In the destructor.
143 void Uninitialize(HWND window);
144
145 // Helper function for processing keystokes coming back from the renderer 163 // Helper function for processing keystokes coming back from the renderer
146 // process. 164 // process.
147 bool ProcessUnhandledKeyStroke(HWND window, UINT message, WPARAM wparam, 165 bool ProcessUnhandledKeyStroke(HWND window, UINT message, WPARAM wparam,
148 LPARAM lparam); 166 LPARAM lparam);
149 167
150 TabContents* tab_contents_; 168 TabContents* tab_contents_;
151 scoped_refptr<AutomationProvider> automation_; 169 scoped_refptr<AutomationProvider> automation_;
152 170
153 NotificationRegistrar registrar_; 171 NotificationRegistrar registrar_;
154 172
(...skipping 20 matching lines...) Expand all
175 193
176 // whether top level URL requests are to be handled by the automation client. 194 // whether top level URL requests are to be handled by the automation client.
177 bool handle_top_level_requests_; 195 bool handle_top_level_requests_;
178 196
179 // Scoped browser object for this ExternalTabContainer instance. 197 // Scoped browser object for this ExternalTabContainer instance.
180 scoped_ptr<Browser> browser_; 198 scoped_ptr<Browser> browser_;
181 199
182 // A customized profile for automation specific needs. 200 // A customized profile for automation specific needs.
183 scoped_ptr<AutomationProfileImpl> automation_profile_; 201 scoped_ptr<AutomationProfileImpl> automation_profile_;
184 202
203 // Contains ExternalTabContainers that have not been connected to as yet.
204 static PendingTabs pending_tabs_;
205
185 DISALLOW_COPY_AND_ASSIGN(ExternalTabContainer); 206 DISALLOW_COPY_AND_ASSIGN(ExternalTabContainer);
186 }; 207 };
187 208
188 #endif // CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_ 209 #endif // CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_resource_message_filter.cc ('k') | chrome/browser/external_tab_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698