diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-09 16:46:25 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-09 16:46:25 +0000 |
commit | 3941c026ba6576a4e21c93f3f08b917505c369a1 (patch) | |
tree | 2dbaad011bd9b20eadfbc25477c20a51a7f60a6e /chrome/browser/external_tab_container.cc | |
parent | f61b898ba829ce8b1393f5a518a0f28eaafa1408 (diff) | |
download | chromium_src-3941c026ba6576a4e21c93f3f08b917505c369a1.zip chromium_src-3941c026ba6576a4e21c93f3f08b917505c369a1.tar.gz chromium_src-3941c026ba6576a4e21c93f3f08b917505c369a1.tar.bz2 |
Adding support for tab notifications and initializing the focus of an automated tab.
Review URL: http://codereview.chromium.org/20125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_tab_container.cc')
-rw-r--r-- | chrome/browser/external_tab_container.cc | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index e80a01b..6e1d58e 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -74,12 +74,22 @@ bool ExternalTabContainer::Init(Profile* profile, HWND parent, // Create a TabContentsContainerView to handle focus cycling using Tab and // Shift-Tab. - // TODO(sanjeevr): We need to create a dummy FocusTraversable object to - // represent the frame of the external host. This will allow Tab and - // Shift-Tab to cycle into the external frame. tab_contents_container_ = new TabContentsContainerView(); root_view_.AddChildView(tab_contents_container_); + // Note that SetTabContents must be called after AddChildView is called tab_contents_container_->SetTabContents(tab_contents_); + // Add a dummy view to catch when the user tabs out of the tab + // Create a dummy FocusTraversable object to represent the frame of the + // external host. This will allow Tab and Shift-Tab to cycle into the + // external frame. When the tab_contents_container_ loses focus, + // the focus will be moved to this class (See OnSetFocus in this file). + // An alternative to using views::View and catching when the focus manager + // shifts the focus to the dummy view could be to implement our own view + // and handle AboutToRequestFocusFromTabTraversal. + views::View* dummy = new views::View(); + dummy->SetFocusable(true); + DCHECK(dummy->IsFocusable()); + root_view_.AddChildView(dummy); NavigationController* controller = tab_contents_->controller(); DCHECK(controller); @@ -104,7 +114,7 @@ bool ExternalTabContainer::Init(Profile* profile, HWND parent, } void ExternalTabContainer::OnDestroy() { - views::FocusManager * focus_manager = + views::FocusManager* focus_manager = views::FocusManager::GetFocusManager(GetHWND()); if (focus_manager) { focus_manager->RemoveKeystrokeListener(this); @@ -140,9 +150,21 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) { return 0; } -// TODO(sanjeevr): The implementation of the TabContentsDelegate interface -// needs to be fully fleshed out based on the requirements of the -// "Chrome tab in external browser" feature. +LRESULT ExternalTabContainer::OnSetFocus(UINT msg, WPARAM wp, LPARAM lp, + BOOL& handled) { + if (automation_) { + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetHWND()); + DCHECK(focus_manager); + if (focus_manager) { + focus_manager->ClearFocus(); + automation_->Send(new AutomationMsg_TabbedOut(win_util::IsShiftPressed(), + false)); + } + } + + return 0; +} void ExternalTabContainer::OpenURLFromTab(TabContents* source, const GURL& url, @@ -164,10 +186,10 @@ void ExternalTabContainer::OpenURLFromTab(TabContents* source, } void ExternalTabContainer::NavigationStateChanged(const TabContents* source, - unsigned changed_flags) { + unsigned changed_flags) { if (automation_) { automation_->Send( - new AutomationMsg_NavigationStateChanged(0,changed_flags)); + new AutomationMsg_NavigationStateChanged(0, changed_flags)); } } @@ -190,14 +212,16 @@ void ExternalTabContainer::LoadingStateChanged(TabContents* source) { void ExternalTabContainer::CloseContents(TabContents* source) { } -void ExternalTabContainer::MoveContents(TabContents* source, const gfx::Rect& pos) { +void ExternalTabContainer::MoveContents(TabContents* source, + const gfx::Rect& pos) { } bool ExternalTabContainer::IsPopup(TabContents* source) { return false; } -void ExternalTabContainer::URLStarredChanged(TabContents* source, bool starred) { +void ExternalTabContainer::URLStarredChanged(TabContents* source, + bool starred) { } void ExternalTabContainer::UpdateTargetURL(TabContents* source, @@ -213,7 +237,7 @@ void ExternalTabContainer::ContentsZoomChange(bool zoom_in) { } void ExternalTabContainer::ToolbarSizeChanged(TabContents* source, - bool finished) { + bool finished) { } void ExternalTabContainer::ForwardMessageToExternalHost( @@ -281,7 +305,7 @@ bool ExternalTabContainer::IsActive() { } bool ExternalTabContainer::ProcessKeyDown(HWND window, UINT message, - WPARAM wparam, LPARAM lparam) { + WPARAM wparam, LPARAM lparam) { if (!automation_) { return false; } @@ -324,6 +348,13 @@ void ExternalTabContainer::ProcessUnhandledAccelerator(const MSG& msg) { DispatchMessage(&msg); } +void ExternalTabContainer::SetInitialFocus(bool reverse) { + DCHECK(tab_contents_); + if (tab_contents_) { + tab_contents_->SetInitialFocus(reverse); + } +} + // static bool ExternalTabContainer::IsExternalTabContainer(HWND window) { std::wstring class_name = win_util::GetClassName(window); |