summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-23 22:55:56 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-23 22:55:56 +0000
commit1e0a02d6464d8d1d5934c2a9bae6e852537c76b2 (patch)
treee2bf7d9b2db6d2959d9c252a2c0e83383ca06f96 /chrome
parent6e95706dcc9a205e78b1d4820427754d16a50465 (diff)
downloadchromium_src-1e0a02d6464d8d1d5934c2a9bae6e852537c76b2.zip
chromium_src-1e0a02d6464d8d1d5934c2a9bae6e852537c76b2.tar.gz
chromium_src-1e0a02d6464d8d1d5934c2a9bae6e852537c76b2.tar.bz2
Provide a way for a TabContentsDelegate to take focus when we receive a notification from the
renderer that it is done cycling through the controls on the page. Review URL: http://codereview.chromium.org/93001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/external_tab_container.cc43
-rw-r--r--chrome/browser/external_tab_container.h4
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h7
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_win.cc14
4 files changed, 32 insertions, 36 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 79a84fc..a66e2c2 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -77,18 +77,6 @@ bool ExternalTabContainer::Init(Profile* profile, HWND parent,
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();
registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
@@ -157,22 +145,6 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) {
return 0;
}
-LRESULT ExternalTabContainer::OnSetFocus(UINT msg, WPARAM wp, LPARAM lp,
- BOOL& handled) {
- if (automation_) {
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- DCHECK(focus_manager);
- if (focus_manager) {
- focus_manager->ClearFocus();
- automation_->Send(new AutomationMsg_TabbedOut(0,
- win_util::IsShiftPressed()));
- }
- }
-
- return 0;
-}
-
void ExternalTabContainer::OpenURLFromTab(TabContents* source,
const GURL& url,
const GURL& referrer,
@@ -262,6 +234,21 @@ void ExternalTabContainer::ForwardMessageToExternalHost(
}
}
+bool ExternalTabContainer::TakeFocus(bool reverse) {
+ if (automation_) {
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(GetNativeView());
+ DCHECK(focus_manager);
+ if (focus_manager) {
+ focus_manager->ClearFocus();
+ automation_->Send(new AutomationMsg_TabbedOut(0,
+ win_util::IsShiftPressed()));
+ }
+ }
+
+ return true;
+}
+
void ExternalTabContainer::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index c9d8f34..4f7750b 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -40,7 +40,6 @@ class ExternalTabContainer : public TabContentsDelegate,
public:
BEGIN_MSG_MAP(ExternalTabContainer)
MESSAGE_HANDLER(WM_SIZE, OnSize)
- MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
END_MSG_MAP()
DECLARE_WND_CLASS(chrome::kExternalTabWindowClass)
@@ -89,6 +88,8 @@ class ExternalTabContainer : public TabContentsDelegate,
return true;
};
+ virtual bool TakeFocus(bool reverse);
+
// Notification service callback.
virtual void Observe(NotificationType type,
const NotificationSource& source,
@@ -135,7 +136,6 @@ class ExternalTabContainer : public TabContentsDelegate,
protected:
LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL& handled);
- LRESULT OnSetFocus(UINT msg, WPARAM wp, LPARAM lp, BOOL& handled);
void OnDestroy();
void OnFinalMessage(HWND window);
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index ac8739c..87e228e 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -157,6 +157,13 @@ class TabContentsDelegate : public PageNavigator {
// this to disable inactive rendering for the frame in the window the select
// is opened within if necessary.
virtual void RenderWidgetShowing() {}
+
+ // This is called when webkit tells us that it is done tabbing through
+ // controls on the page. Provides a way for TabContentsDelegates to handle
+ // this. Returns true if the delegate successfully handled it.
+ virtual bool TakeFocus(bool reverse) {
+ return false;
+ }
};
#endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_
diff --git a/chrome/browser/tab_contents/tab_contents_view_win.cc b/chrome/browser/tab_contents/tab_contents_view_win.cc
index f5f3d96..e0ee88e 100644
--- a/chrome/browser/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_win.cc
@@ -315,13 +315,15 @@ void TabContentsViewWin::UpdateDragCursor(bool is_drop_target) {
}
void TabContentsViewWin::TakeFocus(bool reverse) {
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ if (!web_contents()->delegate()->TakeFocus(reverse)) {
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(GetNativeView());
- // We may not have a focus manager if the tab has been switched before this
- // message arrived.
- if (focus_manager)
- focus_manager->AdvanceFocus(reverse);
+ // We may not have a focus manager if the tab has been switched before this
+ // message arrived.
+ if (focus_manager)
+ focus_manager->AdvanceFocus(reverse);
+ }
}
void TabContentsViewWin::HandleKeyboardEvent(