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

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

Issue 6277020: keyboard: Update the visibility after tab-switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update the property of the tab-contents that triggered the focus-change notification. 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 545f31cc28923a2116a3dff889799778bdae21da..6362353be30201d5c7a6bfa1fb50c4f9a2294aa9 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -8,7 +8,9 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/touch/frame/keyboard_container_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/notification_service.h"
@@ -19,6 +21,11 @@ namespace {
const int kKeyboardHeight = 300;
+PropertyAccessor<bool>* GetFocusedStateAccessor() {
+ static PropertyAccessor<bool> state;
+ return &state;
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -35,9 +42,15 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
registrar_.Add(this,
NotificationType::FOCUS_CHANGED_IN_PAGE,
NotificationService::AllSources());
+ registrar_.Add(this,
+ NotificationType::TAB_CONTENTS_DESTROYED,
+ NotificationService::AllSources());
+
+ browser_view->browser()->tabstrip_model()->AddObserver(this);
}
TouchBrowserFrameView::~TouchBrowserFrameView() {
+ browser_view()->browser()->tabstrip_model()->RemoveObserver(this);
}
void TouchBrowserFrameView::Layout() {
@@ -98,6 +111,17 @@ void TouchBrowserFrameView::UpdateKeyboardAndLayout(bool should_show_keyboard) {
}
}
+void TouchBrowserFrameView::TabSelectedAt(TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index,
+ bool user_gesture) {
+ TabContents* contents = new_contents->tab_contents();
+ bool* editable = GetFocusedStateAccessor()->GetProperty(
+ contents->property_bag());
+ UpdateKeyboardAndLayout(editable ? *editable : false);
+}
+
+
void TouchBrowserFrameView::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -106,15 +130,26 @@ void TouchBrowserFrameView::Observe(NotificationType type,
// Only modify the keyboard state if the currently active tab sent the
// notification.
const TabContents* tab_contents = browser->GetSelectedTabContents();
- if (tab_contents &&
- tab_contents->render_view_host() ==
- Source<RenderViewHost>(source).ptr())
- UpdateKeyboardAndLayout(*Details<const bool>(details).ptr());
+ RenderViewHost* host = Source<RenderViewHost>(source).ptr();
+ const bool editable = *Details<const bool>(details).ptr();
+
+ if (tab_contents && tab_contents->render_view_host() == host) {
+ UpdateKeyboardAndLayout(editable);
+ }
+
+ // Save the state of the focused field so that the keyboard visibility
+ // can be determined after tab switching.
+ TabContents* source_tab = static_cast<TabContents*>(host->delegate());
sky 2011/01/26 18:07:43 Casts like this are dangerous. Could we change FOC
brettw 2011/01/26 20:18:07 I agree, we should never have this type of cast.
+ GetFocusedStateAccessor()->SetProperty(
+ source_tab->property_bag(), editable);
} else if (type == NotificationType::NAV_ENTRY_COMMITTED) {
Browser* source_browser = Browser::GetBrowserForController(
Source<NavigationController>(source).ptr(), NULL);
// If the Browser for the keyboard has navigated, hide the keyboard.
if (source_browser == browser)
UpdateKeyboardAndLayout(false);
+ } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
+ GetFocusedStateAccessor()->DeleteProperty(
+ Source<TabContents>(source).ptr()->property_bag());
sadrul 2011/01/26 17:43:10 Or should this be done from TabDetachedAt and TabR
sky 2011/01/26 18:07:43 This is better.
}
}
« 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