diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-28 21:46:11 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-28 21:46:11 +0000 |
commit | ecf59c793327fd2dcba719a4160a37147b8be668 (patch) | |
tree | 390565b6d99337eebde69eadbd7024e41202e600 | |
parent | 19106891c09d31ccc686edaa5919f26d737f7c7e (diff) | |
download | chromium_src-ecf59c793327fd2dcba719a4160a37147b8be668.zip chromium_src-ecf59c793327fd2dcba719a4160a37147b8be668.tar.gz chromium_src-ecf59c793327fd2dcba719a4160a37147b8be668.tar.bz2 |
Minimal Chrome Frame with Aura.
It builds and runs, but not a whole lot else. This change includes:
* ChromeFrameAutomationProvider is now OS_WIN only. In practice, this
has been the case for some time. Now it's formalized by giving the
implementation files the _win suffix.
* Automation messages and datatypes used exclusively by Chrome Frame now
use HWND directly rather than a toolkit-specific gfx typedef of one
since the requirement is that an actual HWND be sent over the
channel. A change in toolkit (e.g., switching to Aura) must not change
this. As a consequence of this change, some automation types and
messages are now only defined for OS_WIN builds.
* ExternalTabContainerWin is no longer derived from a NativeWidget type
(this was previously the case so that the ETCW could be notified of NW
lifecycle events). Now, in contrast, ETCW registers itself as an
observer of its Widget. Two additional lifecycle methods have been
added to WidgetObserver: OnWidgetCreated and OnWidgetDestroyed.
* ExternalTabContianerWin initializes its Widget with an instance of
DesktopNativeWidgetAura when use_aura.
* A special note about HWND IPC marshaling: this change adds a type
mapping from HWND to a generic HANDLE in ipc_message_utils.h, which
allows for the removal of a hack in content_message_generator.h to
marshal HWNDs.
This change reverts all of:
* r178752 -- Remove CF from all.gyp targets if use_aura is defined.
* r164590 -- Remove setup -> Chrome Frame dependency. Make it possible
to build an installer for Aura.
and portions of:
* r99993 -- Get chrome to link with USE_AURA
* r99787 -- Preliminary work to allow Chrome to build with USE_AURA.
BUG=171018
TEST=chrome_frame_tests provides good coverage in non-Aura builds.
Review URL: https://chromiumcodereview.appspot.com/12220101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185328 0039d316-1c4b-4281-b951-d872f2087c98
26 files changed, 207 insertions, 246 deletions
diff --git a/build/all.gyp b/build/all.gyp index ddb6558..dfc3811 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -258,15 +258,14 @@ '../chrome_frame/chrome_frame.gyp:chrome_frame_tests', '../chrome_frame/chrome_frame.gyp:chrome_frame_unittests', ] - }], # target_arch!="x64" - ['use_aura==1 or target_arch=="x64"', { + }, { # target_arch!="x64" 'dependencies!': [ '../chrome_frame/chrome_frame.gyp:npchrome_frame', ], 'defines': [ 'OMIT_CHROME_FRAME', ], - }], # use_aura==1 or target_arch=="x64" + }], # target_arch=="x64" ], }], ['OS=="linux"', { @@ -579,15 +578,14 @@ '../chrome_frame/chrome_frame.gyp:chrome_frame_tests', '../chrome_frame/chrome_frame.gyp:chrome_frame_unittests', ] - }], # target_arch!="x64" - ['use_aura==1 or target_arch=="x64"', { + }, { # target_arch!="x64" 'dependencies!': [ '../chrome_frame/chrome_frame.gyp:npchrome_frame', ], 'defines': [ 'OMIT_CHROME_FRAME', ], - }], # use_aura==1 or target_arch=="x64" + }], # target_arch=="x64" ], }, { @@ -706,14 +704,14 @@ '../remoting/remoting.gyp:remoting_host_installation', ], }], # component != "shared_library" - ['use_aura==1 or target_arch=="x64"', { + ['target_arch=="x64"', { 'dependencies!': [ '../chrome_frame/chrome_frame.gyp:npchrome_frame', ], 'defines': [ 'OMIT_CHROME_FRAME', ], - }], # use_aura==1 or target_arch=="x64" + }], # target_arch=="x64" ] }, ], # targets diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 08a7cc7..f85aaaa 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -428,7 +428,7 @@ bool AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_BeginTracing, BeginTracing) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_EndTracing, EndTracing) IPC_MESSAGE_HANDLER(AutomationMsg_GetTracingOutput, GetTracingOutput) -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) // These are for use with external tabs. IPC_MESSAGE_HANDLER(AutomationMsg_CreateExternalTab, CreateExternalTab) IPC_MESSAGE_HANDLER(AutomationMsg_ProcessUnhandledAccelerator, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index a288308..1c5b8b6 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -146,7 +146,7 @@ class AutomationProvider return reply_message; } -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) // Adds the external tab passed in to the tab tracker. bool AddExternalTab(ExternalTabContainer* external_tab); #endif @@ -285,7 +285,7 @@ class AutomationProvider // Method called by the popup menu tracker when a popup menu is opened. void NotifyPopupMenuOpened(); -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) // The functions in this block are for use with external tabs, so they are // Windows only. @@ -304,16 +304,16 @@ class AutomationProvider void OnForwardContextMenuCommandToChrome(int tab_handle, int command); void CreateExternalTab(const ExternalTabSettings& settings, - gfx::NativeWindow* tab_container_window, - gfx::NativeWindow* tab_window, + HWND* tab_container_window, + HWND* tab_window, 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, + HWND parent_window, + HWND* tab_container_window, + HWND* tab_window, int* tab_handle, int* session_id); @@ -335,7 +335,7 @@ class AutomationProvider void OnSetZoomLevel(int handle, int zoom_level); ExternalTabContainer* GetExternalTabForHandle(int handle); -#endif // defined(OS_WIN) && !defined(USE_AURA) +#endif // defined(OS_WIN) scoped_ptr<IPC::ChannelProxy> channel_; scoped_ptr<NewTabUILoadObserver> new_tab_ui_load_observer_; diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 358ad6f..3bf1c12 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -24,7 +24,6 @@ #include "content/public/browser/navigation_controller.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/common/page_zoom.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/views/focus/accelerator_handler.h" @@ -36,8 +35,10 @@ using content::WebContents; void AutomationProvider::CreateExternalTab( const ExternalTabSettings& settings, - gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, - int* tab_handle, int* session_id) { + HWND* tab_container_window, + HWND* tab_window, + int* tab_handle, + int* session_id) { TRACE_EVENT_BEGIN_ETW("AutomationProvider::CreateExternalTab", 0, ""); *tab_handle = 0; @@ -63,8 +64,8 @@ void AutomationProvider::CreateExternalTab( SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(web_contents); *tab_handle = external_tab_container->GetTabHandle(); - *tab_container_window = external_tab_container->GetExternalTabNativeView(); - *tab_window = web_contents->GetView()->GetNativeView(); + *tab_container_window = external_tab_container->GetExternalTabHWND(); + *tab_window = external_tab_container->GetContentHWND(); *session_id = session_tab_helper->session_id().id(); } else { external_tab_container->Uninitialize(); @@ -118,15 +119,14 @@ void AutomationProvider::PrintAsync(int tab_handle) { ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - return ExternalTabContainer::GetContainerForTab( - tab->GetWebContents()->GetView()->GetNativeView()); + return ExternalTabContainer::GetContainerForTab(tab->GetWebContents()); } return NULL; } -void AutomationProvider::OnTabReposition( - int tab_handle, const Reposition_Params& params) { +void AutomationProvider::OnTabReposition(int tab_handle, + const Reposition_Params& params) { if (!tab_tracker_->ContainsHandle(tab_handle)) return; @@ -161,14 +161,13 @@ void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle, external_tab->ExecuteContextMenuCommand(command); } -void AutomationProvider::ConnectExternalTab( - uint64 cookie, - bool allow, - gfx::NativeWindow parent_window, - gfx::NativeWindow* tab_container_window, - gfx::NativeWindow* tab_window, - int* tab_handle, - int* session_id) { +void AutomationProvider::ConnectExternalTab(uint64 cookie, + bool allow, + HWND parent_window, + HWND* tab_container_window, + HWND* tab_window, + int* tab_handle, + int* session_id) { TRACE_EVENT_BEGIN_ETW("AutomationProvider::ConnectExternalTab", 0, ""); *tab_handle = 0; @@ -191,8 +190,8 @@ void AutomationProvider::ConnectExternalTab( SessionTabHelper* session_tab_helper = SessionTabHelper::FromWebContents(web_contents); *tab_handle = external_tab_container->GetTabHandle(); - *tab_container_window = external_tab_container->GetExternalTabNativeView(); - *tab_window = web_contents->GetView()->GetNativeView(); + *tab_container_window = external_tab_container->GetExternalTabHWND(); + *tab_window = external_tab_container->GetContentHWND(); *session_id = session_tab_helper->session_id().id(); } else { external_tab_container->Uninitialize(); diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider_win.cc index 5f8127d..808b711 100644 --- a/chrome/browser/automation/chrome_frame_automation_provider.cc +++ b/chrome/browser/automation/chrome_frame_automation_provider_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/automation/chrome_frame_automation_provider.h" +#include "chrome/browser/automation/chrome_frame_automation_provider_win.h" #include <algorithm> @@ -83,14 +83,10 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { switch (type) { case AutomationMsg_CreateExternalTab::ID: case AutomationMsg_ConnectExternalTab::ID: -#if defined(OS_WIN) case AutomationMsg_BrowserMove::ID: case AutomationMsg_ProcessUnhandledAccelerator::ID: case AutomationMsg_ForwardContextMenuCommandToChrome::ID: -#endif // defined(OS_WIN) -#if defined(OS_WIN) case AutomationMsg_TabReposition::ID: -#endif case AutomationMsg_NavigateInExternalTab::ID: case AutomationMsg_NavigateExternalTabAtIndex::ID: case AutomationMsg_Find::ID: @@ -128,8 +124,7 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { // static void ChromeFrameAutomationProvider::ReleaseBrowserProcess() { if (g_browser_process) { - VLOG(1) << "ChromeFrameAutomationProvider: " - "Releasing browser process."; + VLOG(1) << "ChromeFrameAutomationProvider: Releasing browser process."; g_browser_process->ReleaseModule(); } } diff --git a/chrome/browser/automation/chrome_frame_automation_provider.h b/chrome/browser/automation/chrome_frame_automation_provider_win.h index 99f3297..6b5a145 100644 --- a/chrome/browser/automation/chrome_frame_automation_provider.h +++ b/chrome/browser/automation/chrome_frame_automation_provider_win.h @@ -8,8 +8,8 @@ // The entire lifetime of this object should be contained within that of // the BrowserProcess -#ifndef CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_H_ -#define CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_H_ +#ifndef CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_WIN_H_ +#define CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_WIN_H_ #include "base/basictypes.h" #include "chrome/browser/automation/automation_provider.h" @@ -41,5 +41,5 @@ class ChromeFrameAutomationProvider : public AutomationProvider { DISALLOW_COPY_AND_ASSIGN(ChromeFrameAutomationProvider); }; -#endif // CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_H_ +#endif // CHROME_BROWSER_AUTOMATION_CHROME_FRAME_AUTOMATION_PROVIDER_WIN_H_ diff --git a/chrome/browser/automation/automation_provider_unittest.cc b/chrome/browser/automation/chrome_frame_automation_provider_win_unittest.cc index 3458158..1b9b9f0 100644 --- a/chrome/browser/automation/automation_provider_unittest.cc +++ b/chrome/browser/automation/chrome_frame_automation_provider_win_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/automation/chrome_frame_automation_provider.h" +#include "chrome/browser/automation/chrome_frame_automation_provider_win.h" #include "chrome/test/base/testing_browser_process.h" #include "content/public/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" @@ -37,4 +37,3 @@ TEST_F(AutomationProviderTest, TestInvalidChromeFrameMessage) { -1))).Times(1); mock->OnMessageReceived(bad_msg); } - diff --git a/chrome/browser/external_tab/external_tab_container.h b/chrome/browser/external_tab/external_tab_container.h index d48c170..4afaa6e 100644 --- a/chrome/browser/external_tab/external_tab_container.h +++ b/chrome/browser/external_tab/external_tab_container.h @@ -34,14 +34,17 @@ class ExternalTabContainer : public base::RefCounted<ExternalTabContainer> { AutomationResourceMessageFilter* filter); // A helper method that retrieves the ExternalTabContainer object that - // hosts the given tab window. - static ExternalTabContainer* GetContainerForTab(HWND tab_window); + // hosts the given WebContents. + static ExternalTabContainer* GetContainerForTab( + content::WebContents* web_contents); // Returns the ExternalTabContainer instance associated with the cookie // passed in. It also erases the corresponding reference from the map. // Returns NULL if we fail to find the cookie in the map. static scoped_refptr<ExternalTabContainer> RemovePendingTab(uintptr_t cookie); + // Initializes the instance. This must be invoked before any other member + // functions. virtual bool Init(Profile* profile, HWND parent, const gfx::Rect& bounds, @@ -66,7 +69,7 @@ class ExternalTabContainer : public base::RefCounted<ExternalTabContainer> { // instance is created by Chrome and attached to an automation client. virtual bool Reinitialize(AutomationProvider* automation_provider, AutomationResourceMessageFilter* filter, - gfx::NativeWindow parent_window) = 0; + HWND parent_window) = 0; // This is invoked when the external host reflects back to us a keyboard // message it did not process. @@ -79,9 +82,8 @@ class ExternalTabContainer : public base::RefCounted<ExternalTabContainer> { virtual void RunUnloadHandlers(IPC::Message* reply_message) = 0; virtual content::WebContents* GetWebContents() const = 0; - - // This is a wrapper for GetNativeView from ExternalTabContainerWin. - virtual gfx::NativeView GetExternalTabNativeView() const = 0; + virtual HWND GetExternalTabHWND() const = 0; + virtual HWND GetContentHWND() const = 0; virtual void SetTabHandle(int handle) = 0; virtual int GetTabHandle() const = 0; diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index e052cfc..62357be 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc @@ -27,7 +27,6 @@ #include "chrome/browser/auto_launch_trial.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/automation_provider_list.h" -#include "chrome/browser/automation/chrome_frame_automation_provider.h" #include "chrome/browser/automation/testing_automation_provider.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" @@ -78,6 +77,7 @@ #endif #if defined(OS_WIN) +#include "chrome/browser/automation/chrome_frame_automation_provider_win.h" #include "chrome/browser/ui/startup/startup_browser_creator_win.h" #endif @@ -497,7 +497,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( silent_launch = true; if (command_line.HasSwitch(switches::kChromeFrame)) { -#if !defined(USE_AURA) +#if defined(OS_WIN) if (!CreateAutomationProvider<ChromeFrameAutomationProvider>( automation_channel_id, last_used_profile, expected_tabs)) return false; diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index bc5d9ce..d89b3a5 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -4,6 +4,10 @@ #include "chrome/browser/ui/views/external_tab_container_win.h" +#include <atlbase.h> +#include <atlapp.h> +#include <atlconv.h> +#include <atlmisc.h> #include <string> #include "base/bind.h" @@ -36,6 +40,7 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/media_stream_infobar_delegate.h" #include "chrome/browser/ui/tab_modal_confirm_dialog.h" +#include "chrome/browser/ui/views/hwnd_util.h" #include "chrome/browser/ui/views/infobars/infobar_container_view.h" #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_win.h" #include "chrome/common/automation_messages.h" @@ -70,7 +75,12 @@ #include "ui/base/view_prop.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/layout/grid_layout.h" -#include "ui/views/win/hwnd_message_handler.h" +#include "ui/views/widget/widget.h" + +#if defined(USE_AURA) +#include "ui/aura/root_window.h" +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#endif using content::BrowserThread; using content::LoadNotificationDetails; @@ -81,15 +91,44 @@ using content::OpenURLParams; using content::RenderViewHost; using content::SSLStatus; using content::WebContents; -using ui::ViewProp; using WebKit::WebCString; using WebKit::WebReferrerPolicy; using WebKit::WebSecurityPolicy; using WebKit::WebString; +namespace { + static const char kWindowObjectKey[] = "ChromeWindowObject"; -namespace { +// The following helper functions exist to localize UI toolkit-specific code. + +void ShowNativeView(gfx::NativeView view) { +#if !defined(USE_AURA) + ::ShowWindow(view, SW_SHOWNA); +#endif +} + +scoped_ptr<content::NativeWebKeyboardEvent> CreateKeyboardEvent( + const MSG& msg) { +#if defined(USE_AURA) + // TODO(grt): confirm that this is a translated character event. + ui::KeyEvent key_event(msg, true); + return scoped_ptr<content::NativeWebKeyboardEvent>( + new content::NativeWebKeyboardEvent(&key_event)); +#else + return scoped_ptr<content::NativeWebKeyboardEvent>( + new content::NativeWebKeyboardEvent(msg)); +#endif +} + +const MSG& MessageFromKeyboardEvent( + const content::NativeWebKeyboardEvent& event) { +#if defined(USE_AURA) + return event.os_event->native_event(); +#else + return event.os_event; +#endif +} // Convert ui::MenuModel into a serializable form for Chrome Frame ContextMenuModel* ConvertMenuModel(const ui::MenuModel* ui_model) { @@ -123,7 +162,7 @@ base::LazyInstance<ExternalTabContainerWin::PendingTabs> ExternalTabContainerWin::ExternalTabContainerWin( AutomationProvider* automation, AutomationResourceMessageFilter* filter) - : views::NativeWidgetWin(new views::Widget), + : widget_(NULL), automation_(automation), tab_contents_container_(NULL), tab_handle_(0), @@ -131,12 +170,12 @@ ExternalTabContainerWin::ExternalTabContainerWin( automation_resource_message_filter_(filter), load_requests_via_automation_(false), handle_top_level_requests_(false), + route_all_top_level_navigations_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), pending_(false), focus_manager_(NULL), external_tab_view_(NULL), unload_reply_message_(NULL), - route_all_top_level_navigations_(false), is_popup_window_(false) { } @@ -167,29 +206,28 @@ bool ExternalTabContainerWin::Init(Profile* profile, const GURL& referrer, bool infobars_enabled, bool route_all_top_level_navigations) { - if (IsWindow(GetNativeView())) { + if (widget_) { NOTREACHED(); return false; } + widget_ = new views::Widget(); + widget_->AddObserver(this); load_requests_via_automation_ = load_requests_via_automation; handle_top_level_requests_ = handle_top_level_requests; route_all_top_level_navigations_ = route_all_top_level_navigations; - GetMessageHandler()->set_window_style(WS_POPUP | WS_CLIPCHILDREN); - views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); params.bounds = bounds; - params.native_widget = this; - GetWidget()->Init(params); - if (!IsWindow(GetNativeView())) { - NOTREACHED(); - return false; - } +#if defined(USE_AURA) + params.native_widget = new views::DesktopNativeWidgetAura(widget_); +#endif + widget_->Init(params); + HWND window = chrome::HWNDForWidget(widget_); // TODO(jcampan): limit focus traversal to contents. - prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); + prop_.reset(new ui::ViewProp(window, kWindowObjectKey, this)); if (existing_contents) { existing_contents->GetController().SetBrowserContext(profile); @@ -243,15 +281,14 @@ bool ExternalTabContainerWin::Init(Profile* profile, // Note that it's important to do this before we call SetParent since // during the SetParent call we will otherwise get a WA_ACTIVATE call // that causes us to steal the current focus. - SetWindowLong( - GetNativeView(), GWL_STYLE, - (GetWindowLong(GetNativeView(), GWL_STYLE) & ~WS_POPUP) | style); + SetWindowLong(window, GWL_STYLE, + (GetWindowLong(window, GWL_STYLE) & ~WS_POPUP) | style); // Now apply the parenting and style if (parent) - SetParent(GetNativeView(), parent); + SetParent(window, parent); - ::ShowWindow(existing_contents->GetView()->GetNativeView(), SW_SHOWNA); + ShowNativeView(existing_contents->GetView()->GetNativeView()); LoadAccelerators(); SetupExternalTabView(); @@ -263,6 +300,7 @@ bool ExternalTabContainerWin::Init(Profile* profile, void ExternalTabContainerWin::Uninitialize() { registrar_.RemoveAll(); if (web_contents_.get()) { + tab_contents_container_->SetWebContents(NULL); UnregisterRenderViewHost(web_contents_->GetRenderViewHost()); // Explicitly tell the RPH to shutdown, as doing so is the only thing that @@ -284,8 +322,9 @@ void ExternalTabContainerWin::Uninitialize() { // more fitting. web_contents_->GetRenderProcessHost()->FastShutdownForPageCount(1); - if (GetWidget()->GetRootView()) - GetWidget()->GetRootView()->RemoveAllChildViews(true); + if (widget_->GetRootView()) + widget_->GetRootView()->RemoveAllChildViews(true); + widget_ = NULL; content::NotificationService::current()->Notify( chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED, @@ -308,7 +347,7 @@ void ExternalTabContainerWin::Uninitialize() { bool ExternalTabContainerWin::Reinitialize( AutomationProvider* automation_provider, AutomationResourceMessageFilter* filter, - gfx::NativeWindow parent_window) { + HWND parent_window) { if (!automation_provider || !filter) { NOTREACHED(); return false; @@ -323,7 +362,7 @@ bool ExternalTabContainerWin::Reinitialize( weak_factory_.GetWeakPtr())); if (parent_window) - SetParent(GetNativeView(), parent_window); + SetParent(chrome::HWNDForWidget(widget_), parent_window); return true; } @@ -331,8 +370,12 @@ WebContents* ExternalTabContainerWin::GetWebContents() const { return web_contents_.get(); } -gfx::NativeView ExternalTabContainerWin::GetExternalTabNativeView() const { - return GetNativeView(); +HWND ExternalTabContainerWin::GetExternalTabHWND() const { + return chrome::HWNDForWidget(widget_); +} + +HWND ExternalTabContainerWin::GetContentHWND() const { + return chrome::HWNDForNativeWindow(web_contents_->GetView()->GetNativeView()); } void ExternalTabContainerWin::SetTabHandle(int handle) { @@ -389,8 +432,8 @@ void ExternalTabContainerWin::RunUnloadHandlers(IPC::Message* reply_message) { } void ExternalTabContainerWin::ProcessUnhandledAccelerator(const MSG& msg) { - NativeWebKeyboardEvent keyboard_event(msg); - unhandled_keyboard_event_handler_.HandleKeyboardEvent(keyboard_event, + scoped_ptr<NativeWebKeyboardEvent> keyboard_event(CreateKeyboardEvent(msg)); + unhandled_keyboard_event_handler_.HandleKeyboardEvent(*keyboard_event, focus_manager_); } @@ -409,22 +452,6 @@ void ExternalTabContainerWin::FocusThroughTabTraversal( web_contents_->FocusThroughTabTraversal(reverse); } -// static -bool ExternalTabContainerWin::IsExternalTabContainer(HWND window) { - return ViewProp::GetValue(window, kWindowObjectKey) != NULL; -} - -// static -ExternalTabContainer* - ExternalTabContainerWin::GetExternalContainerFromNativeWindow( - gfx::NativeView native_window) { - ExternalTabContainer* tab_container = NULL; - if (native_window) { - tab_container = reinterpret_cast<ExternalTabContainer*>( - ViewProp::GetValue(native_window, kWindowObjectKey)); - } - return tab_container; -} //////////////////////////////////////////////////////////////////////////////// // ExternalTabContainer, content::WebContentsDelegate implementation: @@ -719,7 +746,7 @@ bool ExternalTabContainerWin::HandleContextMenu( ConvertMenuModel(&external_context_menu_->menu_model())); POINT screen_pt = { params.x, params.y }; - MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1); + MapWindowPoints(chrome::HWNDForWidget(widget_), HWND_DESKTOP, &screen_pt, 1); MiniContextMenuParams ipc_params; ipc_params.screen_x = screen_pt.x; @@ -750,8 +777,9 @@ bool ExternalTabContainerWin::PreHandleKeyboardEvent( void ExternalTabContainerWin::HandleKeyboardEvent( content::WebContents* source, const NativeWebKeyboardEvent& event) { - ProcessUnhandledKeyStroke(event.os_event.hwnd, event.os_event.message, - event.os_event.wParam, event.os_event.lParam); + const MSG& message = MessageFromKeyboardEvent(event); + ProcessUnhandledKeyStroke(message.hwnd, message.message, + message.wParam, message.lParam); } void ExternalTabContainerWin::BeforeUnloadFired(WebContents* tab, @@ -950,30 +978,23 @@ void ExternalTabContainerWin::Observe( } //////////////////////////////////////////////////////////////////////////////// -// ExternalTabContainer, views::NativeWidgetWin overrides: - -bool ExternalTabContainerWin::PreHandleMSG(UINT message, - WPARAM w_param, - LPARAM l_param, - LRESULT* result) { - if (message == WM_DESTROY) { - prop_.reset(); - Uninitialize(); - } - return false; +// WidgetObserver overrides: + +void ExternalTabContainerWin::OnWidgetCreated(views::Widget* widget) { + DCHECK_EQ(widget_, widget); + // Grab a reference here which will be released in OnWidgetDestroyed. + AddRef(); } -void ExternalTabContainerWin::PostHandleMSG(UINT message, - WPARAM w_param, - LPARAM l_param) { - // Grab a reference here which will be released in OnFinalMessage - if (message == WM_CREATE) - AddRef(); +void ExternalTabContainerWin::OnWidgetDestroying(views::Widget* widget) { + DCHECK_EQ(widget_, widget); + Uninitialize(); + prop_.reset(); } -void ExternalTabContainerWin::OnFinalMessage(HWND window) { - GetWidget()->OnNativeWidgetDestroyed(); - // Release the reference which we grabbed in WM_CREATE. +void ExternalTabContainerWin::OnWidgetDestroyed(views::Widget* widget) { + DCHECK_EQ(widget_, static_cast<views::Widget*>(NULL)); + // Release the reference which we grabbed in OnWidgetCreated. Release(); } @@ -1144,7 +1165,7 @@ void ExternalTabContainerWin::LoadAccelerators() { CopyAcceleratorTable(accelerator_table, accelerators, count); - focus_manager_ = GetWidget()->GetFocusManager(); + focus_manager_ = widget_->GetFocusManager(); DCHECK(focus_manager_); // Let's fill our own accelerator table. @@ -1222,7 +1243,7 @@ void ExternalTabContainerWin::SetupExternalTabView() { layout->AddView(info_bar_container); layout->StartRow(1, 0); layout->AddView(tab_contents_container_); - GetWidget()->SetContentsView(external_tab_view_); + widget_->SetContentsView(external_tab_view_); // Note that SetWebContents must be called after AddChildView is called tab_contents_container_->SetWebContents(web_contents()); } @@ -1236,17 +1257,13 @@ ExternalTabContainer* ExternalTabContainer::Create( // static ExternalTabContainer* ExternalTabContainer::GetContainerForTab( - HWND tab_window) { - HWND parent_window = ::GetParent(tab_window); - if (!::IsWindow(parent_window)) { + content::WebContents* web_contents) { + HWND parent_window = chrome::HWNDForNativeWindow( + web_contents->GetView()->GetTopLevelNativeWindow()); + if (!::IsWindow(parent_window)) return NULL; - } - if (!ExternalTabContainerWin::IsExternalTabContainer(parent_window)) { - return NULL; - } - ExternalTabContainer* container = reinterpret_cast<ExternalTabContainer*>( - ViewProp::GetValue(parent_window, kWindowObjectKey)); - return container; + return reinterpret_cast<ExternalTabContainerWin*>( + ui::ViewProp::GetValue(parent_window, kWindowObjectKey)); } // static @@ -1283,6 +1300,6 @@ WebContents* TemporaryPopupExternalTabContainerWin::OpenURLFromTab( WebContents* new_contents = ExternalTabContainerWin::OpenURLFromTab(source, forward_params); // support only one navigation for a dummy tab before it is killed. - ::DestroyWindow(GetNativeView()); + widget_->CloseNow(); return new_contents; } diff --git a/chrome/browser/ui/views/external_tab_container_win.h b/chrome/browser/ui/views/external_tab_container_win.h index 3d06fec..139db42 100644 --- a/chrome/browser/ui/views/external_tab_container_win.h +++ b/chrome/browser/ui/views/external_tab_container_win.h @@ -25,7 +25,7 @@ #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" #include "ui/base/accelerators/accelerator.h" -#include "ui/views/widget/native_widget_win.h" +#include "ui/views/widget/widget_observer.h" class AutomationProvider; class Browser; @@ -39,7 +39,9 @@ class ViewProp; } namespace views { +class View; class WebView; +class Widget; } // This class serves as the container window for an external tab. @@ -50,7 +52,7 @@ class ExternalTabContainerWin : public ExternalTabContainer, public content::WebContentsDelegate, public content::WebContentsObserver, public content::NotificationObserver, - public views::NativeWidgetWin, + public views::WidgetObserver, public ui::AcceleratorTarget, public InfoBarContainer::Delegate, public BlockedContentTabHelperDelegate { @@ -79,9 +81,10 @@ class ExternalTabContainerWin : public ExternalTabContainer, virtual void Uninitialize() OVERRIDE; virtual bool Reinitialize(AutomationProvider* automation_provider, AutomationResourceMessageFilter* filter, - gfx::NativeWindow parent_window) OVERRIDE; + HWND parent_window) OVERRIDE; virtual content::WebContents* GetWebContents() const OVERRIDE; - virtual gfx::NativeView GetExternalTabNativeView() const OVERRIDE; + virtual HWND GetExternalTabHWND() const OVERRIDE; + virtual HWND GetContentHWND() const OVERRIDE; virtual void SetTabHandle(int handle) OVERRIDE; virtual int GetTabHandle() const OVERRIDE; virtual bool ExecuteContextMenuCommand(int command) OVERRIDE; @@ -90,16 +93,6 @@ class ExternalTabContainerWin : public ExternalTabContainer, virtual void FocusThroughTabTraversal(bool reverse, bool restore_focus_to_view) OVERRIDE; - // A helper method that tests whether the given window is an - // ExternalTabContainerWin window. - static bool IsExternalTabContainer(HWND window); - - // A helper function that returns a pointer to the ExternalTabContainerWin - // instance associated with a native view. Returns NULL if the window - // is not an ExternalTabContainerWin. - static ExternalTabContainer* GetExternalContainerFromNativeWindow( - gfx::NativeView native_window); - // Overridden from content::WebContentsDelegate: virtual content::WebContents* OpenURLFromTab( content::WebContents* source, @@ -219,15 +212,10 @@ class ExternalTabContainerWin : public ExternalTabContainer, protected: virtual ~ExternalTabContainerWin(); - // Overridden from views::NativeWidgetWin: - virtual bool PreHandleMSG(UINT message, - WPARAM w_param, - LPARAM l_param, - LRESULT* result) OVERRIDE; - virtual void PostHandleMSG(UINT message, - WPARAM w_param, - LPARAM l_param) OVERRIDE; - virtual void OnFinalMessage(HWND window); + // WidgetObserver overrides. + virtual void OnWidgetCreated(views::Widget* widget) OVERRIDE; + virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; + virtual void OnWidgetDestroyed(views::Widget* widget) OVERRIDE; bool InitNavigationInfo(NavigationInfo* nav_info, content::NavigationType nav_type, @@ -257,6 +245,7 @@ class ExternalTabContainerWin : public ExternalTabContainer, // ExternalTabContainerWin. void SetupExternalTabView(); + views::Widget* widget_; scoped_ptr<content::WebContents> web_contents_; scoped_refptr<AutomationProvider> automation_; @@ -284,6 +273,11 @@ class ExternalTabContainerWin : public ExternalTabContainer, // whether top level URL requests are to be handled by the automation client. bool handle_top_level_requests_; + // Set to true if the host needs to get notified of all top level navigations + // in this page. This typically applies to hosts which would render the new + // page without chrome frame. + bool route_all_top_level_navigations_; + // Contains ExternalTabContainers that have not been connected to as yet. static base::LazyInstance<PendingTabs> pending_tabs_; @@ -322,11 +316,6 @@ class ExternalTabContainerWin : public ExternalTabContainer, IPC::Message* unload_reply_message_; - // set to true if the host needs to get notified of all top level navigations - // in this page. This typically applies to hosts which would render the new - // page without chrome frame. - bool route_all_top_level_navigations_; - scoped_ptr<ui::ViewProp> prop_; // if this tab is a popup diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2873e98..1860b28 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -311,8 +311,8 @@ 'browser/automation/automation_util.h', 'browser/automation/automation_window_tracker.cc', 'browser/automation/automation_window_tracker.h', - 'browser/automation/chrome_frame_automation_provider.cc', - 'browser/automation/chrome_frame_automation_provider.h', + 'browser/automation/chrome_frame_automation_provider_win.cc', + 'browser/automation/chrome_frame_automation_provider_win.h', 'browser/automation/testing_automation_provider.cc', 'browser/automation/testing_automation_provider.h', 'browser/automation/testing_automation_provider_aura.cc', @@ -2578,9 +2578,6 @@ }], ['use_aura==1', { 'sources/': [ - ['exclude', '^browser/automation/automation_provider_win.cc'], - ['exclude', '^browser/automation/chrome_frame_automation_provider.cc'], - ['exclude', '^browser/automation/chrome_frame_automation_provider.h'], ['exclude', '^browser/automation/testing_automation_provider_win.cc'], ['exclude', '^browser/google/google_update_win.cc'], ['exclude', '^browser/google/google_update_win.h'], @@ -2604,6 +2601,7 @@ 'conditions': [ ['OS=="win"', { 'sources/': [ + ['exclude', '^browser/automation/automation_provider_aura.cc'], ['exclude', '^browser/background/background_mode_manager_aura.cc'], ['exclude', '^browser/fullscreen_ash.cc'], ['exclude', '^browser/lifetime/application_lifetime_win.cc'], diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index bc2185d..3d14c63 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -2427,8 +2427,6 @@ ['exclude', '^browser/ui/views/certificate_viewer_win.cc'], ['exclude', '^browser/ui/views/dropdown_bar_host_win.cc'], ['exclude', '^browser/ui/views/external_protocol_dialog.cc'], - ['exclude', '^browser/ui/views/external_tab_container_win.cc'], - ['exclude', '^browser/ui/views/external_tab_container_win.h'], ['exclude', '^browser/ui/views/find_bar_host_win.cc'], ['exclude', '^browser/ui/views/frame/browser_frame_win.cc'], ['exclude', '^browser/ui/views/frame/browser_frame_win.h'], diff --git a/chrome/chrome_installer.gypi b/chrome/chrome_installer.gypi index 6c5d7ec..f3da62d 100644 --- a/chrome/chrome_installer.gypi +++ b/chrome/chrome_installer.gypi @@ -374,7 +374,7 @@ 'branding_dir_100': 'app/theme/default_100_percent/chromium', }, }], - ['use_aura==1 or target_arch=="x64"', { + ['target_arch=="x64"', { 'dependencies!': [ '../chrome_frame/chrome_frame.gyp:chrome_tab_idl', '../chrome_frame/chrome_frame.gyp:npchrome_frame', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 56805e2..72d0df1 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -508,8 +508,8 @@ 'browser/autofill/wallet/wallet_service_url_unittest.cc', 'browser/autofill/wallet/wallet_test_util.cc', 'browser/autofill/wallet/wallet_test_util.h', - 'browser/automation/automation_provider_unittest.cc', 'browser/automation/automation_tab_helper_unittest.cc', + 'browser/automation/chrome_frame_automation_provider_win_unittest.cc', 'browser/background/background_application_list_model_unittest.cc', 'browser/background/background_contents_service_unittest.cc', 'browser/background/background_mode_manager_unittest.cc', @@ -1823,7 +1823,6 @@ '../ui/aura/aura.gyp:aura_test_support', ], 'sources/': [ - ['exclude', '^browser/automation/automation_provider_unittest.cc'], ['exclude', '^browser/ui/views/extensions/browser_action_drag_data_unittest.cc'], ['exclude', '^browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc'], ['exclude', '^browser/ui/panels/display_settings_provider_win_unittest.cc'], diff --git a/chrome/common/automation_messages.h b/chrome/common/automation_messages.h index 0f084dc..2f908f6 100644 --- a/chrome/common/automation_messages.h +++ b/chrome/common/automation_messages.h @@ -53,8 +53,10 @@ IPC_STRUCT_BEGIN(AutomationURLResponse) IPC_STRUCT_MEMBER(uint64, upload_size) IPC_STRUCT_END() +#if defined(OS_WIN) + IPC_STRUCT_BEGIN(ExternalTabSettings) - IPC_STRUCT_MEMBER(gfx::NativeWindow, parent) + IPC_STRUCT_MEMBER(HWND, parent) IPC_STRUCT_MEMBER(gfx::Rect, dimensions) IPC_STRUCT_MEMBER(unsigned int, style) IPC_STRUCT_MEMBER(bool, is_incognito) @@ -66,6 +68,8 @@ IPC_STRUCT_BEGIN(ExternalTabSettings) IPC_STRUCT_MEMBER(bool, route_all_top_level_navigations) IPC_STRUCT_END() +#endif // defined(OS_WIN) + IPC_STRUCT_BEGIN(NavigationInfo) IPC_STRUCT_MEMBER(int, navigation_type) IPC_STRUCT_MEMBER(int, relative_offset) @@ -120,7 +124,7 @@ IPC_STRUCT_BEGIN(AttachExternalTabParams) IPC_STRUCT_MEMBER(std::string, profile_name) IPC_STRUCT_END() -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) IPC_STRUCT_BEGIN(Reposition_Params) IPC_STRUCT_MEMBER(HWND, window) diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index 00167ee..a9ee3dc 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -251,18 +251,18 @@ IPC_MESSAGE_CONTROL3(AutomationMsg_DEPRECATED_WindowKeyPress, int, int, int) - +#if defined(OS_WIN) // This message notifies the AutomationProvider to create a tab which is // hosted by an external process. // Request: // ExternalTabSettings - settings for external tab IPC_SYNC_MESSAGE_CONTROL1_4(AutomationMsg_CreateExternalTab, ExternalTabSettings /* settings*/, - gfx::NativeWindow /* Tab container window */, - gfx::NativeWindow /* Tab window */, + HWND /* Tab container window */, + HWND /* Tab window */, int /* Handle to the new tab */, int /* Session Id of the new tab */) - +#endif // defined(OS_WIN) // This message notifies the AutomationProvider to navigate to a specified // url in the external tab with given handle. The first parameter is the // handle to the tab resource. The second parameter is the target url. @@ -557,7 +557,7 @@ IPC_MESSAGE_ROUTED2(AutomationMsg_NavigationFailed, int, GURL) -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) // This message is an outgoing message from an automation client to Chrome. // It is used to reposition a chrome tab window. IPC_MESSAGE_CONTROL2(AutomationMsg_TabReposition, @@ -717,17 +717,17 @@ IPC_SYNC_MESSAGE_CONTROL2_1( IPC_MESSAGE_ROUTED1(AutomationMsg_AttachExternalTab, AttachExternalTabParams) - +#if defined(OS_WIN) // Sent when the automation client connects to an existing tab. IPC_SYNC_MESSAGE_CONTROL3_4(AutomationMsg_ConnectExternalTab, uint64 /* cookie */, bool /* allow/block tab*/, - gfx::NativeWindow /* parent window */, - gfx::NativeWindow /* Tab container window */, - gfx::NativeWindow /* Tab window */, + HWND /* parent window */, + HWND /* Tab container window */, + HWND /* Tab window */, int /* Handle to the new tab */, int /* Session Id of the new tab */) - +#endif // defined(OS_WIN) // Simulate an end of session. Normally this happens when the user // shuts down the machine or logs off. // Request: diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 8371d74..8a0ed36 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -376,31 +376,6 @@ bool AutomationProxy::OpenNewBrowserWindow(Browser::Type type, bool show) { show)); } -scoped_refptr<TabProxy> AutomationProxy::CreateExternalTab( - const ExternalTabSettings& settings, - gfx::NativeWindow* external_tab_container, - gfx::NativeWindow* tab) { - int handle = 0; - int session_id = 0; - bool succeeded = - Send(new AutomationMsg_CreateExternalTab(settings, - external_tab_container, - tab, - &handle, - &session_id)); - if (!succeeded) { - return NULL; - } - -#if defined(OS_WIN) && !defined(USE_AURA) - 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); -} - template <class T> scoped_refptr<T> AutomationProxy::ProxyObjectFromHandle( int handle) { if (!handle) diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 7f426cc..788a3dc 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -181,14 +181,6 @@ class AutomationProxy : public IPC::Listener, public AutomationMessageSender { // the tracker. virtual void InvalidateHandle(const IPC::Message& message); - // 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( - const ExternalTabSettings& settings, - gfx::NativeWindow* external_tab_container, - gfx::NativeWindow* tab); - base::TimeDelta action_timeout() const { return action_timeout_; } diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index a883070..2dcb0dd 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -385,7 +385,7 @@ bool TabProxy::CaptureEntirePageAsPNG(const base::FilePath& path) { path, &error); } -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) void TabProxy::Reposition(HWND window, HWND window_insert_after, int left, int top, int width, int height, int flags, HWND parent_window) { diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 6eae23f..5e77f93 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -46,7 +46,8 @@ const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | const DWORD kCrashServicePipeFlagsAndAttributes = SECURITY_IDENTIFICATION | SECURITY_SQOS_PRESENT; -const int kCrashServiceStartupTimeoutMs = 500; +const int kCrashServiceDetectTimeoutMs = 500; +const int kCrashServiceStartupTimeoutMs = 1000; const wchar_t kIEImageName[] = L"iexplore.exe"; const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; @@ -596,7 +597,7 @@ bool DetectRunningCrashService(int timeout_ms) { } base::ProcessHandle StartCrashService() { - if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { + if (DetectRunningCrashService(kCrashServiceDetectTimeoutMs)) { VLOG(1) << "crash_service.exe is already running. We will use the " "existing process and leave it running after tests complete."; return NULL; diff --git a/content/common/content_message_generator.cc b/content/common/content_message_generator.cc index a86fb17..2e2b5a6 100644 --- a/content/common/content_message_generator.cc +++ b/content/common/content_message_generator.cc @@ -14,30 +14,6 @@ #include "ipc/struct_destructor_macros.h" #include "content/common/content_message_generator.h" -#if defined(USE_AURA) && defined(OS_WIN) -#include "ui/gfx/native_widget_types.h" - -namespace IPC { -// TODO(beng): Figure out why this is needed, fix that issue and remove -// this. Brett and I were unable to figure out why, but he -// thought this should be harmless. -template <> -struct ParamTraits<gfx::PluginWindowHandle> { - typedef gfx::PluginWindowHandle param_type; - static void Write(Message* m, const param_type& p) { - m->WriteUInt32(reinterpret_cast<uint32>(p)); - } - static bool Read(const Message* m, PickleIterator* iter, param_type* r) { - DCHECK_EQ(sizeof(param_type), sizeof(uint32)); - return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); - } - static void Log(const param_type& p, std::string* l) { - l->append(StringPrintf("0x%X", p)); - } -}; -} // namespace IPC -#endif - // Generate param traits write methods. #include "ipc/param_traits_write_macros.h" namespace IPC { diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index fc72210..c775d8d 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -475,6 +475,13 @@ struct SimilarTypeTraits<base::PlatformFileError> { typedef int Type; }; +#if defined(OS_WIN) +template <> +struct SimilarTypeTraits<HWND> { + typedef HANDLE Type; +}; +#endif // defined(OS_WIN) + template <> struct IPC_EXPORT ParamTraits<base::Time> { typedef base::Time param_type; diff --git a/ui/views/widget/native_widget_delegate.h b/ui/views/widget/native_widget_delegate.h index 40636a2..40bdedc 100644 --- a/ui/views/widget/native_widget_delegate.h +++ b/ui/views/widget/native_widget_delegate.h @@ -28,6 +28,7 @@ class ScrollEvent; namespace views { class InputMethod; +class Widget; namespace internal { diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index a22691d..9f0bfbc 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -1026,6 +1026,8 @@ void Widget::OnNativeWidgetCreated() { widget_delegate_->GetAccessibleWindowState()); native_widget_->InitModalType(widget_delegate_->GetModalType()); + + FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetCreated(this)); } void Widget::OnNativeWidgetDestroying() { @@ -1040,6 +1042,7 @@ void Widget::OnNativeWidgetDestroying() { } void Widget::OnNativeWidgetDestroyed() { + FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetDestroyed(this)); widget_delegate_->DeleteDelegate(); widget_delegate_ = NULL; native_widget_destroyed_ = true; diff --git a/ui/views/widget/widget_observer.h b/ui/views/widget/widget_observer.h index 42f45b3..e156ef8 100644 --- a/ui/views/widget/widget_observer.h +++ b/ui/views/widget/widget_observer.h @@ -23,11 +23,19 @@ class VIEWS_EXPORT WidgetObserver { // CloseNow()). virtual void OnWidgetClosing(Widget* widget) {} + // Invoked after notification is received from the event loop that the native + // widget has been created. + virtual void OnWidgetCreated(Widget* widget) {} + // The destroying event occurs immediately before the widget is destroyed. // This typically occurs asynchronously with respect the the close request, as // a result of a later invocation from the event loop. virtual void OnWidgetDestroying(Widget* widget) {} + // Invoked after notification is received from the event loop that the native + // widget has been destroyed. + virtual void OnWidgetDestroyed(Widget* widget) {} + virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) {} virtual void OnWidgetActivationChanged(Widget* widget, bool active) {} |