summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.h7
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc2
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h2
-rw-r--r--chrome/browser/views/bookmark_editor_view.h6
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc6
-rw-r--r--chrome/browser/views/bookmark_manager_view.h4
-rw-r--r--chrome/browser/views/bug_report_view.cc9
-rw-r--r--chrome/browser/views/bug_report_view.h12
-rw-r--r--chrome/browser/views/edit_keyword_controller.cc7
-rw-r--r--chrome/browser/views/edit_keyword_controller.h4
-rw-r--r--chrome/browser/views/find_bar_view.cc15
-rw-r--r--chrome/browser/views/find_bar_view.h4
-rw-r--r--chrome/browser/views/find_bar_win.cc18
-rw-r--r--chrome/browser/views/find_bar_win.h5
-rw-r--r--chrome/browser/views/input_window.cc8
-rw-r--r--chrome/browser/views/new_profile_dialog.h6
-rw-r--r--chrome/browser/views/options/cookies_view.cc11
-rw-r--r--chrome/browser/views/options/cookies_view.h12
-rw-r--r--chrome/browser/views/options/general_page_view.cc12
-rw-r--r--chrome/browser/views/options/general_page_view.h6
-rw-r--r--chrome/browser/views/shelf_item_dialog.h14
-rw-r--r--chrome/common/render_messages_internal.h5
-rw-r--r--chrome/renderer/render_view.cc8
-rw-r--r--chrome/renderer/render_view.h4
-rw-r--r--chrome/renderer/render_widget.cc2
-rw-r--r--chrome/renderer/render_widget.h10
-rw-r--r--chrome/views/controls/text_field.cc16
-rw-r--r--chrome/views/controls/text_field.h6
-rw-r--r--webkit/glue/webview.h14
-rw-r--r--webkit/glue/webview_impl.cc33
-rw-r--r--webkit/glue/webview_impl.h1
32 files changed, 190 insertions, 85 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 014737c..82b4622 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -638,6 +638,10 @@ void RenderViewHost::SetInitialFocus(bool reverse) {
Send(new ViewMsg_SetInitialFocus(routing_id(), reverse));
}
+void RenderViewHost::ClearFocusedNode() {
+ Send(new ViewMsg_ClearFocusedNode(routing_id()));
+}
+
void RenderViewHost::UpdateWebPreferences(const WebPreferences& prefs) {
Send(new ViewMsg_UpdateWebPreferences(routing_id(), prefs));
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index f70d449..ae7db54 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -343,6 +343,9 @@ class RenderViewHost : public RenderWidgetHost {
// Tells the renderer view to focus the first (last if reverse is true) node.
void SetInitialFocus(bool reverse);
+ // Clears the node that is currently focused (if any).
+ void ClearFocusedNode();
+
// Update render view specific (WebKit) preferences.
void UpdateWebPreferences(const WebPreferences& prefs);
@@ -648,7 +651,7 @@ class RenderViewHost : public RenderWidgetHost {
// Handles processing IPC messages request extension functions be executed.
ExtensionFunctionDispatcher extension_function_dispatcher_;
- DISALLOW_EVIL_CONSTRUCTORS(RenderViewHost);
+ DISALLOW_COPY_AND_ASSIGN(RenderViewHost);
};
#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index bf1e5350..23078c7 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index cac1f4e..19a8102 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index ed1b001..a307277 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -107,9 +107,9 @@ class BookmarkEditorView : public views::View,
// TextField::Controller methods.
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
- UINT flags) {}
+ UINT flags) { return false; }
// NativeButton.
virtual void ButtonPressed(views::Button* sender);
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index b9fccb1a..12150c6 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -456,7 +456,7 @@ void BookmarkManagerView::ContentsChanged(views::TextField* sender,
kSearchDelayMS);
}
-void BookmarkManagerView::HandleKeystroke(views::TextField* sender,
+bool BookmarkManagerView::HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key,
UINT repeat_count,
UINT flags) {
@@ -464,6 +464,8 @@ void BookmarkManagerView::HandleKeystroke(views::TextField* sender,
PerformSearch();
search_tf_->SelectAll();
}
+
+ return false;
}
void BookmarkManagerView::ShowContextMenu(views::View* source,
diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h
index bf0826a..9f986aa 100644
--- a/chrome/browser/views/bookmark_manager_view.h
+++ b/chrome/browser/views/bookmark_manager_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -136,7 +136,7 @@ class BookmarkManagerView : public views::View,
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
// If return has been pressed this performs an immediate search.
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
UINT flags);
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index 2ae5afa..1144065 100644
--- a/chrome/browser/views/bug_report_view.cc
+++ b/chrome/browser/views/bug_report_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -91,7 +91,7 @@ class BugReportComboBoxModel : public views::ComboBox::Model {
}
private:
- DISALLOW_EVIL_CONSTRUCTORS(BugReportComboBoxModel);
+ DISALLOW_COPY_AND_ASSIGN(BugReportComboBoxModel);
};
// Simple URLFetcher::Delegate to clean up URLFetcher on completion
@@ -107,7 +107,7 @@ class BugReportView::PostCleanup : public URLFetcher::Delegate {
const ResponseCookies& cookies,
const std::string& data);
private:
- DISALLOW_EVIL_CONSTRUCTORS(PostCleanup);
+ DISALLOW_COPY_AND_ASSIGN(PostCleanup);
};
BugReportView::PostCleanup::PostCleanup() {
@@ -260,9 +260,10 @@ void BugReportView::ContentsChanged(views::TextField* sender,
const std::wstring& new_contents) {
}
-void BugReportView::HandleKeystroke(views::TextField* sender,
+bool BugReportView::HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key,
UINT repeat_count, UINT flags) {
+ return false;
}
std::wstring BugReportView::GetDialogButtonLabel(DialogButton button) const {
diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h
index de3e4b4..22a2c42 100644
--- a/chrome/browser/views/bug_report_view.h
+++ b/chrome/browser/views/bug_report_view.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_BUGREPORT_VIEW_H_
-#define CHROME_BROWSER_VIEWS_BUGREPORT_VIEW_H_
+#ifndef CHROME_BROWSER_VIEWS_BUG_REPORT_VIEW_H_
+#define CHROME_BROWSER_VIEWS_BUG_REPORT_VIEW_H_
#include "chrome/browser/net/url_fetcher.h"
#include "chrome/views/controls/combo_box.h"
@@ -52,7 +52,7 @@ class BugReportView : public views::View,
// views::TextField::Controller implementation:
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key,
UINT repeat_count, UINT flags);
@@ -120,7 +120,7 @@ class BugReportView : public views::View,
// their original text so they don't have to type it again.
std::wstring old_report_text_;
- DISALLOW_EVIL_CONSTRUCTORS(BugReportView);
+ DISALLOW_COPY_AND_ASSIGN(BugReportView);
};
-#endif // CHROME_BROWSER_VIEWS_BUGREPORT_VIEW_H_
+#endif // CHROME_BROWSER_VIEWS_BUG_REPORT_VIEW_H_
diff --git a/chrome/browser/views/edit_keyword_controller.cc b/chrome/browser/views/edit_keyword_controller.cc
index 1968d27..1463777d 100644
--- a/chrome/browser/views/edit_keyword_controller.cc
+++ b/chrome/browser/views/edit_keyword_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -161,11 +161,12 @@ void EditKeywordController::ContentsChanged(TextField* sender,
UpdateImageViews();
}
-void EditKeywordController::HandleKeystroke(TextField* sender,
+bool EditKeywordController::HandleKeystroke(TextField* sender,
UINT message,
TCHAR key,
UINT repeat_count,
UINT flags) {
+ return false;
}
void EditKeywordController::Init() {
@@ -328,7 +329,7 @@ std::wstring EditKeywordController::GetURL() const {
bool EditKeywordController::IsKeywordValid() const {
std::wstring keyword = keyword_tf_->GetText();
if (keyword.empty())
- return true; // Always allow no keyword.
+ return true; // Always allow no keyword.
const TemplateURL* turl_with_keyword =
profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
return (turl_with_keyword == NULL || turl_with_keyword == template_url_);
diff --git a/chrome/browser/views/edit_keyword_controller.h b/chrome/browser/views/edit_keyword_controller.h
index a94422e..00a76fe 100644
--- a/chrome/browser/views/edit_keyword_controller.h
+++ b/chrome/browser/views/edit_keyword_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,7 +56,7 @@ class EditKeywordController : public views::TextField::Controller,
// valid.
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message,
TCHAR key,
UINT repeat_count,
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 3930a7e..e5fcf4f 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -473,11 +473,11 @@ void FindBarView::ContentsChanged(views::TextField* sender,
}
}
-void FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
+bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
TCHAR key, UINT repeat_count, UINT flags) {
// If the dialog is not visible, there is no reason to process keyboard input.
if (!container_->IsVisible())
- return;
+ return false;
switch (key) {
case VK_RETURN: {
@@ -491,7 +491,18 @@ void FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
}
break;
}
+#if defined(OS_WIN)
+ // TODO(port): Handle this for other platforms.
+ case VK_UP:
+ case VK_DOWN:
+ case VK_PRIOR: // Page up
+ case VK_NEXT: // Page down
+ container_->ForwardKeystrokeToWebpage(key);
+ return true; // Message has been handled. No further processing needed.
+#endif
}
+
+ return false;
}
void FindBarView::ResetMatchCountBackground() {
diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h
index 148fa83d..3ea4542 100644
--- a/chrome/browser/views/find_bar_view.h
+++ b/chrome/browser/views/find_bar_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -67,7 +67,7 @@ class FindBarView : public views::View,
// Overridden from views::TextField::Controller:
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender, UINT message,
+ virtual bool HandleKeystroke(views::TextField* sender, UINT message,
TCHAR key, UINT repeat_count, UINT flags);
// Set whether or not we're attempting to blend with the toolbar.
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index 5e1ed79..a1d01a9 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -232,6 +232,24 @@ void FindBarWin::MoveWindowIfNecessary(const gfx::Rect& selection_rect,
view_->SchedulePaint();
}
+void FindBarWin::ForwardKeystrokeToWebpage(TCHAR key) {
+ WebContents* contents = find_bar_controller_->web_contents();
+ if (!contents)
+ return;
+
+ RenderViewHost* render_view_host = contents->render_view_host();
+
+ // Make sure we don't have a text field element interfering with keyboard
+ // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom".
+ render_view_host->ClearFocusedNode();
+
+ HWND hwnd = contents->GetContentNativeView();
+ render_view_host->ForwardKeyboardEvent(
+ NativeWebKeyboardEvent(hwnd, WM_KEYDOWN, key, 0));
+ render_view_host->ForwardKeyboardEvent(
+ NativeWebKeyboardEvent(hwnd, WM_KEYUP, key, 0));
+}
+
////////////////////////////////////////////////////////////////////////////////
// FindBarWin, views::WidgetWin implementation:
diff --git a/chrome/browser/views/find_bar_win.h b/chrome/browser/views/find_bar_win.h
index 3fb4f75..d2f84fa 100644
--- a/chrome/browser/views/find_bar_win.h
+++ b/chrome/browser/views/find_bar_win.h
@@ -59,6 +59,11 @@ class FindBarWin : public views::FocusChangeListener,
// new |parent_hwnd|.
void SetFocusChangeListener(HWND parent_hwnd);
+ // Forwards keystrokes to the renderer. This is useful to make sure that
+ // arrow keys and PageUp and PageDown result in scrolling, instead of
+ // being eaten because the FindBar has focus.
+ void ForwardKeystrokeToWebpage(TCHAR key);
+
// FindBar implementation:
virtual FindBarController* GetFindBarController() const {
return find_bar_controller_;
diff --git a/chrome/browser/views/input_window.cc b/chrome/browser/views/input_window.cc
index f650320..8d8c24f 100644
--- a/chrome/browser/views/input_window.cc
+++ b/chrome/browser/views/input_window.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -45,7 +45,9 @@ class ContentView : public views::View,
// views::TextField::Controller overrides:
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField*, UINT, TCHAR, UINT, UINT) {}
+ virtual bool HandleKeystroke(views::TextField*, UINT, TCHAR, UINT, UINT) {
+ return false;
+ }
protected:
// views::View overrides:
@@ -69,7 +71,7 @@ class ContentView : public views::View,
// Helps us set focus to the first TextField in the window.
ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_;
- DISALLOW_EVIL_CONSTRUCTORS(ContentView);
+ DISALLOW_COPY_AND_ASSIGN(ContentView);
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/new_profile_dialog.h b/chrome/browser/views/new_profile_dialog.h
index da36728..868480e 100644
--- a/chrome/browser/views/new_profile_dialog.h
+++ b/chrome/browser/views/new_profile_dialog.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -39,9 +39,9 @@ class NewProfileDialog : public views::DialogDelegate,
// views::TextField::Controller methods.
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
- UINT flags) {}
+ UINT flags) { return false; }
// views::WindowDelegate methods.
virtual views::View* GetContentsView();
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index 2bdc149..f5c0a68 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -75,7 +75,7 @@ class CookiesTableModel : public views::TableModel {
views::TableModelObserver* observer_;
- DISALLOW_EVIL_CONSTRUCTORS(CookiesTableModel);
+ DISALLOW_COPY_AND_ASSIGN(CookiesTableModel);
};
///////////////////////////////////////////////////////////////////////////////
@@ -264,7 +264,7 @@ class CookiesTableView : public views::TableView {
// Our model, as a CookiesTableModel.
CookiesTableModel* cookies_model_;
- DISALLOW_EVIL_CONSTRUCTORS(CookiesTableView);
+ DISALLOW_COPY_AND_ASSIGN(CookiesTableView);
};
CookiesTableView::CookiesTableView(
@@ -353,7 +353,7 @@ class CookieInfoView : public views::View {
views::Label* expires_label_;
views::TextField* expires_value_field_;
- DISALLOW_EVIL_CONSTRUCTORS(CookieInfoView);
+ DISALLOW_COPY_AND_ASSIGN(CookieInfoView);
};
///////////////////////////////////////////////////////////////////////////////
@@ -620,7 +620,7 @@ void CookiesView::ContentsChanged(views::TextField* sender,
&CookiesView::UpdateSearchResults), kSearchFilterDelayMs);
}
-void CookiesView::HandleKeystroke(views::TextField* sender, UINT message,
+bool CookiesView::HandleKeystroke(views::TextField* sender, UINT message,
TCHAR key, UINT repeat_count, UINT flags) {
switch (key) {
case VK_ESCAPE:
@@ -631,6 +631,7 @@ void CookiesView::HandleKeystroke(views::TextField* sender, UINT message,
UpdateSearchResults();
break;
}
+ return false;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index ab8b213..2baed44 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_
#include "base/task.h"
#include "chrome/views/controls/button/button.h"
@@ -50,7 +50,7 @@ class CookiesView : public views::View,
// views::TextField::Controller implementation:
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
UINT flags);
@@ -112,7 +112,7 @@ class CookiesView : public views::View,
// window somewhere.
static views::Window* instance_;
- DISALLOW_EVIL_CONSTRUCTORS(CookiesView);
+ DISALLOW_COPY_AND_ASSIGN(CookiesView);
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H__
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc
index 564aef1..5257ad9 100644
--- a/chrome/browser/views/options/general_page_view.cc
+++ b/chrome/browser/views/options/general_page_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -96,7 +96,7 @@ class GeneralPageView::DefaultBrowserWorker
MessageLoop* ui_loop_;
MessageLoop* file_loop_;
- DISALLOW_EVIL_CONSTRUCTORS(GeneralPageView::DefaultBrowserWorker);
+ DISALLOW_COPY_AND_ASSIGN(GeneralPageView::DefaultBrowserWorker);
};
GeneralPageView::DefaultBrowserWorker::DefaultBrowserWorker(
@@ -239,7 +239,7 @@ class CustomHomePagesTableModel : public views::TableModel {
// Used in loading favicons.
CancelableRequestConsumer fav_icon_consumer_;
- DISALLOW_EVIL_CONSTRUCTORS(CustomHomePagesTableModel);
+ DISALLOW_COPY_AND_ASSIGN(CustomHomePagesTableModel);
};
// static
@@ -418,7 +418,7 @@ class SearchEngineListModel : public views::ComboBox::Model,
typedef std::vector<const TemplateURL*> TemplateURLs;
TemplateURLs template_urls_;
- DISALLOW_EVIL_CONSTRUCTORS(SearchEngineListModel);
+ DISALLOW_COPY_AND_ASSIGN(SearchEngineListModel);
};
SearchEngineListModel::SearchEngineListModel(Profile* profile)
@@ -614,10 +614,10 @@ void GeneralPageView::ContentsChanged(views::TextField* sender,
}
}
-void GeneralPageView::HandleKeystroke(views::TextField* sender,
+bool GeneralPageView::HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key,
UINT repeat_count, UINT flags) {
- // Not necessary.
+ return false;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index 2ec7f4e..4887e1b 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -51,7 +51,7 @@ class GeneralPageView : public OptionsPageView,
// views::TextField::Controller implementation:
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
UINT flags);
@@ -155,7 +155,7 @@ class GeneralPageView : public OptionsPageView,
friend DefaultBrowserWorker;
scoped_refptr<DefaultBrowserWorker> default_browser_worker_;
- DISALLOW_EVIL_CONSTRUCTORS(GeneralPageView);
+ DISALLOW_COPY_AND_ASSIGN(GeneralPageView);
};
#endif // CHROME_BROWSER_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_
diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h
index a90b593..9e5520d 100644
--- a/chrome/browser/views/shelf_item_dialog.h
+++ b/chrome/browser/views/shelf_item_dialog.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H__
-#define CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H__
+#ifndef CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H_
+#define CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H_
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/history/history.h"
@@ -67,9 +67,9 @@ class ShelfItemDialog : public views::View,
// TextField::Controller.
virtual void ContentsChanged(views::TextField* sender,
const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender,
+ virtual bool HandleKeystroke(views::TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
- UINT flags) {}
+ UINT flags) { return false; }
// Overridden from View.
virtual gfx::Size GetPreferredSize();
@@ -120,7 +120,7 @@ class ShelfItemDialog : public views::View,
// The delegate.
ShelfItemDialogDelegate* delegate_;
- DISALLOW_EVIL_CONSTRUCTORS(ShelfItemDialog);
+ DISALLOW_COPY_AND_ASSIGN(ShelfItemDialog);
};
-#endif // CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H__
+#endif // CHROME_BROWSER_VIEWS_SHELF_ITEM_DIALOG_H_
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 38184f8..894a554 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -564,6 +564,9 @@ IPC_BEGIN_MESSAGES(View)
// WEB_TEXT_DIRECTION_RTL RightToLeftWritingDirection ("ltr")
IPC_MESSAGE_ROUTED1(ViewMsg_SetTextDirection,
int /* direction */)
+
+ // Tells the renderer to clear the focused node (if any).
+ IPC_MESSAGE_ROUTED0(ViewMsg_ClearFocusedNode)
IPC_END_MESSAGES(View)
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e76d187..d0b8d28 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -441,6 +441,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse)
IPC_MESSAGE_HANDLER(ViewMsg_RequestSelectionText, OnRequestSelectionText)
+ IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
@@ -3011,6 +3012,11 @@ void RenderView::OnResize(const gfx::Size& new_size,
RenderWidget::OnResize(new_size, resizer_rect);
}
+void RenderView::OnClearFocusedNode() {
+ if (webview())
+ webview()->ClearFocusedNode();
+}
+
void RenderView::SendExtensionRequest(const std::string& name,
const std::string& args,
int callback_id,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 6a499ad..7e8e818 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -385,6 +385,8 @@ class RenderView : public RenderWidget,
void GetAudioVolume(int stream_id);
void SetAudioVolume(int stream_id, double left, double right);
+ void OnClearFocusedNode();
+
void SendExtensionRequest(const std::string& name, const std::string& args,
int callback_id, WebFrame* web_frame);
void OnExtensionResponse(int callback_id, const std::string& response);
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 9b05e19..81421d1 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 7ee2c04..84eb9b2 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_RENDER_WIDGET_H__
-#define CHROME_RENDERER_RENDER_WIDGET_H__
+#ifndef CHROME_RENDERER_RENDER_WIDGET_H_
+#define CHROME_RENDERER_RENDER_WIDGET_H_
#include <vector>
#include "base/basictypes.h"
@@ -265,7 +265,7 @@ class RenderWidget : public IPC::Channel::Listener,
// Holds all the needed plugin window moves for a scroll.
std::vector<WebPluginGeometry> plugin_window_moves_;
- DISALLOW_EVIL_CONSTRUCTORS(RenderWidget);
+ DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};
-#endif // CHROME_RENDERER_RENDER_WIDGET_H__
+#endif // CHROME_RENDERER_RENDER_WIDGET_H_
diff --git a/chrome/views/controls/text_field.cc b/chrome/views/controls/text_field.cc
index a83c1c0..5114d83c 100644
--- a/chrome/views/controls/text_field.cc
+++ b/chrome/views/controls/text_field.cc
@@ -805,13 +805,19 @@ void TextField::Edit::HandleKeystroke(UINT message,
UINT repeat_count,
UINT flags) {
ScopedFreeze freeze(this, GetTextObjectModel());
- OnBeforePossibleChange();
- DefWindowProc(message, key, MAKELPARAM(repeat_count, flags));
- OnAfterPossibleChange();
TextField::Controller* controller = parent_->GetController();
- if (controller)
- controller->HandleKeystroke(parent_, message, key, repeat_count, flags);
+ bool handled = false;
+ if (controller) {
+ handled =
+ controller->HandleKeystroke(parent_, message, key, repeat_count, flags);
+ }
+
+ if (!handled) {
+ OnBeforePossibleChange();
+ DefWindowProc(message, key, MAKELPARAM(repeat_count, flags));
+ OnAfterPossibleChange();
+ }
}
void TextField::Edit::OnBeforePossibleChange() {
diff --git a/chrome/views/controls/text_field.h b/chrome/views/controls/text_field.h
index 35abf3f..2447e92 100644
--- a/chrome/views/controls/text_field.h
+++ b/chrome/views/controls/text_field.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,9 @@ class TextField : public View {
const std::wstring& new_contents) = 0;
// This method is called to get notified about keystrokes in the edit.
- virtual void HandleKeystroke(TextField* sender,
+ // This method returns true if the message was handled and should not be
+ // processed further. If it returns false the processing continues.
+ virtual bool HandleKeystroke(TextField* sender,
UINT message, TCHAR key, UINT repeat_count,
UINT flags) = 0;
};
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index 35c7fe8..99ad41e 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_WEBVIEW_H__
-#define WEBKIT_GLUE_WEBVIEW_H__
+#ifndef WEBKIT_GLUE_WEBVIEW_H_
+#define WEBKIT_GLUE_WEBVIEW_H_
#include <string>
#include <vector>
@@ -129,6 +129,10 @@ class WebView : public WebWidget {
// bug is fixed.
virtual void StoreFocusForFrame(WebFrame* frame) = 0;
+ // Clears the focused node (and selection if a text field is focused) to
+ // ensure that a text field on the page is not eating keystrokes we send it.
+ virtual void ClearFocusedNode() = 0;
+
// Requests the webview to download an image. When done, the delegate is
// notified by way of DidDownloadImage. Returns true if the request was
// successfully started, false otherwise. id is used to uniquely identify the
@@ -218,7 +222,7 @@ class WebView : public WebWidget {
virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0;
private:
- DISALLOW_EVIL_CONSTRUCTORS(WebView);
+ DISALLOW_COPY_AND_ASSIGN(WebView);
};
-#endif // WEBKIT_GLUE_WEBVIEW_H__
+#endif // WEBKIT_GLUE_WEBVIEW_H_
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 408246b..440830f 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -1075,6 +1075,39 @@ void WebViewImpl::SetBackForwardListSize(int size) {
page_->backForwardList()->setCapacity(size);
}
+void WebViewImpl::ClearFocusedNode() {
+ // Get the last focused frame or the mainframe.
+ RefPtr<Frame> frame = last_focused_frame_;
+ if (!frame.get() && page_.get())
+ frame = page_->mainFrame();
+ if (!frame.get())
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document.get())
+ return;
+
+ RefPtr<Node> old_focused_node = document->focusedNode();
+
+ // Clear the focused node.
+ document->setFocusedNode(NULL);
+
+ if (!old_focused_node.get())
+ return;
+
+ // If a text field has focus, we need to make sure the selection controller
+ // knows to remove selection from it. Otherwise, the text field is still
+ // processing keyboard events even though focus has been moved to the page and
+ // keystrokes get eaten as a result.
+ if (old_focused_node->hasTagName(HTMLNames::textareaTag) ||
+ (old_focused_node->hasTagName(HTMLNames::inputTag) &&
+ static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) {
+ // Clear the selection.
+ SelectionController* selection = frame->selection();
+ selection->clear();
+ }
+}
+
void WebViewImpl::SetFocus(bool enable) {
if (enable) {
// Getting the focused frame will have the side-effect of setting the main
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index e52a8d2..413445e 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -70,6 +70,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event);
virtual void MouseCaptureLost();
virtual void SetFocus(bool enable);
+ virtual void ClearFocusedNode();
virtual void StoreFocusForFrame(WebFrame* frame);
virtual bool ImeSetComposition(int string_type,
int cursor_position,