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

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: DeleteProperty when tab is destroyed. 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..b2ae7ba0046a340f0e0fd2488dadf3946b63b6d3 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,16 @@ 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();
+ UpdateKeyboardAndLayout(GetFocusedStateAccessor()->GetProperty(
+ contents->property_bag()));
+}
+
+
void TouchBrowserFrameView::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -105,16 +128,26 @@ void TouchBrowserFrameView::Observe(NotificationType type,
if (type == NotificationType::FOCUS_CHANGED_IN_PAGE) {
// 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());
+ TabContents* tab_contents = browser->GetSelectedTabContents();
+ if (tab_contents) {
+ const bool editable = *Details<const bool>(details).ptr();
+ if (tab_contents->render_view_host() ==
+ Source<RenderViewHost>(source).ptr())
+ UpdateKeyboardAndLayout(editable);
+
+ // Save the state of the focused field so that the keyboard visibility
+ // can be determined after tab switching.
+ GetFocusedStateAccessor()->SetProperty(
sky 2011/01/26 16:40:08 This code is problematic if focus changes on a bac
sadrul 2011/01/26 17:43:10 Indeed! I made the change to update the property-b
+ tab_contents->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());
}
}
« 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