summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 18:48:00 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 18:48:00 +0000
commit82166b65c8cdd7cb855c2d018be8c6c815324af6 (patch)
treef96034ed91ce66d6a3ba2afa07cdd4be1e55b264 /chrome/browser/views
parent7811b768ff61d58153a198a273cdb39581a77542 (diff)
downloadchromium_src-82166b65c8cdd7cb855c2d018be8c6c815324af6.zip
chromium_src-82166b65c8cdd7cb855c2d018be8c6c815324af6.tar.gz
chromium_src-82166b65c8cdd7cb855c2d018be8c6c815324af6.tar.bz2
This CL removes the last (major) Windows specific part out of the focus manager.
It was previously landed and reverted because it broke the reliability tests. http://codereview.chromium.org/125148 The breakage was caused by constrained windows not getting a hold of the FocusManager when in unparented tabs. The fix is to ensure unparented tab still have a way to access their FocusManager for proper closure. Files changed from the previous patch that need reviewing: native_tab_contents_container_win.cc tab_contents_view_win.h tab_contents_view_win.cc BUG=None TEST=Run all tests (unit, ui, interactive). Extensively test the focus in Chrome. Review URL: http://codereview.chromium.org/146093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_win.cc2
-rw-r--r--chrome/browser/views/blocked_popup_container_view_win.cc2
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc4
-rw-r--r--chrome/browser/views/browser_bubble_win.cc4
-rw-r--r--chrome/browser/views/constrained_window_win.cc38
-rw-r--r--chrome/browser/views/constrained_window_win.h6
-rw-r--r--chrome/browser/views/download_started_animation_win.cc2
-rw-r--r--chrome/browser/views/find_bar_win.cc5
-rw-r--r--chrome/browser/views/find_bar_win_browsertest.cc5
-rw-r--r--chrome/browser/views/first_run_bubble.cc8
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.cc2
-rw-r--r--chrome/browser/views/info_bubble.cc10
-rw-r--r--chrome/browser/views/infobars/infobars.cc5
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc3
-rw-r--r--chrome/browser/views/status_bubble_views.cc2
-rw-r--r--chrome/browser/views/tab_contents/native_tab_contents_container_win.cc4
-rwxr-xr-xchrome/browser/views/tab_contents/tab_contents_view_win.cc40
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.h11
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc2
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc2
-rw-r--r--chrome/browser/views/tabs/native_view_photobooth_win.cc2
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc3
22 files changed, 75 insertions, 87 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc
index 02d3118..e28e0a5 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc
@@ -28,7 +28,7 @@ void AutocompletePopupWin::Init(AutocompleteEditViewWin* edit_view,
views::View* contents) {
// Create the popup
WidgetWin::Init(edit_view->parent_view()->GetWidget()->GetNativeView(),
- contents_->GetPopupBounds(), false);
+ contents_->GetPopupBounds());
// The contents is owned by the LocationBarView.
contents_->SetParentOwned(false);
SetContentsView(contents_);
diff --git a/chrome/browser/views/blocked_popup_container_view_win.cc b/chrome/browser/views/blocked_popup_container_view_win.cc
index 8e2837e..29240de 100644
--- a/chrome/browser/views/blocked_popup_container_view_win.cc
+++ b/chrome/browser/views/blocked_popup_container_view_win.cc
@@ -398,7 +398,7 @@ BlockedPopupContainerViewWin::BlockedPopupContainerViewWin(
set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
WidgetWin::Init(GetModel()->GetConstrainingContents(NULL)->GetNativeView(),
- gfx::Rect(), false);
+ gfx::Rect());
SetContentsView(container_view_);
SetPosition();
}
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index 69af750..ba101f1a 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -182,9 +182,7 @@ void BookmarkBubbleView::DidChangeBounds(const gfx::Rect& previous,
void BookmarkBubbleView::BubbleShown() {
DCHECK(GetWidget());
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetWidget()->GetNativeView());
- focus_manager->RegisterAccelerator(
+ GetFocusManager()->RegisterAccelerator(
views::Accelerator(VK_RETURN, false, false, false), this);
title_tf_->RequestFocus();
diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc
index 7b47fe9..e72545b 100644
--- a/chrome/browser/views/browser_bubble_win.cc
+++ b/chrome/browser/views/browser_bubble_win.cc
@@ -24,9 +24,7 @@ void BrowserBubble::InitPopup() {
#endif
// A focus manager is necessary if you want to be able to handle various
// mouse events properly.
- pop->Init(frame_native_view_,
- bounds_,
- true); // Give the widget a focus manager.
+ pop->Init(frame_native_view_, bounds_);
pop->SetContentsView(view_);
popup_.reset(pop);
Reposition();
diff --git a/chrome/browser/views/constrained_window_win.cc b/chrome/browser/views/constrained_window_win.cc
index f641f6f..8a68c1e 100644
--- a/chrome/browser/views/constrained_window_win.cc
+++ b/chrome/browser/views/constrained_window_win.cc
@@ -626,7 +626,6 @@ ConstrainedWindowWin::ConstrainedWindowWin(
owner_(owner) {
GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
- focus_restoration_disabled_ = false;
set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION |
WS_THICKFRAME | WS_SYSMENU);
set_focus_on_creation(false);
@@ -638,48 +637,13 @@ ConstrainedWindowWin::ConstrainedWindowWin(
void ConstrainedWindowWin::ActivateConstrainedWindow() {
// Other pop-ups are simply moved to the front of the z-order.
SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
-
- // Store the focus of our parent focus manager so we can restore it when we
- // close.
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- DCHECK(focus_manager);
- focus_manager = focus_manager->GetParentFocusManager();
- if (focus_manager) {
- // We could not have a parent focus manager if the ConstrainedWindow is
- // displayed in a tab that is not currently selected.
- // TODO(jcampan): we should store the ConstrainedWindow active events in
- // that case and replay them when the TabContents becomes selected.
- focus_manager->StoreFocusedView();
-
- // Give our window the focus so we get keyboard messages.
- ::SetFocus(GetNativeView());
- }
}
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowWin, views::WidgetWin overrides:
void ConstrainedWindowWin::OnDestroy() {
- // We do this here, rather than |Close|, since the window may be destroyed in
- // a way other than by some other component calling Close, e.g. by the native
- // window hierarchy closing. We are guaranteed to receive a WM_DESTROY
- // message regardless of how the window is closed.
- // Note that when we get this message, the focus manager of the
- // ConstrainedWindow has already been destroyed (by the processing of
- // WM_DESTROY in FocusManager). So the FocusManager we retrieve here is the
- // parent one (the one from the top window).
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- if (focus_manager) {
- // We may not have a focus manager if:
- // - we are hidden when closed (the TabContent would be detached).
- // - the tab has been closed and we are closed as a result.
- // TODO(jcampan): when hidden, we should modify the stored focus of the tab
- // so when it becomes visible again we retrieve the focus appropriately.
- if (!focus_restoration_disabled_)
- focus_manager->RestoreFocusedView();
- }
+ // TODO(jcampan): figure out focus restoration
// Make sure we call super so that it can do its cleanup.
WindowWin::OnDestroy();
diff --git a/chrome/browser/views/constrained_window_win.h b/chrome/browser/views/constrained_window_win.h
index a91a736..c331322 100644
--- a/chrome/browser/views/constrained_window_win.h
+++ b/chrome/browser/views/constrained_window_win.h
@@ -24,7 +24,7 @@ class WindowDelegate;
// a child HWND with a custom window frame.
//
class ConstrainedWindowWin : public ConstrainedWindow,
- public views::WindowWin {
+ public views::WindowWin {
public:
virtual ~ConstrainedWindowWin();
@@ -61,10 +61,6 @@ class ConstrainedWindowWin : public ConstrainedWindow,
// The TabContents that owns and constrains this ConstrainedWindow.
TabContents* owner_;
- // True if focus should not be restored to whatever view was focused last
- // when this window is destroyed.
- bool focus_restoration_disabled_;
-
// Current "anchor point", the lower right point at which we render
// the constrained title bar.
gfx::Point anchor_point_;
diff --git a/chrome/browser/views/download_started_animation_win.cc b/chrome/browser/views/download_started_animation_win.cc
index 4de387e..ec71683 100644
--- a/chrome/browser/views/download_started_animation_win.cc
+++ b/chrome/browser/views/download_started_animation_win.cc
@@ -106,7 +106,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin(
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TRANSPARENT);
popup_->SetOpacity(0x00);
- popup_->Init(tab_contents_->GetNativeView(), rc, false);
+ popup_->Init(tab_contents_->GetNativeView(), rc);
popup_->SetContentsView(this);
Reposition();
popup_->Show();
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index 51e1b20..4272ef7 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -95,12 +95,13 @@ FindBarWin::FindBarWin(BrowserView* browser_view)
// Initialize the host.
host_.reset(new Host(this));
- host_->Init(browser_view->GetWidget()->GetNativeView(), gfx::Rect(), false);
+ host_->Init(browser_view->GetWidget()->GetNativeView(), gfx::Rect());
host_->SetContentsView(view_);
// Start listening to focus changes, so we can register and unregister our
// own handler for Escape.
- focus_manager_ = views::FocusManager::GetFocusManager(host_->GetNativeView());
+ focus_manager_ =
+ views::FocusManager::GetFocusManagerForNativeView(host_->GetNativeView());
focus_manager_->AddFocusChangeListener(this);
// Stores the currently focused view, and tracks focus changes so that we can
diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_win_browsertest.cc
index 6b4c265..de66f7a 100644
--- a/chrome/browser/views/find_bar_win_browsertest.cc
+++ b/chrome/browser/views/find_bar_win_browsertest.cc
@@ -573,8 +573,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
GURL url = server->TestServerPageW(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
- views::FocusManager* focus_manager = views::FocusManager::GetFocusManager(
- browser()->window()->GetNativeHandle());
+ gfx::NativeView browser_view = browser()->window()->GetNativeHandle();
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(browser_view);
// See where Escape is registered.
views::Accelerator escape(VK_ESCAPE, false, false, false);
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index ba8edb2..b79c665 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -343,9 +343,7 @@ void FirstRunBubble::InfoBubbleClosing(InfoBubble* info_bubble,
if (!IsWindowEnabled(GetParent()))
::EnableWindow(GetParent(), true);
enable_window_method_factory_.RevokeAll();
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- focus_manager->RemoveFocusChangeListener(view_);
+ GetFocusManager()->RemoveFocusChangeListener(view_);
}
// static
@@ -362,9 +360,7 @@ FirstRunBubble* FirstRunBubble::Show(Profile* profile, views::Window* parent,
window->set_view(view);
window->Init(parent, position_relative_to, view);
window->ShowWindow(SW_SHOW);
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(window->GetNativeView());
- focus_manager->AddFocusChangeListener(view);
+ window->GetFocusManager()->AddFocusChangeListener(view);
view->BubbleShown();
return window;
}
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index 854c3dd..907a791 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/views/fullscreen_exit_bubble.cc
@@ -144,7 +144,7 @@ FullscreenExitBubble::FullscreenExitBubble(
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
- popup_->Init(frame->GetNativeView(), GetPopupRect(false), false);
+ popup_->Init(frame->GetNativeView(), GetPopupRect(false));
popup_->SetContentsView(view_);
popup_->Show(); // This does not activate the popup.
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 5930801..7fa99de 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -133,7 +133,7 @@ void InfoBubble::Init(views::Window* parent,
content_view_->CalculateWindowBoundsAndAjust(position_relative_to);
#if defined(OS_WIN)
- WidgetWin::Init(parent->GetNativeWindow(), bounds, true);
+ WidgetWin::Init(parent->GetNativeWindow(), bounds);
#else
WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), bounds, true);
#endif
@@ -155,11 +155,9 @@ void InfoBubble::Init(views::Window* parent,
#if defined(OS_WIN)
// Register the Escape accelerator for closing.
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- focus_manager->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false,
- false, false),
- this);
+ GetFocusManager()->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false,
+ false, false),
+ this);
// Set initial alpha value of the layered window.
SetLayeredWindowAttributes(GetNativeView(),
RGB(0xFF, 0xFF, 0xFF),
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index 48f866d..8c67150 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -203,9 +203,8 @@ void InfoBar::InfoBarAdded() {
// focus so that we can restore focus when we're removed.
views::Widget* widget = GetWidget();
if (widget) {
- focus_tracker_.reset(
- new views::ExternalFocusTracker(this,
- views::FocusManager::GetFocusManager(widget->GetNativeView())));
+ focus_tracker_.reset(new views::ExternalFocusTracker(this,
+ GetFocusManager()));
}
#endif
}
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index 636d724..ce3c7b0 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -259,8 +259,7 @@ bool ShelfItemDialog::AcceleratorPressed(
if (accelerator.GetKeyCode() == VK_ESCAPE) {
window()->Close();
} else if (accelerator.GetKeyCode() == VK_RETURN) {
- views::FocusManager* fm = views::FocusManager::GetFocusManager(
- GetWidget()->GetNativeView());
+ views::FocusManager* fm = GetFocusManager();
if (fm->GetFocusedView() == url_table_) {
// Return on table behaves like a double click.
OnDoubleClick();
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 933c6e5..ecaba94 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -485,7 +485,7 @@ void StatusBubbleViews::Init() {
WS_EX_TRANSPARENT |
l10n_util::GetExtendedTooltipStyles());
popup->SetOpacity(0x00);
- popup->Init(frame_->GetNativeView(), gfx::Rect(), false);
+ popup->Init(frame_->GetNativeView(), gfx::Rect());
popup->SetContentsView(view_);
Reposition();
popup->Show();
diff --git a/chrome/browser/views/tab_contents/native_tab_contents_container_win.cc b/chrome/browser/views/tab_contents/native_tab_contents_container_win.cc
index 1e4933f..dad95e4 100644
--- a/chrome/browser/views/tab_contents/native_tab_contents_container_win.cc
+++ b/chrome/browser/views/tab_contents/native_tab_contents_container_win.cc
@@ -8,6 +8,8 @@
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/tab_contents/tab_contents_container.h"
+#include "chrome/browser/views/tab_contents/tab_contents_view_win.h"
+
#include "views/focus/focus_manager.h"
////////////////////////////////////////////////////////////////////////////////
@@ -44,7 +46,7 @@ void NativeTabContentsContainerWin::DetachContents(TabContents* contents) {
ShowWindow(container_hwnd, SW_HIDE);
// Reset the parent to NULL to ensure hidden tabs don't receive messages.
- ::SetParent(container_hwnd, NULL);
+ static_cast<TabContentsViewWin*>(contents->view())->Unparent();
}
// Now detach the TabContents.
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index f4e76b2..0026c6b 100755
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -53,7 +53,8 @@ TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
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 @@ TabContentsViewWin::~TabContentsViewWin() {
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());
@@ -236,7 +246,7 @@ void TabContentsViewWin::SizeContents(const gfx::Size& size) {
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();
@@ -272,7 +282,7 @@ void TabContentsViewWin::StoreFocus() {
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.
@@ -304,7 +314,7 @@ void TabContentsViewWin::RestoreFocus() {
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.";
@@ -336,7 +346,7 @@ void TabContentsViewWin::GotFocus() {
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.
@@ -360,7 +370,7 @@ void TabContentsViewWin::HandleKeyboardEvent(
// 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) {
@@ -396,6 +406,22 @@ void TabContentsViewWin::HandleKeyboardEvent(
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;
+ }
+ // TODO(jcampan): we should DCHECK on focus_manager_, as it should not be
+ // NULL. We are not doing it as it breaks some unit-tests. We should
+ // probably have an empty TabContentView implementation for the unit-tests,
+ // that would prevent that code being executed in the unit-test case.
+ // 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))
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.h b/chrome/browser/views/tab_contents/tab_contents_view_win.h
index 236e237a..4b5ade1 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.h
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.h
@@ -26,6 +26,10 @@ class TabContentsViewWin : public TabContentsView,
explicit TabContentsViewWin(TabContents* tab_contents);
virtual ~TabContentsViewWin();
+ // Reset the native parent of this view to NULL. Unparented windows should
+ // not receive any messages.
+ virtual void Unparent();
+
// TabContentsView implementation --------------------------------------------
virtual void CreateView();
@@ -52,6 +56,9 @@ class TabContentsViewWin : public TabContentsView,
virtual void TakeFocus(bool reverse);
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+ // WidgetWin overridde.
+ virtual views::FocusManager* GetFocusManager();
+
private:
// Windows events ------------------------------------------------------------
@@ -104,6 +111,10 @@ class TabContentsViewWin : public TabContentsView,
// The context menu. Callbacks are asynchronous so we need to keep it around.
scoped_ptr<RenderViewContextMenuWin> context_menu_;
+ // The FocusManager associated with this tab. Stored as it is not directly
+ // accessible when unparented.
+ views::FocusManager* focus_manager_;
+
DISALLOW_COPY_AND_ASSIGN(TabContentsViewWin);
};
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index b4fea1d..adf7903 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -198,7 +198,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate {
popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TOPMOST);
popup->SetOpacity(0x00);
- popup->Init(NULL, info.GetPopupRect(), false);
+ popup->Init(NULL, info.GetPopupRect());
popup->SetContentsView(new DockView(info.type()));
if (info.in_enable_area())
animation_.Reset(1);
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index f3101d9..b77ace5 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -48,7 +48,7 @@ DraggedTabView::DraggedTabView(TabContents* datasource,
container_->set_window_ex_style(
WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW);
container_->set_can_update_layered_window(false);
- container_->Init(NULL, gfx::Rect(0, 0, 0, 0), false);
+ container_->Init(NULL, gfx::Rect(0, 0, 0, 0));
container_->SetContentsView(this);
BOOL drag;
diff --git a/chrome/browser/views/tabs/native_view_photobooth_win.cc b/chrome/browser/views/tabs/native_view_photobooth_win.cc
index 430e009..6f78ea9 100644
--- a/chrome/browser/views/tabs/native_view_photobooth_win.cc
+++ b/chrome/browser/views/tabs/native_view_photobooth_win.cc
@@ -155,7 +155,7 @@ void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) {
// WS_EX_TOOLWINDOW ensures the capture window doesn't produce a Taskbar
// button.
capture_window_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW);
- capture_window_->Init(NULL, capture_bounds, false);
+ capture_window_->Init(NULL, capture_bounds);
// If the capture window isn't visible, blitting from the TabContents'
// HWND's DC to the capture bitmap produces blankness.
capture_window_->Show();
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 089925e..d9e7952 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -1388,8 +1388,7 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
arrow_window->Init(
NULL,
- gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height),
- true);
+ gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height));
arrow_window->SetContentsView(arrow_view);
#else
NOTIMPLEMENTED();