summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/tab_contents.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 00:21:28 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 00:21:28 +0000
commit401513c474b3520fe784c03e068a15fc6655d6e1 (patch)
tree9d5368feb8f3a668ec4523e90bc9694bcfc3a9d3 /chrome/browser/tab_contents/tab_contents.cc
parenta8e9b16e3e3f944d0eaf7f91e5cc96a7b2c914d3 (diff)
downloadchromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.zip
chromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.tar.gz
chromium_src-401513c474b3520fe784c03e068a15fc6655d6e1.tar.bz2
Moving the storing/restoring of the focus from TabContents to WebContentsView. This makes TabContents less dependent on views.
This requires few contortions with DOMUIs (NTP, history and downloads tab) as they still need to set the initial focus specifically. BUG=None TEST=Run the interactive tests. Review URL: http://codereview.chromium.org/39269 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/tab_contents.cc')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc88
1 files changed, 0 insertions, 88 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 4da0609..0e8f6e4 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -22,10 +22,6 @@
#include "chrome/browser/views/download_started_animation.h"
#include "chrome/browser/views/blocked_popup_container.h"
#include "chrome/views/native_scroll_bar.h"
-#include "chrome/views/root_view.h"
-#include "chrome/views/view.h"
-#include "chrome/views/view_storage.h"
-#include "chrome/views/widget.h"
#endif
#if defined(OS_WIN)
@@ -54,22 +50,9 @@ TabContents::TabContents(TabContentsType type)
capturing_contents_(false),
blocked_popups_(NULL),
is_being_destroyed_(false) {
-#if defined(OS_WIN)
- last_focused_view_storage_id_ =
- views::ViewStorage::GetSharedInstance()->CreateStorageID();
-#endif
}
TabContents::~TabContents() {
-#if defined(OS_WIN)
- // Makes sure to remove any stored view we may still have in the ViewStorage.
- //
- // It is possible the view went away before us, so we only do this if the
- // view is registered.
- views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance();
- if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
- view_storage->RemoveView(last_focused_view_storage_id_);
-#endif
}
// static
@@ -366,77 +349,6 @@ void TabContents::Focus() {
#endif
}
-void TabContents::StoreFocus() {
-#if defined(OS_WIN)
- views::ViewStorage* view_storage =
- views::ViewStorage::GetSharedInstance();
-
- if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
- view_storage->RemoveView(last_focused_view_storage_id_);
-
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
- if (focus_manager) {
- // |focus_manager| can be NULL if the tab has been detached but still
- // exists.
- views::View* focused_view = focus_manager->GetFocusedView();
- if (focused_view)
- view_storage->StoreView(last_focused_view_storage_id_, focused_view);
-
- // If the focus was on the page, explicitly clear the focus so that we
- // don't end up with the focused HWND not part of the window hierarchy.
- // TODO(brettw) this should move to the view somehow.
- HWND container_hwnd = GetNativeView();
- if (container_hwnd) {
- views::View* focused_view = focus_manager->GetFocusedView();
- if (focused_view) {
- HWND hwnd = focused_view->GetRootView()->GetWidget()->GetHWND();
- if (container_hwnd == hwnd || ::IsChild(container_hwnd, hwnd))
- focus_manager->ClearFocus();
- }
- }
- }
-#endif
-}
-
-void TabContents::RestoreFocus() {
-#if defined(OS_WIN)
- views::ViewStorage* view_storage =
- views::ViewStorage::GetSharedInstance();
- views::View* last_focused_view =
- view_storage->RetrieveView(last_focused_view_storage_id_);
-
- if (!last_focused_view) {
- SetInitialFocus();
- } else {
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetNativeView());
-
- // If you hit this DCHECK, please report it to Jay (jcampan).
- DCHECK(focus_manager != NULL) << "No focus manager when restoring focus.";
-
- if (last_focused_view->IsFocusable() && focus_manager &&
- focus_manager->ContainsView(last_focused_view)) {
- last_focused_view->RequestFocus();
- } else {
- // The focused view may not belong to the same window hierarchy (e.g.
- // if the location bar was focused and the tab is dragged out), or it may
- // no longer be focusable (e.g. if the location bar was focused and then
- // we switched to fullscreen mode). In that case we default to the
- // default focus.
- SetInitialFocus();
- }
- view_storage->RemoveView(last_focused_view_storage_id_);
- }
-#endif
-}
-
-void TabContents::SetInitialFocus() {
-#if defined(OS_WIN)
- ::SetFocus(GetNativeView());
-#endif
-}
-
void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
// Look through the existing InfoBarDelegates we have for a match. If we've
// already got one that matches, then we don't add the new one.