diff options
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 33 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 17 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_uitest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 16 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 9 | ||||
-rw-r--r-- | chrome/common/ipc_message_utils.h | 31 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages.h | 42 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 40 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 19 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 11 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 39 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 11 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 5 |
13 files changed, 142 insertions, 143 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 49bd64f..36e348d 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -999,8 +999,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, HideInterstitialPage) #if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_SetAcceleratorsForTab, - SetAcceleratorsForTab) IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, ProcessUnhandledAccelerator) #endif @@ -2383,20 +2381,19 @@ void AutomationProvider::CloseBrowserAsync(int browser_handle) { #if defined(OS_WIN) // TODO(port): Remove windowsisms. -void AutomationProvider::CreateExternalTab(HWND parent, - const gfx::Rect& dimensions, - unsigned int style, - bool incognito, - HWND* tab_container_window, - HWND* tab_window, - int* tab_handle) { +void AutomationProvider::CreateExternalTab( + const IPC::ExternalTabSettings& settings, + gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, + int* tab_handle) { *tab_handle = 0; *tab_container_window = NULL; *tab_window = NULL; ExternalTabContainer* external_tab_container = new ExternalTabContainer(this, automation_resource_message_filter_); - Profile* profile = incognito? profile_->GetOffTheRecordProfile() : profile_; - external_tab_container->Init(profile, parent, dimensions, style); + Profile* profile = settings.is_off_the_record ? + profile_->GetOffTheRecordProfile() : profile_; + external_tab_container->Init(profile, settings.parent, settings.dimensions, + settings.style, settings.load_requests_via_automation); TabContents* tab_contents = external_tab_container->tab_contents(); if (tab_contents) { *tab_handle = tab_tracker_->Add(&tab_contents->controller()); @@ -2422,20 +2419,6 @@ void AutomationProvider::NavigateInExternalTab( } #if defined(OS_WIN) -// TODO(port): remove windowisms. -void AutomationProvider::SetAcceleratorsForTab(int handle, - HACCEL accel_table, - int accel_entry_count, - bool* status) { - *status = false; - - ExternalTabContainer* external_tab = GetExternalTabForHandle(handle); - if (external_tab) { - external_tab->SetAccelerators(accel_table, accel_entry_count); - *status = true; - } -} - void AutomationProvider::ProcessUnhandledAccelerator( const IPC::Message& message, int handle, const MSG& msg) { ExternalTabContainer* external_tab = GetExternalTabForHandle(handle); diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 8c57e7a..ed23671 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -37,6 +37,7 @@ struct AutomationMsg_Find_Params; namespace IPC { struct Reposition_Params; +struct ExternalTabSettings; } class LoginHandler; @@ -289,14 +290,10 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, IPC::Message* reply_message); void HideInterstitialPage(int tab_handle, bool* success); -// TODO(port): remove windowisms. -#if defined(OS_WIN) - void CreateExternalTab(HWND parent, const gfx::Rect& dimensions, - unsigned int style, bool incognito, - HWND* tab_container_window, - HWND* tab_window, + void CreateExternalTab(const IPC::ExternalTabSettings& settings, + gfx::NativeWindow* tab_container_window, + gfx::NativeWindow* tab_window, int* tab_handle); -#endif // defined(OS_WIN) void NavigateInExternalTab( int handle, const GURL& url, @@ -318,12 +315,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // TODO(port): remove windowisms. #if defined(OS_WIN) - // This sets the keyboard accelerators to be used by an externally - // hosted tab. This call is not valid on a regular tab hosted within - // Chrome. - void SetAcceleratorsForTab(int handle, HACCEL accel_table, - int accel_entry_count, bool* status); - void OnTabReposition(int tab_handle, const IPC::Reposition_Params& params); void OnForwardContextMenuCommandToChrome(int tab_handle, int command); diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index 359ba9a..6d7bc8c 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -54,10 +54,18 @@ class ExtensionUITest : public ParentTestType { } void TestWithURL(const GURL& url) { + const IPC::ExternalTabSettings settings = { + NULL, + gfx::Rect(), + WS_POPUP, + false, + false + }; + HWND external_tab_container = NULL; HWND tab_wnd = NULL; - scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(NULL, - gfx::Rect(), WS_POPUP, false, &external_tab_container, &tab_wnd)); + scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(settings, + &external_tab_container, &tab_wnd)); ASSERT_TRUE(tab != NULL); ASSERT_NE(FALSE, ::IsWindow(external_tab_container)); DoAdditionalPreNavigateSetup(tab.get()); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index a2d71b5..acc6e9d 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -27,15 +27,10 @@ static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; -// TODO(sanjeevr): The external_accel_table_ and external_accel_entry_count_ -// member variables are now obsolete and we don't use them. -// We need to remove them. ExternalTabContainer::ExternalTabContainer( AutomationProvider* automation, AutomationResourceMessageFilter* filter) : automation_(automation), tab_contents_(NULL), - external_accel_table_(NULL), - external_accel_entry_count_(0), tab_contents_container_(NULL), tab_handle_(0), ignore_next_load_notification_(false), @@ -50,12 +45,15 @@ ExternalTabContainer::~ExternalTabContainer() { bool ExternalTabContainer::Init(Profile* profile, HWND parent, const gfx::Rect& bounds, - DWORD style) { + DWORD style, + bool load_requests_via_automation) { if (IsWindow()) { NOTREACHED(); return false; } + load_requests_via_automation_ = load_requests_via_automation; + set_window_style(WS_POPUP); views::WidgetWin::Init(NULL, bounds); if (!IsWindow()) { @@ -117,12 +115,6 @@ bool ExternalTabContainer::Init(Profile* profile, return true; } -void ExternalTabContainer::SetAccelerators(HACCEL accel_table, - int accel_table_entry_count) { - external_accel_table_ = accel_table; - external_accel_entry_count_ = accel_table_entry_count; -} - void ExternalTabContainer::ProcessUnhandledAccelerator(const MSG& msg) { // We just received an accelerator key that we had sent to external host // back. Since the external host was not interested in handling this, we diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index d40a0f4..64accf5 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -39,10 +39,8 @@ class ExternalTabContainer : public TabContentsDelegate, bool Init(Profile* profile, HWND parent, const gfx::Rect& bounds, - DWORD style); - - // Sets the keyboard accelerators needed by the external host - void SetAccelerators(HACCEL accel_table, int accel_table_entry_count); + DWORD style, + bool load_requests_via_automation); // This is invoked when the external host reflects back to us a keyboard // message it did not process @@ -126,9 +124,6 @@ class ExternalTabContainer : public TabContentsDelegate, NotificationRegistrar registrar_; - // The accelerator table of the external host. - HACCEL external_accel_table_; - unsigned int external_accel_entry_count_; // A view to handle focus cycling TabContentsContainer* tab_contents_container_; diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 516a432d..ee199e2 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/format_macros.h" +#include "base/gfx/native_widget_types.h" #include "base/string16.h" #include "base/string_util.h" #include "base/tuple.h" @@ -610,21 +611,6 @@ struct ParamTraits<HCURSOR> { }; template <> -struct ParamTraits<HWND> { - typedef HWND param_type; - static void Write(Message* m, const param_type& p) { - m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); - } - static bool Read(const Message* m, void** iter, param_type* r) { - DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); - return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"0x%X", p)); - } -}; - -template <> struct ParamTraits<HACCEL> { typedef HACCEL param_type; static void Write(Message* m, const param_type& p) { @@ -699,6 +685,21 @@ struct ParamTraits<gfx::Size> { static void Log(const param_type& p, std::wstring* l); }; +template <> +struct ParamTraits<gfx::NativeWindow> { + typedef gfx::NativeWindow param_type; + static void Write(Message* m, const param_type& p) { + m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); + } + static bool Read(const Message* m, void** iter, param_type* r) { + DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); + return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"0x%X", p)); + } +}; + #if defined(OS_POSIX) // FileDescriptors may be serialised over IPC channels on POSIX. On the // receiving side, the FileDescriptor is a valid duplicate of the file diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index f19a74f..dd17017 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" +#include "base/gfx/rect.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/security_style.h" #include "chrome/common/ipc_message_utils.h" @@ -295,6 +296,47 @@ struct ParamTraits<AutomationURLResponse> { } }; +struct ExternalTabSettings { + gfx::NativeWindow parent; + gfx::Rect dimensions; + unsigned int style; + bool is_off_the_record; + bool load_requests_via_automation; +}; + +// Traits for ExternalTabSettings structure to pack/unpack. +template <> +struct ParamTraits<ExternalTabSettings> { + typedef ExternalTabSettings param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.parent); + WriteParam(m, p.dimensions); + WriteParam(m, p.style); + WriteParam(m, p.is_off_the_record); + WriteParam(m, p.load_requests_via_automation); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->parent) && + ReadParam(m, iter, &p->dimensions) && + ReadParam(m, iter, &p->style) && + ReadParam(m, iter, &p->is_off_the_record) && + ReadParam(m, iter, &p->load_requests_via_automation); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.parent, l); + l->append(L", "); + LogParam(p.dimensions, l); + l->append(L", "); + LogParam(p.style, l); + l->append(L", "); + LogParam(p.is_off_the_record, l); + l->append(L", "); + LogParam(p.load_requests_via_automation, l); + l->append(L")"); + } +}; + } // namespace IPC #define MESSAGES_INTERNAL_FILE \ diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index ac1b7deb..15528c2 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -409,25 +409,15 @@ IPC_BEGIN_MESSAGES(Automation) // associated for, as defined in chrome/views/event.h IPC_MESSAGE_ROUTED3(AutomationMsg_WindowKeyPress, int, wchar_t, int) -#if defined(OS_WIN) - // TODO(port): Port these messages. - // // This message notifies the AutomationProvider to create a tab which is // hosted by an external process. // Request: - // HWND - handle to a window acting as a parent/owner for the new tab. - // gfx::Rect - initial dimensions. - // style - window style to be used at the time of cration. - // incognito - use off-the-record profile - IPC_SYNC_MESSAGE_ROUTED4_3(AutomationMsg_CreateExternalTab, - HWND /* owner_or_parent*/, - gfx::Rect /* dimensions */, - unsigned int /* style */, - bool /* off-the-record profile */, - HWND, // Tab container HWND - HWND, // Tab HWND - int /* Handle to the new tab */) -#endif // defined(OS_WIN) + // ExternalTabSettings - settings for external tab + IPC_SYNC_MESSAGE_ROUTED1_3(AutomationMsg_CreateExternalTab, + IPC::ExternalTabSettings /* settings*/, + gfx::NativeWindow /* Tab container window */, + gfx::NativeWindow /* Tab window */, + int /* Handle to the new tab */) // This message notifies the AutomationProvider to navigate to a specified // url in the external tab with given handle. The first parameter is the @@ -493,21 +483,15 @@ IPC_BEGIN_MESSAGES(Automation) bool) IPC_MESSAGE_ROUTED1(AutomationMsg_CloseBrowserRequestAsync, int) + + // Unused. + // Response: + // None expected + IPC_MESSAGE_ROUTED1(AutomationMsg_Unused, int) + #if defined(OS_WIN) // TODO(port): Port these messages. // - // This message sets the keyboard accelarators to be used by an externally - // hosted tab. This call is not valid on a regular tab hosted within - // Chrome. - // Request: - // - int: handle of the tab - // - HACCEL: The accelerator table to be set - // - int: The number of entries in the accelerator table - // Response: - // -bool: whether the operation was successful. - IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetAcceleratorsForTab, int, HACCEL, - int, bool) - // This message is an outgoing message from Chrome to an external host. // It is a request to process a keyboard accelerator. // Request: diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 2d4fe5b..a1df2d8 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -496,17 +496,13 @@ bool AutomationProxy::OpenNewBrowserWindow(bool show) { return Send(new AutomationMsg_OpenNewBrowserWindow(0, show)); } -#if defined(OS_WIN) -// TODO(port): Replace HWNDs. -scoped_refptr<TabProxy> AutomationProxy::CreateExternalTab(HWND parent, - const gfx::Rect& dimensions, unsigned int style, bool incognito, - HWND* external_tab_container, HWND* tab) { - IPC::Message* response = NULL; +scoped_refptr<TabProxy> AutomationProxy::CreateExternalTab( + const IPC::ExternalTabSettings& settings, + gfx::NativeWindow* external_tab_container, + gfx::NativeWindow* tab) { int handle = 0; - bool succeeded = - Send(new AutomationMsg_CreateExternalTab(0, parent, dimensions, style, - incognito, + Send(new AutomationMsg_CreateExternalTab(0, settings, external_tab_container, tab, &handle)); @@ -514,11 +510,14 @@ scoped_refptr<TabProxy> AutomationProxy::CreateExternalTab(HWND parent, return NULL; } +#if defined(OS_WIN) DCHECK(IsWindow(*external_tab_container)); +#else // defined(OS_WIN) + DCHECK(*external_tab_container); +#endif // defined(OS_WIN) DCHECK(tracker_->GetResource(handle) == NULL); return new TabProxy(this, tracker_.get(), handle); } -#endif // defined(OS_WIN) template <class T> scoped_refptr<T> AutomationProxy::ProxyObjectFromHandle( int handle) { diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 2271f83..ffbf39d 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -191,16 +191,13 @@ class AutomationProxy : public IPC::Channel::Listener, // the tracker. void InvalidateHandle(const IPC::Message& message); -#if defined(OS_WIN) - // TODO(port): Enable when we can replace HWND. - // Creates a tab that can hosted in an external process. The function // returns a TabProxy representing the tab as well as a window handle // that can be reparented in another process. - scoped_refptr<TabProxy> CreateExternalTab(HWND parent, - const gfx::Rect& dimensions, unsigned int style, bool incognito, - HWND* external_tab_container, HWND* tab); -#endif // defined(OS_WIN) + scoped_refptr<TabProxy> CreateExternalTab( + const IPC::ExternalTabSettings& settings, + gfx::NativeWindow* external_tab_container, + gfx::NativeWindow* tab); int command_execution_timeout_ms() const { return static_cast<int>(command_execution_timeout_.InMilliseconds()); diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 261bdfc..eeedf20 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -767,10 +767,18 @@ void AutomationProxyForExternalTab::OnForwardMessageToExternalHost( } TEST_F(ExternalTabTestType, CreateExternalTab) { + const IPC::ExternalTabSettings settings = { + NULL, + gfx::Rect(), + WS_POPUP, + false, + false + }; HWND external_tab_container = NULL; HWND tab_wnd = NULL; - scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), - WS_POPUP, false, &external_tab_container, &tab_wnd)); + + scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(settings, + &external_tab_container, &tab_wnd)); EXPECT_TRUE(tab != NULL); EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); if (tab != NULL) { @@ -783,14 +791,21 @@ TEST_F(ExternalTabTestType, CreateExternalTab) { } TEST_F(ExternalTabTestType, IncognitoMode) { + IPC::ExternalTabSettings settings = { + NULL, + gfx::Rect(), + WS_POPUP, + true, + false + }; HWND external_tab_container = NULL; HWND tab_wnd = NULL; GURL url("http://anatomyofmelancholy.net"); std::string value_result; // Create incognito tab - scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), - WS_POPUP, true, &external_tab_container, &tab_wnd)); + scoped_refptr<TabProxy> tab(automation()->CreateExternalTab(settings, + &external_tab_container, &tab_wnd)); EXPECT_TRUE(tab->SetCookie(url, "robert=burton; " "expires=Thu, 13 Oct 2011 05:04:03 UTC;")); EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); @@ -803,8 +818,9 @@ TEST_F(ExternalTabTestType, IncognitoMode) { external_tab_container = NULL; tab_wnd = NULL; LaunchBrowserAndServer(); - tab = automation()->CreateExternalTab(NULL, gfx::Rect(), - WS_POPUP, false, &external_tab_container, &tab_wnd); + settings.is_off_the_record = false; + tab = automation()->CreateExternalTab(settings, &external_tab_container, + &tab_wnd); EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); EXPECT_EQ("", value_result); } @@ -813,10 +829,17 @@ TEST_F(ExternalTabTestType, ExternalTabPostMessage) { AutomationProxyForExternalTab* proxy = static_cast<AutomationProxyForExternalTab*>(automation()); + IPC::ExternalTabSettings settings = { + NULL, + gfx::Rect(), + WS_POPUP, + false, + false + }; HWND external_tab_container = NULL; HWND tab_wnd = NULL; - scoped_refptr<TabProxy> tab(proxy->CreateExternalTab(NULL, gfx::Rect(), - WS_POPUP, false, &external_tab_container, &tab_wnd)); + scoped_refptr<TabProxy> tab(proxy->CreateExternalTab(settings, + &external_tab_container, &tab_wnd)); EXPECT_TRUE(tab != NULL); EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); if (tab != NULL) { diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 8d8ebf7..89bbf26 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -451,17 +451,6 @@ bool TabProxy::Close(bool wait_until_closed) { #if defined(OS_WIN) // TODO(port): Remove windowsisms. -bool TabProxy::SetAccelerators(HACCEL accel_table, - int accel_table_entry_count) { - if (!is_valid()) - return false; - - bool succeeded = false; - sender_->Send(new AutomationMsg_SetAcceleratorsForTab( - 0, handle_, accel_table, accel_table_entry_count, &succeeded)); - return succeeded; -} - bool TabProxy::ProcessUnhandledAccelerator(const MSG& msg) { if (!is_valid()) return false; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 200c5f9..a04f496 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -215,11 +215,6 @@ class TabProxy : public AutomationResourceProxy { #if defined(OS_WIN) // TODO(port): Use something portable. - // This sets the keyboard accelerators to be used by an externally - // hosted tab. This call is not valid on a regular tab hosted within - // Chrome. - bool SetAccelerators(HACCEL accel_table, int accel_table_entry_count); - // The container of an externally hosted tab calls this to reflect any // accelerator keys that it did not process. This gives the tab a chance // to handle the keys |