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

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: fixed merge conflicts 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
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b4edbc6c5e0a63f3c767b7f0e5650aeac83c4a0d..12fc62c71296177dde794df2d88cebe241bd5c46 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -16,11 +16,18 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#include "ui/gfx/rect.h"
+#include "views/controls/textfield/textfield.h"
namespace {
const int kKeyboardHeight = 300;
+TouchBrowserFrameView::VirtualKeyboardType GetKeyboardType(views::View* view) {
+ if (view->GetClassName().compare(views::Textfield::kViewClassName) == 0)
+ return TouchBrowserFrameView::GENERIC;
+ return TouchBrowserFrameView::NONE;
+}
+
PropertyAccessor<bool>* GetFocusedStateAccessor() {
static PropertyAccessor<bool> state;
return &state;
@@ -35,6 +42,7 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
: OpaqueBrowserFrameView(frame, browser_view),
keyboard_showing_(false),
+ focus_listener_added_(false),
keyboard_(NULL) {
registrar_.Add(this,
NotificationType::NAV_ENTRY_COMMITTED,
@@ -63,6 +71,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 +90,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())
+ 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:
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698