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

Unified Diff: chrome/browser/views/tab_contents/tab_contents_view_win.cc

Issue 146093: Relanding focus manager refactoring (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/views/tab_contents/tab_contents_view_win.cc
===================================================================
--- chrome/browser/views/tab_contents/tab_contents_view_win.cc (revision 19153)
+++ chrome/browser/views/tab_contents/tab_contents_view_win.cc (working copy)
@@ -53,7 +53,8 @@
TabContentsViewWin::TabContentsViewWin(TabContents* tab_contents)
: TabContentsView(tab_contents),
- ignore_next_char_event_(false) {
+ ignore_next_char_event_(false),
+ focus_manager_(NULL) {
last_focused_view_storage_id_ =
views::ViewStorage::GetSharedInstance()->CreateStorageID();
}
@@ -68,12 +69,21 @@
view_storage->RemoveView(last_focused_view_storage_id_);
}
+void TabContentsViewWin::Unparent() {
+ // Remember who our FocusManager is, we won't be able to access it once
+ // unparented.
+ focus_manager_ = views::WidgetWin::GetFocusManager();
+ // Note that we do not DCHECK on focus_manager_ as it may be NULL when used
+ // with an external tab container.
+ ::SetParent(GetNativeView(), NULL);
+}
+
void TabContentsViewWin::CreateView() {
set_delete_on_destroy(false);
// Since we create these windows parented to the desktop window initially, we
// don't want to create them initially visible.
set_window_style(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- WidgetWin::Init(GetDesktopWindow(), gfx::Rect(), false);
+ WidgetWin::Init(GetDesktopWindow(), gfx::Rect());
// Remove the root view drop target so we can register our own.
RevokeDragDrop(GetNativeView());
@@ -233,7 +243,7 @@
void TabContentsViewWin::Focus() {
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
if (tab_contents()->interstitial_page()) {
tab_contents()->interstitial_page()->Focus();
@@ -269,7 +279,7 @@
view_storage->RemoveView(last_focused_view_storage_id_);
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
if (focus_manager) {
// |focus_manager| can be NULL if the tab has been detached but still
// exists.
@@ -301,7 +311,7 @@
SetInitialFocus();
} else {
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
// If you hit this DCHECK, please report it to Jay (jcampan).
DCHECK(focus_manager != NULL) << "No focus manager when restoring focus.";
@@ -333,7 +343,7 @@
void TabContentsViewWin::TakeFocus(bool reverse) {
if (!tab_contents()->delegate()->TakeFocus(reverse)) {
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
// We may not have a focus manager if the tab has been switched before this
// message arrived.
@@ -357,7 +367,7 @@
// a keyboard shortcut that we have to process.
if (event.type == WebInputEvent::RawKeyDown) {
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
// We may not have a focus_manager at this point (if the tab has been
// switched by the time this message returned).
if (focus_manager) {
@@ -393,6 +403,19 @@
event.os_event.lParam);
}
+views::FocusManager* TabContentsViewWin::GetFocusManager() {
+ views::FocusManager* focus_manager = WidgetWin::GetFocusManager();
+ if (focus_manager) {
+ // If focus_manager_ is non NULL, it means we have been reparented, in which
+ // case its value may not be valid anymore.
+ focus_manager_ = NULL;
+ return focus_manager;
+ }
+
+ DCHECK(focus_manager_);
+ return focus_manager_;
+}
+
void TabContentsViewWin::ShowContextMenu(const ContextMenuParams& params) {
// Allow delegates to handle the context menu operation first.
if (tab_contents()->delegate()->HandleContextMenu(params))

Powered by Google App Engine
This is Rietveld 408576698