summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-18 00:46:20 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-18 00:46:20 +0000
commit1d80250af1a1959e739cc02a13576401b5f113f5 (patch)
treeb3397de1f1175aae3b27b9dc75aa99f92c31502c
parent9ef017bc62963d792e42868576837129d71354f8 (diff)
downloadchromium_src-1d80250af1a1959e739cc02a13576401b5f113f5.zip
chromium_src-1d80250af1a1959e739cc02a13576401b5f113f5.tar.gz
chromium_src-1d80250af1a1959e739cc02a13576401b5f113f5.tar.bz2
HtmlDialogs had focus problems.
They would not be focused when shown and tab traversal was not working. This was caused by several issues: - HWNDView was not focusing its HWND when focused through the View::RequestFocus() method (it would rely on the default view behavior which is to focus the root view HWND), so it would not be focused by default. - DOMView (parent of HtmlDialogView) was not focusable so would not get the focus when pressing tab. - DOMView was not eating tab keys events (by returning false in View::CanProcessTabKeyEvents()), so the render view would not get the tab key press messages (for focus traversal in the render view). Note: most of the file changes in this CL are just the consequence of changing the constness of the WindowDelegate::GetInitiallyFocusedView method. BUG=6859 TEST=Open a web page, from the page menu, select the "Create application shortcut..." menu. In the dialog, press the TAB key, focus should alternate between the different fields Review URL: http://codereview.chromium.org/21439 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9925 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/jsmessage_box_handler_win.cc2
-rw-r--r--chrome/browser/jsmessage_box_handler_win.h2
-rw-r--r--chrome/browser/views/dom_view.cc1
-rw-r--r--chrome/browser/views/dom_view.h2
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/views/frame/browser_view.h2
-rw-r--r--chrome/browser/views/html_dialog_view.cc4
-rw-r--r--chrome/browser/views/html_dialog_view.h9
-rw-r--r--chrome/browser/views/new_profile_dialog.cc2
-rw-r--r--chrome/browser/views/new_profile_dialog.h2
-rw-r--r--chrome/browser/views/options/cookies_view.h2
-rw-r--r--chrome/browser/views/select_profile_dialog.cc2
-rw-r--r--chrome/browser/views/select_profile_dialog.h2
-rw-r--r--chrome/views/dialog_delegate.cc2
-rw-r--r--chrome/views/dialog_delegate.h2
-rw-r--r--chrome/views/hwnd_view.cc4
-rw-r--r--chrome/views/hwnd_view.h2
-rw-r--r--chrome/views/window_delegate.h2
18 files changed, 30 insertions, 16 deletions
diff --git a/chrome/browser/jsmessage_box_handler_win.cc b/chrome/browser/jsmessage_box_handler_win.cc
index 9dac0f4..9c48f9e 100644
--- a/chrome/browser/jsmessage_box_handler_win.cc
+++ b/chrome/browser/jsmessage_box_handler_win.cc
@@ -174,7 +174,7 @@ views::View* JavascriptMessageBoxHandler::GetContentsView() {
return message_box_view_;
}
-views::View* JavascriptMessageBoxHandler::GetInitiallyFocusedView() const {
+views::View* JavascriptMessageBoxHandler::GetInitiallyFocusedView() {
if (message_box_view_->text_box())
return message_box_view_->text_box();
return views::AppModalDialogDelegate::GetInitiallyFocusedView();
diff --git a/chrome/browser/jsmessage_box_handler_win.h b/chrome/browser/jsmessage_box_handler_win.h
index 80beaa1..bac80dd 100644
--- a/chrome/browser/jsmessage_box_handler_win.h
+++ b/chrome/browser/jsmessage_box_handler_win.h
@@ -44,7 +44,7 @@ class JavascriptMessageBoxHandler
// views::WindowDelegate Methods:
virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView();
- virtual views::View* GetInitiallyFocusedView() const;
+ virtual views::View* GetInitiallyFocusedView();
private:
// NotificationObserver implementation.
diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc
index 226f7b8..16739a4 100644
--- a/chrome/browser/views/dom_view.cc
+++ b/chrome/browser/views/dom_view.cc
@@ -8,6 +8,7 @@
DOMView::DOMView(const GURL& contents)
: contents_(contents), initialized_(false), host_(NULL) {
+ SetFocusable(true);
}
DOMView::~DOMView() {
diff --git a/chrome/browser/views/dom_view.h b/chrome/browser/views/dom_view.h
index 24ae966..92bf31f 100644
--- a/chrome/browser/views/dom_view.h
+++ b/chrome/browser/views/dom_view.h
@@ -28,6 +28,8 @@ class DOMView : public views::HWNDView {
bool Init(Profile* profile, SiteInstance* instance);
protected:
+ virtual bool CanProcessTabKeyEvents() { return true; }
+
DOMUIHost* host_;
private:
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 9d0f706..6e07b23 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -818,7 +818,7 @@ std::wstring BrowserView::GetWindowTitle() const {
return browser_->GetCurrentPageTitle();
}
-views::View* BrowserView::GetInitiallyFocusedView() const {
+views::View* BrowserView::GetInitiallyFocusedView() {
return toolbar_->GetLocationBarView();
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 0ece17e..e2e8063 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -214,7 +214,7 @@ class BrowserView : public BrowserWindow,
virtual bool CanMaximize() const;
virtual bool IsModal() const;
virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetInitiallyFocusedView() const;
+ virtual views::View* GetInitiallyFocusedView();
virtual bool ShouldShowWindowTitle() const;
virtual SkBitmap GetWindowIcon();
virtual bool ShouldShowWindowIcon() const;
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 58f9efe..2ff93b7 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -61,6 +61,10 @@ views::View* HtmlDialogView::GetContentsView() {
return this;
}
+views::View* HtmlDialogView::GetInitiallyFocusedView() {
+ return this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// HtmlDialogContentsDelegate implementation:
diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h
index 224f882..0b3946c 100644
--- a/chrome/browser/views/html_dialog_view.h
+++ b/chrome/browser/views/html_dialog_view.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H__
-#define CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
+#define CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
#include <string>
@@ -47,6 +47,7 @@ class HtmlDialogView
virtual std::wstring GetWindowTitle() const;
virtual void WindowClosing();
virtual views::View* GetContentsView();
+ virtual views::View* GetInitiallyFocusedView();
// Overridden from HtmlDialogContentsDelegate:
virtual GURL GetDialogContentURL() const;
@@ -91,8 +92,8 @@ class HtmlDialogView
// using this variable.
HtmlDialogContentsDelegate* delegate_;
- DISALLOW_EVIL_CONSTRUCTORS(HtmlDialogView);
+ DISALLOW_COPY_AND_ASSIGN(HtmlDialogView);
};
-#endif // CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H__
+#endif // CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc
index 07c3c708..2d49a8c 100644
--- a/chrome/browser/views/new_profile_dialog.cc
+++ b/chrome/browser/views/new_profile_dialog.cc
@@ -50,7 +50,7 @@ int NewProfileDialog::GetDialogButtons() const {
return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
}
-views::View* NewProfileDialog::GetInitiallyFocusedView() const {
+views::View* NewProfileDialog::GetInitiallyFocusedView() {
views::TextField* text_box = message_box_view_->text_box();
DCHECK(text_box);
return text_box;
diff --git a/chrome/browser/views/new_profile_dialog.h b/chrome/browser/views/new_profile_dialog.h
index 970a820..c8e4f02 100644
--- a/chrome/browser/views/new_profile_dialog.h
+++ b/chrome/browser/views/new_profile_dialog.h
@@ -31,7 +31,7 @@ class NewProfileDialog : public views::DialogDelegate,
// views::DialogDelegate methods.
virtual bool Accept();
virtual int GetDialogButtons() const;
- virtual views::View* GetInitiallyFocusedView() const;
+ virtual views::View* GetInitiallyFocusedView();
virtual bool IsDialogButtonEnabled(DialogButton button) const;
virtual std::wstring GetWindowTitle() const;
virtual void WindowClosing();
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index ee50b9d..6d829bb 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -54,7 +54,7 @@ class CookiesView : public views::View,
// views::WindowDelegate implementation:
virtual int GetDialogButtons() const { return DIALOGBUTTON_CANCEL; }
- virtual views::View* GetInitiallyFocusedView() const {
+ virtual views::View* GetInitiallyFocusedView() {
return search_field_;
}
virtual bool CanResize() const { return true; }
diff --git a/chrome/browser/views/select_profile_dialog.cc b/chrome/browser/views/select_profile_dialog.cc
index 50353ba..bfcfa1f 100644
--- a/chrome/browser/views/select_profile_dialog.cc
+++ b/chrome/browser/views/select_profile_dialog.cc
@@ -71,7 +71,7 @@ int SelectProfileDialog::GetDialogButtons() const {
return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
}
-views::View* SelectProfileDialog::GetInitiallyFocusedView() const {
+views::View* SelectProfileDialog::GetInitiallyFocusedView() {
return profile_combobox_;
}
diff --git a/chrome/browser/views/select_profile_dialog.h b/chrome/browser/views/select_profile_dialog.h
index f42df85..179e754 100644
--- a/chrome/browser/views/select_profile_dialog.h
+++ b/chrome/browser/views/select_profile_dialog.h
@@ -51,7 +51,7 @@ class SelectProfileDialog
virtual bool Cancel();
virtual views::View* GetContentsView();
virtual int GetDialogButtons() const;
- virtual views::View* GetInitiallyFocusedView() const;
+ virtual views::View* GetInitiallyFocusedView();
virtual std::wstring GetWindowTitle() const;
virtual bool IsModal() const { return false; }
diff --git a/chrome/views/dialog_delegate.cc b/chrome/views/dialog_delegate.cc
index 8c63340..42aaafc 100644
--- a/chrome/views/dialog_delegate.cc
+++ b/chrome/views/dialog_delegate.cc
@@ -18,7 +18,7 @@ int DialogDelegate::GetDefaultDialogButton() const {
return DIALOGBUTTON_NONE;
}
-View* DialogDelegate::GetInitiallyFocusedView() const {
+View* DialogDelegate::GetInitiallyFocusedView() {
// Focus the default button if any.
DialogClientView* dcv = GetDialogClientView();
int default_button = GetDefaultDialogButton();
diff --git a/chrome/views/dialog_delegate.h b/chrome/views/dialog_delegate.h
index a8b72e0f..d077e60 100644
--- a/chrome/views/dialog_delegate.h
+++ b/chrome/views/dialog_delegate.h
@@ -96,7 +96,7 @@ class DialogDelegate : public WindowDelegate {
virtual bool Accept() { return true; }
// Overridden from WindowDelegate:
- virtual View* GetInitiallyFocusedView() const;
+ virtual View* GetInitiallyFocusedView();
// Overridden from WindowDelegate:
virtual ClientView* CreateClientView(Window* window);
diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc
index 55786b6..e812a06 100644
--- a/chrome/views/hwnd_view.cc
+++ b/chrome/views/hwnd_view.cc
@@ -171,6 +171,10 @@ void HWNDView::VisibleBoundsInRootChanged() {
UpdateHWNDBounds();
}
+void HWNDView::Focus() {
+ ::SetFocus(hwnd_);
+}
+
void HWNDView::Paint(ChromeCanvas* canvas) {
// The area behind our window is black, so during a fast resize (where our
// content doesn't draw over the full size of our HWND, and the HWND
diff --git a/chrome/views/hwnd_view.h b/chrome/views/hwnd_view.h
index 701d228..ae33d0f 100644
--- a/chrome/views/hwnd_view.h
+++ b/chrome/views/hwnd_view.h
@@ -69,6 +69,8 @@ class HWNDView : public View {
// Notification that our visible bounds relative to the root has changed.
// This updates the bounds of the HWND.
virtual void VisibleBoundsInRootChanged();
+
+ virtual void Focus();
private:
// The hosted window handle.
diff --git a/chrome/views/window_delegate.h b/chrome/views/window_delegate.h
index d10dbf6..4c496bb 100644
--- a/chrome/views/window_delegate.h
+++ b/chrome/views/window_delegate.h
@@ -80,7 +80,7 @@ class WindowDelegate {
// Returns the view that should have the focus when the dialog is opened. If
// NULL no view is focused.
- virtual View* GetInitiallyFocusedView() const { return NULL; }
+ virtual View* GetInitiallyFocusedView() { return NULL; }
// Returns true if the window should show a title in the title bar.
virtual bool ShouldShowWindowTitle() const {