Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Unified Diff: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc

Issue 6384004: Browser should get notified if a views textfield changes focus. In addition, (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Modified according to comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
index 3838b4f6883f50634210874bfd8cab58b3655cec..587d06b6401f392313c79b4e34195e24cd1a083e 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -16,6 +16,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#include "gfx/rect.h"
+#include "views/controls/textfield/textfield.h"
namespace {
@@ -35,7 +36,8 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
: OpaqueBrowserFrameView(frame, browser_view),
keyboard_showing_(false),
- keyboard_(NULL) {
+ keyboard_(NULL),
+ focus_listener_added_(false) {
registrar_.Add(this,
NotificationType::NAV_ENTRY_COMMITTED,
NotificationService::AllSources());
@@ -63,6 +65,16 @@ void TouchBrowserFrameView::Layout() {
keyboard_->SetBounds(GetBoundsForReservedArea());
}
+void TouchBrowserFrameView::FocusWillChange(views::View* focused_before,
+ views::View* focused_now) {
+ if (!focused_before ||
+ (focused_now && GetKeyboardType(focused_now)
+ != GetKeyboardType(focused_before))) {
+ // TODO(varunjain): support other types of keyboard.
+ UpdateKeyboardAndLayout(GetKeyboardType(focused_now) == GENERIC);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// TouchBrowserFrameView, protected:
int TouchBrowserFrameView::GetReservedHeight() const {
@@ -72,6 +84,24 @@ int TouchBrowserFrameView::GetReservedHeight() const {
return 0;
}
+void TouchBrowserFrameView::ViewHierarchyChanged(bool is_add,
+ View* parent,
+ View* child) {
+ OpaqueBrowserFrameView::ViewHierarchyChanged(is_add, parent, child);
+ if (!GetFocusManager() || child != this)
oshima 2011/02/04 10:15:27 child != this is not necessary. This does not work
varunjain 2011/02/04 16:38:46 Done.
+ return;
+
+ if (is_add && !focus_listener_added_) {
+ // Add focus listener when this view is added to the hierarchy.
+ GetFocusManager()->AddFocusChangeListener(this);
+ focus_listener_added_ = true;
+ } else if (!is_add && focus_listener_added_) {
+ // Remove focus listener when this view is removed from the hierarchy.
+ GetFocusManager()->RemoveFocusChangeListener(this);
+ focus_listener_added_ = false;
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// TouchBrowserFrameView, private:
@@ -152,3 +182,11 @@ void TouchBrowserFrameView::Observe(NotificationType type,
Source<TabContents>(source).ptr()->property_bag());
}
}
+
+TouchBrowserFrameView::VirtualKeyboardType
+ TouchBrowserFrameView::GetKeyboardType(views::View* view) {
+ if (view->GetClassName().compare(views::Textfield::kViewClassName) == 0)
+ return GENERIC;
+ else
Ben Goodger (Google) 2011/02/04 15:57:22 nit: no else after return
varunjain 2011/02/04 16:38:46 Done.
+ return NONE;
+}

Powered by Google App Engine
This is Rietveld 408576698