Skip to content

Commit

Permalink
Minimal Chrome Frame with Aura.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
grt@chromium.org committed Feb 28, 2013
1 parent 1910689 commit ecf59c7
Show file tree
Hide file tree
Showing 26 changed files with 207 additions and 246 deletions.
14 changes: 6 additions & 8 deletions build/all.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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"', {
Expand Down Expand Up @@ -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"
],
},
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/automation/automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions chrome/browser/automation/automation_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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);

Expand All @@ -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_;
Expand Down
37 changes: 18 additions & 19 deletions chrome/browser/automation/automation_provider_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -37,4 +37,3 @@ TEST_F(AutomationProviderTest, TestInvalidChromeFrameMessage) {
-1))).Times(1);
mock->OnMessageReceived(bad_msg);
}

14 changes: 8 additions & 6 deletions chrome/browser/external_tab/external_tab_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/startup/startup_browser_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit ecf59c7

Please sign in to comment.