Changing the focus manager to not subclass HWNDs (but for the top-windows).Components that have HWND now need to specifically let the FocusManager know when they get the native focus.This is the reason for the new GotFocus() notification on the RenderWidgetHostViewWin class.BUG=NoneTEST=Run the interactive tests, the unit-tests. Test that the focus is remembered correctly when switching windows, switching tabs. Test that focus traversal in the browser and in the option dialog works as expected.
Review URL: http://codereview.chromium.org/122002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18301 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 712f955..3681c1b 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -96,7 +96,7 @@
 };
 }  // namespace
 
-IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) {
   HTTPTestServer* server = StartHTTPServer();
 
   // First we navigate to our test page.
@@ -111,7 +111,7 @@
       views::FocusManager::GetFocusManager(hwnd);
   ASSERT_TRUE(focus_manager);
 
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 
   // Now hide the window, show it again, the focus should not have changed.
@@ -119,7 +119,7 @@
   // using Windows API.
   ::ShowWindow(hwnd, SW_HIDE);
   ::ShowWindow(hwnd, SW_SHOW);
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 
   // Click on the location bar.
@@ -151,7 +151,7 @@
   views::FocusManager* focus_manager2 =
       views::FocusManager::GetFocusManager(hwnd2);
   ASSERT_TRUE(focus_manager2);
-  EXPECT_EQ(browser_view2->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view2->GetTabContentsContainerView(),
             focus_manager2->GetFocusedView());
 
   // Switch to the 1st browser window, focus should still be on the location
@@ -163,7 +163,7 @@
   // Switch back to the second browser, focus should still be on the page.
   browser2->window()->Activate();
   EXPECT_EQ(NULL, focus_manager->GetFocusedView());
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view2->GetTabContentsContainerView(),
             focus_manager2->GetFocusedView());
 
   // Close the 2nd browser to avoid a DCHECK().
@@ -205,9 +205,12 @@
       browser()->SelectTabContentsAt(j, true);
 
       // Activate the location bar or the page.
-      views::View* view_to_focus = kFocusPage[i][j] ?
-          browser_view->contents_container()->GetFocusView() :
-          browser_view->GetLocationBarView();
+      views::View* view_to_focus;
+      if (kFocusPage[i][j]) {
+        view_to_focus = browser_view->GetTabContentsContainerView();
+      } else {
+        view_to_focus = browser_view->GetLocationBarView();
+      }
 
       ui_controls::MoveMouseToCenterAndPress(view_to_focus,
                                              ui_controls::LEFT,
@@ -223,9 +226,12 @@
       browser()->SelectTabContentsAt(j, true);
 
       // Activate the location bar or the page.
-      views::View* view = kFocusPage[i][j] ?
-          browser_view->contents_container()->GetFocusView() :
-          browser_view->GetLocationBarView();
+      views::View* view;
+      if (kFocusPage[i][j]) {
+        view = browser_view->GetTabContentsContainerView();
+      } else {
+        view = browser_view->GetLocationBarView();
+      }
       EXPECT_EQ(view, focus_manager->GetFocusedView());
     }
   }
@@ -398,7 +404,7 @@
       views::FocusManager::GetFocusManager(hwnd);
 
   // Focus should be on the page.
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 
   // Let's show an interstitial.
@@ -493,12 +499,12 @@
       views::FocusManager::GetFocusManager(hwnd);
 
   // Page should have focus.
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
   EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()->
       HasFocus());
 
-  // Let's show an interstitial.
+  // Let's show an interstitial.erstitial
   TestInterstitialPage* interstitial_page =
       new TestInterstitialPage(browser()->GetSelectedTabContents(),
                                true, GURL("http://interstitial.com"));
@@ -510,7 +516,7 @@
   ui_test_utils::RunMessageLoop();
 
   // The interstitial should have focus now.
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
   EXPECT_TRUE(interstitial_page->HasFocus());
 
@@ -518,7 +524,7 @@
   interstitial_page->DontProceed();
 
   // Focus should be back on the original page.
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
   EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()->
       HasFocus());
@@ -577,12 +583,12 @@
 
   // Set focus to the page.
   ui_controls::MoveMouseToCenterAndPress(
-      browser_view->contents_container()->GetFocusView(),
+      browser_view->GetTabContentsContainerView(),
       ui_controls::LEFT,
       ui_controls::DOWN | ui_controls::UP,
       new MessageLoop::QuitTask());
   ui_test_utils::RunMessageLoop();
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 
   // Now press Ctrl+F again and focus should move to the Find box.
@@ -612,7 +618,7 @@
 
   // Open the history tab, focus should be on the tab contents.
   browser()->ShowHistoryTab();
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 
   // Open the new tab, focus should be on the location bar.
@@ -622,6 +628,6 @@
 
   // Open the download tab, focus should be on the tab contents.
   browser()->ShowDownloadsTab();
-  EXPECT_EQ(browser_view->contents_container()->GetFocusView(),
+  EXPECT_EQ(browser_view->GetTabContentsContainerView(),
             focus_manager->GetFocusedView());
 }