diff options
23 files changed, 170 insertions, 75 deletions
diff --git a/ceee/ie/common/chrome_frame_host.cc b/ceee/ie/common/chrome_frame_host.cc index 22d6184..77c0bc9 100644 --- a/ceee/ie/common/chrome_frame_host.cc +++ b/ceee/ie/common/chrome_frame_host.cc @@ -170,13 +170,6 @@ HRESULT ChromeFrameHost::GetSessionId(int* session_id) { CComQIPtr<IChromeFrameInternal> chrome_frame_internal_(chrome_frame_); if (chrome_frame_internal_) { return chrome_frame_internal_->getSessionId(session_id); - } else { - // This whole else should be removed when getSessionId gets committed to - // ChromeFrame. - if (session_id != NULL) { - *session_id = kInvalidChromeSessionId; - return S_OK; - } } } NOTREACHED(); diff --git a/ceee/ie/plugin/bho/browser_helper_object.cc b/ceee/ie/plugin/bho/browser_helper_object.cc index 6da154a..cc2be5e 100644 --- a/ceee/ie/plugin/bho/browser_helper_object.cc +++ b/ceee/ie/plugin/bho/browser_helper_object.cc @@ -523,12 +523,9 @@ bool BrowserHelperObject::EnsureTabId() { // At this point if tab_id_ is still invalid we have a problem. if (tab_id_ == kInvalidChromeSessionId) { - // TODO(hansl@google.com): uncomment the following code when the CF change - // has landed. - //// Something really bad happened. - //NOTREACHED(); - //return false; - tab_id_ = reinterpret_cast<int>(tab_window_); + // Something really bad happened. + NOTREACHED(); + return false; } CeeeWindowHandle handle = reinterpret_cast<CeeeWindowHandle>(tab_window_); diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 66d084a..280d916 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -357,14 +357,16 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void CreateExternalTab(const IPC::ExternalTabSettings& settings, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, - int* tab_handle); + int* tab_handle, + int* session_id); void ConnectExternalTab(uint64 cookie, bool allow, gfx::NativeWindow parent_window, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, - int* tab_handle); + int* tab_handle, + int* session_id); void NavigateInExternalTab( int handle, const GURL& url, const GURL& referrer, diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 7843c83..a988a2f 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -241,12 +241,13 @@ void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) { void AutomationProvider::CreateExternalTab( const IPC::ExternalTabSettings& settings, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, - int* tab_handle) { + int* tab_handle, int* session_id) { TRACE_EVENT_BEGIN("AutomationProvider::CreateExternalTab", 0, ""); *tab_handle = 0; *tab_container_window = NULL; *tab_window = NULL; + *session_id = -1; scoped_refptr<ExternalTabContainer> external_tab_container = new ExternalTabContainer(this, automation_resource_message_filter_); @@ -266,6 +267,7 @@ void AutomationProvider::CreateExternalTab( *tab_handle = external_tab_container->tab_handle(); *tab_container_window = external_tab_container->GetNativeView(); *tab_window = tab_contents->GetNativeView(); + *session_id = tab_contents->controller().session_id().id(); } else { external_tab_container->Uninitialize(); } @@ -378,12 +380,14 @@ void AutomationProvider::ConnectExternalTab( gfx::NativeWindow parent_window, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, - int* tab_handle) { + int* tab_handle, + int* session_id) { TRACE_EVENT_BEGIN("AutomationProvider::ConnectExternalTab", 0, ""); *tab_handle = 0; *tab_container_window = NULL; *tab_window = NULL; + *session_id = -1; scoped_refptr<ExternalTabContainer> external_tab_container = ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie)); @@ -400,6 +404,7 @@ void AutomationProvider::ConnectExternalTab( *tab_handle = external_tab_container->tab_handle(); *tab_container_window = external_tab_container->GetNativeView(); *tab_window = tab_contents->GetNativeView(); + *session_id = tab_contents->controller().session_id().id(); } else { external_tab_container->Uninitialize(); } diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index adadf68..d421859 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -428,11 +428,12 @@ IPC_BEGIN_MESSAGES(Automation) // hosted by an external process. // Request: // ExternalTabSettings - settings for external tab - IPC_SYNC_MESSAGE_ROUTED1_3(AutomationMsg_CreateExternalTab, + IPC_SYNC_MESSAGE_ROUTED1_4(AutomationMsg_CreateExternalTab, IPC::ExternalTabSettings /* settings*/, gfx::NativeWindow /* Tab container window */, gfx::NativeWindow /* Tab window */, - int /* Handle to the new tab */) + int /* Handle to the new tab */, + int /* Session Id of 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 @@ -1099,13 +1100,14 @@ IPC_BEGIN_MESSAGES(Automation) IPC::AttachExternalTabParams) // Sent when the automation client connects to an existing tab. - IPC_SYNC_MESSAGE_ROUTED3_3(AutomationMsg_ConnectExternalTab, + IPC_SYNC_MESSAGE_ROUTED3_4(AutomationMsg_ConnectExternalTab, uint64 /* cookie */, bool /* allow/block tab*/, gfx::NativeWindow /* parent window */, gfx::NativeWindow /* Tab container window */, gfx::NativeWindow /* Tab window */, - int /* Handle to the new tab */) + int /* Handle to the new tab */, + int /* Session Id of the new tab */) #if defined(OS_POSIX) // TODO(estade): this should be merged with the windows message of the same diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 3f6eb64..748ffc2 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -487,11 +487,13 @@ scoped_refptr<TabProxy> AutomationProxy::CreateExternalTab( gfx::NativeWindow* external_tab_container, gfx::NativeWindow* tab) { int handle = 0; + int session_id = 0; bool succeeded = Send(new AutomationMsg_CreateExternalTab(0, settings, external_tab_container, tab, - &handle)); + &handle, + &session_id)); if (!succeeded) { return NULL; } diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 7d8a432..e2e494c 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -774,10 +774,11 @@ void ExternalTabUITestMockClient::ConnectToExternalTab(gfx::NativeWindow parent, gfx::NativeWindow tab_container = NULL; gfx::NativeWindow tab_window = NULL; int tab_handle = 0; + int session_id = -1; IPC::SyncMessage* message = new AutomationMsg_ConnectExternalTab(0, attach_params.cookie, true, NULL, &tab_container, &tab_window, - &tab_handle); + &tab_handle, &session_id); channel_->Send(message); RECT rect; diff --git a/chrome_frame/cfproxy.h b/chrome_frame/cfproxy.h index bfcc998..513c2c5 100644 --- a/chrome_frame/cfproxy.h +++ b/chrome_frame/cfproxy.h @@ -157,9 +157,9 @@ class ChromeProxyDelegate { // Sync message responses. virtual void Completed_CreateTab(bool success, HWND chrome_wnd, - HWND tab_window, int tab_handle) = 0; + HWND tab_window, int tab_handle, int session_id) = 0; virtual void Completed_ConnectToTab(bool success, HWND chrome_window, - HWND tab_window, int tab_handle) = 0; + HWND tab_window, int tab_handle, int session_id) = 0; virtual void Completed_Navigate(bool success, enum AutomationMsg_NavigationResponseValues res) = 0; virtual void Completed_InstallExtension(bool success, diff --git a/chrome_frame/cfproxy_proxy.cc b/chrome_frame/cfproxy_proxy.cc index e03cb0e..5d6a780 100644 --- a/chrome_frame/cfproxy_proxy.cc +++ b/chrome_frame/cfproxy_proxy.cc @@ -181,7 +181,7 @@ void CFProxy::Tab_Navigate(int tab, const GURL& url, const GURL& referrer) { void CFProxy::CreateTab(ChromeProxyDelegate* delegate, const IPC::ExternalTabSettings& p) { - IPC::SyncMessage* m = new AutomationMsg_CreateExternalTab(0, p, 0, 0, 0); + IPC::SyncMessage* m = new AutomationMsg_CreateExternalTab(0, p, 0, 0, 0, 0); sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); SendIpcMessage(m); } @@ -189,14 +189,14 @@ void CFProxy::CreateTab(ChromeProxyDelegate* delegate, void CFProxy::ConnectTab(ChromeProxyDelegate* delegate, HWND hwnd, uint64 cookie) { IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(0, cookie, true, - hwnd, NULL, NULL, NULL); + hwnd, NULL, NULL, NULL, 0); sync_dispatcher_.QueueSyncMessage(m, delegate, NULL); SendIpcMessage(m); } void CFProxy::BlockTab(uint64 cookie) { IPC::SyncMessage* m = new AutomationMsg_ConnectExternalTab(0, cookie, false, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, 0); sync_dispatcher_.QueueSyncMessage(m, NULL, NULL); SendIpcMessage(m); } diff --git a/chrome_frame/cfproxy_support.cc b/chrome_frame/cfproxy_support.cc index 42e6a28..6b5224b 100644 --- a/chrome_frame/cfproxy_support.cc +++ b/chrome_frame/cfproxy_support.cc @@ -20,10 +20,10 @@ void DispatchReplyFail(uint32 type, SyncMessageContext* ctx) { switch (type) { case AutomationMsg_CreateExternalTab::ID: - delegate->Completed_CreateTab(false, NULL, NULL, NULL); + delegate->Completed_CreateTab(false, NULL, NULL, 0, 0); break; case AutomationMsg_ConnectExternalTab::ID: - delegate->Completed_ConnectToTab(false, NULL, NULL, NULL); + delegate->Completed_ConnectToTab(false, NULL, NULL, 0, 0); break; case AutomationMsg_InstallExtension::ID: delegate->Completed_InstallExtension(false, @@ -38,23 +38,23 @@ bool DispatchReplyOk(const IPC::Message* reply_msg, uint32 type, void* iter = IPC::SyncMessage::GetDataIterator(reply_msg); switch (type) { case AutomationMsg_CreateExternalTab::ID: { - // Tuple3<HWND, HWND, int> out; + // Tuple4<HWND, HWND, int, int> out; TupleTypes<AutomationMsg_CreateExternalTab::ReplyParam>::ValueTuple out; if (ReadParam(reply_msg, &iter, &out)) { DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); (*tab2delegate)[out.c] = delegate; - delegate->Completed_CreateTab(true, out.a, out.b, out.c); + delegate->Completed_CreateTab(true, out.a, out.b, out.c, out.d); } return true; } case AutomationMsg_ConnectExternalTab::ID: { - // Tuple3<HWND, HWND, int> out; + // Tuple4<HWND, HWND, int, int> out; TupleTypes<AutomationMsg_ConnectExternalTab::ReplyParam>::ValueTuple out; if (ReadParam(reply_msg, &iter, &out)) { DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); (*tab2delegate)[out.c] = delegate; - delegate->Completed_ConnectToTab(true, out.a, out.b, out.c); + delegate->Completed_ConnectToTab(true, out.a, out.b, out.c, out.d); } return true; } diff --git a/chrome_frame/cfproxy_test.cc b/chrome_frame/cfproxy_test.cc index 28ba8c6..5b2937c 100644 --- a/chrome_frame/cfproxy_test.cc +++ b/chrome_frame/cfproxy_test.cc @@ -33,10 +33,10 @@ struct MockChromeProxyDelegate : public ChromeProxyDelegate { MOCK_METHOD0(Disconnected, void()); MOCK_METHOD0(tab_handle, int()); - MOCK_METHOD4(Completed_CreateTab, void(bool success, HWND chrome_wnd, - HWND tab_window, int tab_handle)); - MOCK_METHOD4(Completed_ConnectToTab, void(bool success, HWND chrome_window, - HWND tab_window, int tab_handle)); + MOCK_METHOD5(Completed_CreateTab, void(bool success, HWND chrome_wnd, + HWND tab_window, int tab_handle, int session_id)); + MOCK_METHOD5(Completed_ConnectToTab, void(bool success, HWND chrome_window, + HWND tab_window, int tab_handle, int session_id)); MOCK_METHOD2(Completed_Navigate, void(bool success, enum AutomationMsg_NavigationResponseValues res)); MOCK_METHOD3(Completed_InstallExtension, void(bool success, @@ -274,7 +274,7 @@ TEST(ChromeProxy, ChannelError) { InvokeWithoutArgs(&connected, &base::WaitableEvent::Signal))); EXPECT_CALL(api.sender, Send(_)); - EXPECT_CALL(delegate, Completed_ConnectToTab(false, _, _, _)); + EXPECT_CALL(delegate, Completed_ConnectToTab(false, _, _, _, _)); EXPECT_CALL(api, CloseChannel(&api.sender)); EXPECT_CALL(delegate, PeerLost(_, ChromeProxyDelegate::CHANNEL_ERROR)); @@ -316,7 +316,16 @@ inline IPC::Message* CreateReply(M* m, const A& a, const B& b, const C& c) { } return r; } -} // namespace + +template <typename M, typename A, typename B, typename C, typename D> +inline IPC::Message* CreateReply(M* m, const A& a, const B& b, const C& c, + const D& d) { + IPC::Message* r = IPC::SyncMessage::GenerateReply(m); + if (r) { + M::WriteReplyParams(r, a, b, c, d); + } + return r; +}} // namespace DISABLE_RUNNABLE_METHOD_REFCOUNT(SyncMsgSender); TEST(SyncMsgSender, Deserialize) { @@ -329,12 +338,16 @@ TEST(SyncMsgSender, Deserialize) { TabsMap tab2delegate; SyncMsgSender queue(&tab2delegate); + const int kTabHandle = 6; + const int kSessionId = 8; + // Create some sync messages and their replies. AutomationMsg_InstallExtension m1(0, FilePath(L"c:\\awesome.x"), 0); - AutomationMsg_CreateExternalTab m2(0, IPC::ExternalTabSettings(), 0, 0, 0); + AutomationMsg_CreateExternalTab m2(0, IPC::ExternalTabSettings(), 0, 0, 0, 0); scoped_ptr<IPC::Message> r1(CreateReply(&m1, AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED)); - scoped_ptr<IPC::Message> r2(CreateReply(&m2, (HWND)1, (HWND)2, 6)); + scoped_ptr<IPC::Message> r2(CreateReply(&m2, (HWND)1, (HWND)2, kTabHandle, + kSessionId)); queue.QueueSyncMessage(&m1, &d1, NULL); queue.QueueSyncMessage(&m2, &d1, NULL); @@ -342,7 +355,8 @@ TEST(SyncMsgSender, Deserialize) { testing::InSequence s; EXPECT_CALL(d1, Completed_InstallExtension(true, AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED, NULL)); - EXPECT_CALL(d1, Completed_CreateTab(true, (HWND)1, (HWND)2, 6)); + EXPECT_CALL(d1, Completed_CreateTab(true, (HWND)1, (HWND)2, kTabHandle, + kSessionId)); // Execute replies in a worker thread. ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index def29b8..736c690 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -166,6 +166,7 @@ class ATL_NO_VTABLE ChromeFrameActivexBase : // NOLINT public com_util::IProvideClassInfo2Impl<class_id, DIID_DIChromeFrameEvents>, public com_util::IDispatchImpl<IChromeFrame>, + public IChromeFrameInternal, public IConnectionPointContainerImpl<T>, public ProxyDIChromeFrameEvents<T>, public IPropertyNotifySinkCP<T>, @@ -200,6 +201,7 @@ DECLARE_NOT_AGGREGATABLE(T) BEGIN_COM_MAP(ChromeFrameActivexBase) COM_INTERFACE_ENTRY(IChromeFrame) COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(IChromeFrameInternal) COM_INTERFACE_ENTRY(IViewObjectEx) COM_INTERFACE_ENTRY(IViewObject2) COM_INTERFACE_ENTRY(IViewObject) @@ -889,6 +891,19 @@ END_MSG_MAP() return S_OK; } + STDMETHOD(getSessionId)(int* session_id) { + DCHECK(automation_client_.get()); + DCHECK(session_id); + + if (!is_privileged_) { + DLOG(ERROR) << "Attempt to getSessionId in non-privileged mode"; + return E_ACCESSDENIED; + } + + *session_id = automation_client_->GetSessionId(); + return (*session_id) == -1 ? S_FALSE : S_OK; + } + STDMETHOD(registerBhoIfNeeded)() { return E_NOTIMPL; } diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index d50f26b..b05c32aa 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -571,6 +571,7 @@ ChromeFrameAutomationClient::ChromeFrameAutomationClient() proxy_factory_(g_proxy_factory.get()), handle_top_level_requests_(false), tab_handle_(-1), + session_id_(-1), external_tab_cookie_(0), url_fetcher_(NULL), url_fetcher_flags_(PluginUrlRequestManager::NOT_THREADSAFE), @@ -899,6 +900,10 @@ void ChromeFrameAutomationClient::GetEnabledExtensionsComplete( delete extension_directories; } +int ChromeFrameAutomationClient::GetSessionId() const { + return session_id_; +} + void ChromeFrameAutomationClient::OnChromeFrameHostMoved() { // Use a local var to avoid the small possibility of getting the tab_ // member be cleared while we try to use it. @@ -961,13 +966,13 @@ void ChromeFrameAutomationClient::CreateExternalTab() { 2); IPC::SyncMessage* message = - new AutomationMsg_CreateExternalTab(0, settings, NULL, NULL, NULL); + new AutomationMsg_CreateExternalTab(0, settings, NULL, NULL, 0, 0); automation_server_->SendAsAsync(message, new CreateExternalTabContext(this), this); } AutomationLaunchResult ChromeFrameAutomationClient::CreateExternalTabComplete( - HWND chrome_window, HWND tab_window, int tab_handle) { + HWND chrome_window, HWND tab_window, int tab_handle, int session_id) { if (!automation_server_) { // If we receive this notification while shutting down, do nothing. DLOG(ERROR) << "CreateExternalTabComplete called when automation server " @@ -984,6 +989,7 @@ AutomationLaunchResult ChromeFrameAutomationClient::CreateExternalTabComplete( tab_ = automation_server_->CreateTabProxy(tab_handle); tab_->AddObserver(this); tab_handle_ = tab_handle; + session_id_ = session_id; } return launch_result; } @@ -1030,7 +1036,7 @@ void ChromeFrameAutomationClient::LaunchComplete( // ExternalTab. IPC::SyncMessage* message = new AutomationMsg_ConnectExternalTab(0, external_tab_cookie_, true, - m_hWnd, NULL, NULL, NULL); + m_hWnd, NULL, NULL, NULL, 0); automation_server_->SendAsAsync(message, new CreateExternalTabContext(this), this); @@ -1367,7 +1373,7 @@ void ChromeFrameAutomationClient::BlockExternalTab(uint64 cookie) { // The host does not want this tab to be shown (due popup blocker). IPC::SyncMessage* message = new AutomationMsg_ConnectExternalTab(0, cookie, false, m_hWnd, - NULL, NULL, NULL); + NULL, NULL, NULL, 0); automation_server_->SendAsAsync(message, NULL, this); } diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 47b03c0..cb1b282 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -364,6 +364,9 @@ class ChromeFrameAutomationClient void* user_data, std::vector<FilePath>* extension_directories); + // Returns the session ID used to identify a Tab in Chrome. + virtual int GetSessionId() const; + virtual void OnChromeFrameHostMoved(); TabProxy* tab() const { return tab_.get(); } @@ -458,7 +461,8 @@ class ChromeFrameAutomationClient void CreateExternalTab(); AutomationLaunchResult CreateExternalTabComplete(HWND chrome_window, HWND tab_window, - int tab_handle); + int tab_handle, + int session_id); // Called in UI thread. Here we fire event to the client notifying for // the result of Initialize() method call. void InitializeComplete(AutomationLaunchResult result); @@ -529,6 +533,8 @@ class ChromeFrameAutomationClient bool handle_top_level_requests_; ProxyFactory* proxy_factory_; int tab_handle_; + // The SessionId used by Chrome as the id in the Javascript Tab object. + int session_id_; // Only used if we attach to an existing tab. uint64 external_tab_cookie_; diff --git a/chrome_frame/custom_sync_call_context.h b/chrome_frame/custom_sync_call_context.h index 9cbe3d6..6162213 100644 --- a/chrome_frame/custom_sync_call_context.h +++ b/chrome_frame/custom_sync_call_context.h @@ -85,15 +85,16 @@ class GetEnabledExtensionsContext class CreateExternalTabContext : public SyncMessageReplyDispatcher::SyncMessageCallContext { public: - typedef Tuple3<HWND, HWND, int> output_type; + typedef Tuple4<HWND, HWND, int, int> output_type; explicit CreateExternalTabContext(ChromeFrameAutomationClient* client) : client_(client) { } - void Completed(HWND chrome_window, HWND tab_window, int tab_handle) { + void Completed(HWND chrome_window, HWND tab_window, int tab_handle, + int session_id) { AutomationLaunchResult launch_result = client_->CreateExternalTabComplete(chrome_window, tab_window, - tab_handle); + tab_handle, session_id); client_->PostTask(FROM_HERE, NewRunnableMethod( client_.get(), diff --git a/chrome_frame/external_tab.cc b/chrome_frame/external_tab.cc index 4bfeff2..211b48d 100644 --- a/chrome_frame/external_tab.cc +++ b/chrome_frame/external_tab.cc @@ -194,7 +194,8 @@ void ExternalTabProxy::ChromeFrameHostMoved() { ////////////////////////////////////////////////////////////////////////// void ExternalTabProxy::UiCompleted_CreateTab(bool success, HWND chrome_window, - HWND tab_window, int tab_handle) { + HWND tab_window, int tab_handle, + int session_id) { if (success) { state_ = READY; tab_ = tab_handle; @@ -210,15 +211,16 @@ void ExternalTabProxy::UiCompleted_CreateTab(bool success, HWND chrome_window, } void ExternalTabProxy::Completed_CreateTab(bool success, HWND chrome_wnd, - HWND tab_window, int tab_handle) { + HWND tab_window, int tab_handle, + int session_id) { // in ipc_thread. ui_.PostTask(FROM_HERE, NewRunnableMethod(this, &ExternalTabProxy::UiCompleted_CreateTab, - success, chrome_wnd, tab_window, tab_handle)); + success, chrome_wnd, tab_window, tab_handle, session_id)); } void ExternalTabProxy::Completed_ConnectToTab(bool success, - HWND chrome_window, HWND tab_window, int tab_handle) { + HWND chrome_window, HWND tab_window, int tab_handle, int session_id) { CHECK(0); } diff --git a/chrome_frame/external_tab.h b/chrome_frame/external_tab.h index b68a9bf..cd8551a 100644 --- a/chrome_frame/external_tab.h +++ b/chrome_frame/external_tab.h @@ -127,9 +127,9 @@ class ExternalTabProxy : public CWindowImpl<ExternalTabProxy>, // Sync message responses. virtual void Completed_CreateTab(bool success, HWND chrome_wnd, - HWND tab_window, int tab_handle); // TODO(stoyan): Error_code + HWND tab_window, int tab_handle, int session_id); virtual void Completed_ConnectToTab(bool success, HWND chrome_window, - HWND tab_window, int tab_handle); + HWND tab_window, int tab_handle, int session_id); virtual void Completed_Navigate(bool success, enum AutomationMsg_NavigationResponseValues res); virtual void Completed_InstallExtension(bool success, @@ -181,7 +181,7 @@ class ExternalTabProxy : public CWindowImpl<ExternalTabProxy>, void UiConnected(ChromeProxy* proxy); void UiPeerLost(ChromeProxy* proxy, DisconnectReason reason); void UiCompleted_CreateTab(bool success, HWND chrome_window, - HWND tab_window, int tab_handle); + HWND tab_window, int tab_handle, int session_id); // With the present state of affairs the only response we can possibly handle // in the background IPC thread is Completed_CreateTab() where we can diff --git a/chrome_frame/external_tab_test.cc b/chrome_frame/external_tab_test.cc index 0e49f95..375e4fb 100644 --- a/chrome_frame/external_tab_test.cc +++ b/chrome_frame/external_tab_test.cc @@ -133,10 +133,11 @@ struct AsyncEventCreator { } void Fire_CompletedCreateTab(bool success, HWND chrome_wnd, HWND tab_window, - int tab_handle, base::TimeDelta delay) { + int tab_handle, int session_id, + base::TimeDelta delay) { ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_, &ChromeProxyDelegate::Completed_CreateTab, success, chrome_wnd, - tab_window, tab_handle), delay.InMilliseconds()); + tab_window, tab_handle, session_id), delay.InMilliseconds()); } void Fire_TabLoaded(const GURL& url, base::TimeDelta delay) { @@ -173,7 +174,7 @@ TEST(ExternalTabProxy, CancelledCreateTab) { EXPECT_CALL(*proxy, RemoveDelegate(_)).WillOnce(DoAll( InvokeWithoutArgs(CreateFunctor(&async_events, &AsyncEventCreator::Fire_CompletedCreateTab, false, HWND(0), HWND(0), - 0, base::TimeDelta::FromMilliseconds(0))), + 0, 0, base::TimeDelta::FromMilliseconds(0))), InvokeWithoutArgs(CreateFunctor(&async_events, &AsyncEventCreator::Fire_Disconnected, base::TimeDelta::FromMilliseconds(0))), @@ -216,7 +217,7 @@ TEST(ExternalTabProxy, NavigateAfterCreate) { .WillOnce(DoAll( InvokeWithoutArgs(CreateFunctor(&async_events, &AsyncEventCreator::Fire_CompletedCreateTab, - true, HWND(0), HWND(0), 7, base::TimeDelta::FromMilliseconds(9))), + true, HWND(0), HWND(0), 7, 0, base::TimeDelta::FromMilliseconds(9))), InvokeWithoutArgs(CreateFunctor(&async_events, &AsyncEventCreator::Fire_TabLoaded, real_url, base::TimeDelta::FromMilliseconds(150))))); diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc index a77b023..7e8f317 100644 --- a/chrome_frame/test/automation_client_mock.cc +++ b/chrome_frame/test/automation_client_mock.cc @@ -70,13 +70,15 @@ MATCHER_P(EqNavigationInfoUrl, url, "IPC::NavigationInfo matcher") { } // Could be implemented as MockAutomationProxy member (we have WithArgs<>!) -ACTION_P3(HandleCreateTab, tab_handle, external_tab_container, tab_wnd) { +ACTION_P4(HandleCreateTab, tab_handle, external_tab_container, tab_wnd, + session_id) { // arg0 - message // arg1 - callback // arg2 - key CreateExternalTabContext::output_type input_args(tab_wnd, external_tab_container, - tab_handle); + tab_handle, + session_id); CreateExternalTabContext* context = reinterpret_cast<CreateExternalTabContext*>(arg1); DispatchToMethod(context, &CreateExternalTabContext::Completed, input_args); @@ -253,7 +255,7 @@ TEST_F(CFACMockTest, MockedCreateTabOk) { EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), testing::NotNull(), _)) - .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2)); + .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)); EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_))) .WillOnce(Return(tab_)); @@ -287,7 +289,8 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) { EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), testing::NotNull(), _)) - .Times(1).WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd)); + .Times(1).WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd, + 99)); EXPECT_CALL(mock_proxy_, CreateTabProxy(_)).Times(0); @@ -348,9 +351,9 @@ TEST_F(CFACMockTest, OnChannelError) { EXPECT_CALL(proxy, SendAsAsync(testing::Property( &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), testing::NotNull(), _)).Times(3) - .WillOnce(HandleCreateTab(tab_handle_, h1, h2)) - .WillOnce(HandleCreateTab(tab_handle_ * 2, h1, h2)) - .WillOnce(HandleCreateTab(tab_handle_ * 3, h1, h2)); + .WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)) + .WillOnce(HandleCreateTab(tab_handle_ * 2, h1, h2, 100)) + .WillOnce(HandleCreateTab(tab_handle_ * 3, h1, h2, 101)); SetAutomationServerOk(3); @@ -428,7 +431,7 @@ TEST_F(CFACMockTest, NavigateTwiceAfterInitToSameUrl) { EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), testing::NotNull(), _)) - .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2)); + .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)); EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_))) .WillOnce(Return(tab_)); diff --git a/ipc/ipc_message_impl_macros.h b/ipc/ipc_message_impl_macros.h index a9c38bd..dfa7c91 100644 --- a/ipc/ipc_message_impl_macros.h +++ b/ipc/ipc_message_impl_macros.h @@ -84,6 +84,7 @@ #undef IPC_SYNC_MESSAGE_ROUTED3_1 #undef IPC_SYNC_MESSAGE_ROUTED3_2 #undef IPC_SYNC_MESSAGE_ROUTED3_3 +#undef IPC_SYNC_MESSAGE_ROUTED3_4 #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 #undef IPC_SYNC_MESSAGE_ROUTED4_2 @@ -575,6 +576,20 @@ \ IPC_SYNC_MESSAGE_DTOR_AND_LOG(msg_class) +#define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, \ + type3_in, type1_out, type2_out, \ + type3_out, type4_out) \ + msg_class::msg_class(int routing_id, const type1_in& arg1, \ + const type2_in& arg2, const type3_in& arg3, \ + type1_out* arg4, type2_out* arg5, \ + type3_out* arg6, type4_out* arg7) \ + : IPC::MessageWithReply<Tuple3<type1_in, type2_in, type3_in>, \ + Tuple4<type1_out&, type2_out&, type3_out&, type4_out&> >( \ + routing_id, ID, MakeRefTuple(arg1, arg2, arg3), \ + MakeRefTuple(*arg4, *arg5, *arg6, *arg7)) {} \ + \ + IPC_SYNC_MESSAGE_DTOR_AND_LOG(msg_class) + #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, \ type3_in, type4_in) \ msg_class::msg_class(int routing_id, const type1_in& arg1, \ diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h index 39c4e38..6fd789e 100644 --- a/ipc/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -44,7 +44,8 @@ #ifndef MESSAGES_INTERNAL_FILE -#error This file should only be included by X_messages.h, which needs to define MESSAGES_INTERNAL_FILE first. +#error This file should only be included by X_messages.h, which needs to define\ + MESSAGES_INTERNAL_FILE first. #endif // Trick scons and xcode into seeing the possible real dependencies since they @@ -133,6 +134,7 @@ #undef IPC_SYNC_MESSAGE_ROUTED3_1 #undef IPC_SYNC_MESSAGE_ROUTED3_2 #undef IPC_SYNC_MESSAGE_ROUTED3_3 +#undef IPC_SYNC_MESSAGE_ROUTED3_4 #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 #undef IPC_SYNC_MESSAGE_ROUTED4_2 @@ -296,6 +298,9 @@ #define IPC_SYNC_MESSAGE_ROUTED3_3(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out) \ msg_class##__ID, +#define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out, type4_out) \ + msg_class##__ID, + #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type4_in) \ msg_class##__ID, @@ -368,7 +373,8 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ break; #define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \ - IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, _IpcMessageHandlerClass::member_func) + IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, this, \ + _IpcMessageHandlerClass::member_func) #define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \ case msg_class::ID: \ @@ -454,6 +460,7 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \ #undef IPC_SYNC_MESSAGE_ROUTED3_1 #undef IPC_SYNC_MESSAGE_ROUTED3_2 #undef IPC_SYNC_MESSAGE_ROUTED3_3 +#undef IPC_SYNC_MESSAGE_ROUTED3_4 #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 #undef IPC_SYNC_MESSAGE_ROUTED4_2 @@ -475,7 +482,8 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_BEGIN_MESSAGES(label) \ - void label##MsgLog(uint32 type, std::string* name, const IPC::Message* msg, std::string* params) { \ + void label##MsgLog(uint32 type, std::string* name, const IPC::Message* msg, \ + std::string* params) { \ switch (type) { #define IPC_END_MESSAGES(label) \ @@ -641,6 +649,9 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_SYNC_MESSAGE_ROUTED3_3(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out) \ IPC_MESSAGE_LOG(msg_class) +#define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out, type4_out) \ + IPC_MESSAGE_LOG(msg_class) + #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type4_in) \ IPC_MESSAGE_LOG(msg_class) @@ -719,6 +730,7 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #undef IPC_SYNC_MESSAGE_ROUTED3_1 #undef IPC_SYNC_MESSAGE_ROUTED3_2 #undef IPC_SYNC_MESSAGE_ROUTED3_3 +#undef IPC_SYNC_MESSAGE_ROUTED3_4 #undef IPC_SYNC_MESSAGE_ROUTED4_0 #undef IPC_SYNC_MESSAGE_ROUTED4_1 #undef IPC_SYNC_MESSAGE_ROUTED4_2 @@ -782,7 +794,8 @@ LogFunction g_log_function_mapping[LastMsgIndex]; #define IPC_MESSAGE_CONTROL5(msg_class, type1, type2, type3, type4, type5) \ class msg_class : \ - public IPC::MessageWithTuple< Tuple5<type1, type2, type3, type4, type5> > { \ + public IPC::MessageWithTuple< Tuple5<type1, type2, type3, type4, \ + type5> > { \ public: \ enum { ID = msg_class##__ID }; \ msg_class(const type1& arg1, const type2& arg2, \ @@ -862,7 +875,7 @@ LogFunction g_log_function_mapping[LastMsgIndex]; }; #define IPC_SYNC_MESSAGE_CONTROL0_1(msg_class, type1_out) \ - class msg_class : public IPC::MessageWithReply<Tuple0, Tuple1<type1_out&> > { \ + class msg_class : public IPC::MessageWithReply<Tuple0, Tuple1<type1_out&> > {\ public: \ enum { ID = msg_class##__ID }; \ msg_class(type1_out* arg1); \ @@ -1216,6 +1229,17 @@ LogFunction g_log_function_mapping[LastMsgIndex]; static void Log(const Message* msg, std::string* l); \ }; +#define IPC_SYNC_MESSAGE_ROUTED3_4(msg_class, type1_in, type2_in, type3_in, type1_out, type2_out, type3_out, type4_out) \ + class msg_class : \ + public IPC::MessageWithReply<Tuple3<type1_in, type2_in, type3_in>, \ + Tuple4<type1_out&, type2_out&, type3_out&, type4_out&> > { \ + public: \ + enum { ID = msg_class##__ID }; \ + msg_class(int routing_id, const type1_in& arg1, const type2_in& arg2, const type3_in& arg3, type1_out* arg4, type2_out* arg5, type3_out* arg6, type4_out* arg7); \ + ~msg_class(); \ + static void Log(const Message* msg, std::string* l); \ + }; + #define IPC_SYNC_MESSAGE_ROUTED4_0(msg_class, type1_in, type2_in, type3_in, type4_in) \ class msg_class : \ public IPC::MessageWithReply<Tuple4<type1_in, type2_in, type3_in, type4_in>, \ diff --git a/ipc/ipc_sync_message_unittest.cc b/ipc/ipc_sync_message_unittest.cc index 506f4c0..d214cfc 100644 --- a/ipc/ipc_sync_message_unittest.cc +++ b/ipc/ipc_sync_message_unittest.cc @@ -136,6 +136,7 @@ class TestMessageReceiver { IPC_MESSAGE_HANDLER(Msg_R_3_1, On_3_1) IPC_MESSAGE_HANDLER(Msg_R_3_2, On_3_2) IPC_MESSAGE_HANDLER(Msg_R_3_3, On_3_3) + IPC_MESSAGE_HANDLER(Msg_R_3_4, On_3_4) IPC_END_MESSAGE_MAP() } diff --git a/ipc/ipc_sync_message_unittest.h b/ipc/ipc_sync_message_unittest.h index 1aa857a..d247428 100644 --- a/ipc/ipc_sync_message_unittest.h +++ b/ipc/ipc_sync_message_unittest.h @@ -104,4 +104,9 @@ IPC_BEGIN_MESSAGES(Test) IPC_SYNC_MESSAGE_ROUTED3_3(Msg_R_3_3, int, std::string, bool, std::string, int, bool) + // in1 must be true, in2 must be 3, in3 must be "3_4", out1 is 34, out2 is + // true, out3 is "3_4", out4 is false + IPC_SYNC_MESSAGE_ROUTED3_4(Msg_R_3_4, bool, int, std::string, int, bool, + std::string, bool) + IPC_END_MESSAGES(Test) |