summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:34:17 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 00:34:17 +0000
commit107d976cd48b004d0f220da154db609457ab903b (patch)
treecf1137b76b1e4cd533ff9a971f83080dd04ecac2 /chrome/browser
parent6689dbbb7832c151d6d846b6ed55445a6c979f20 (diff)
downloadchromium_src-107d976cd48b004d0f220da154db609457ab903b.zip
chromium_src-107d976cd48b004d0f220da154db609457ab903b.tar.gz
chromium_src-107d976cd48b004d0f220da154db609457ab903b.tar.bz2
Make sure we don't set focus to the findbar until after the focus is restored to the tab contents.
BUG=18294 Review URL: http://codereview.chromium.org/160566 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm2
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.h6
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm12
-rw-r--r--chrome/browser/cocoa/tab_strip_controller_unittest.mm9
-rw-r--r--chrome/browser/find_bar_controller.cc4
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc9
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
7 files changed, 24 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index da50796..aca4ef1 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -158,7 +158,7 @@ willPositionSheet:(NSWindow*)sheet
tabStripController_.reset([[TabStripController alloc]
initWithView:[self tabStripView]
switchView:[self tabContentArea]
- model:browser_->tabstrip_model()]);
+ browser:browser_.get()]);
// Create the infobar container view, so we can pass it to the
// ToolbarController.
diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h
index 0a5308d..ead599e 100644
--- a/chrome/browser/cocoa/tab_strip_controller.h
+++ b/chrome/browser/cocoa/tab_strip_controller.h
@@ -14,6 +14,7 @@
@class TabView;
@class TabStripView;
+class Browser;
class TabStripModelObserverBridge;
class TabStripModel;
class TabContents;
@@ -38,6 +39,7 @@ class ToolbarModel;
scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server drags
NSButton* newTabButton_; // weak, obtained from the nib.
scoped_ptr<TabStripModelObserverBridge> bridge_;
+ Browser* browser_; // weak
TabStripModel* tabModel_; // weak
// access to the TabContentsControllers (which own the parent view
// for the toolbar and associated tab contents) given an index. This needs
@@ -49,7 +51,7 @@ class ToolbarModel;
scoped_nsobject<NSMutableArray> tabArray_;
// These values are only used during a drag, and override tab positioning.
- TabView* placeholderTab_; // weak. Tab being dragged
+ TabView* placeholderTab_; // weak. Tab being dragged
NSRect placeholderFrame_; // Frame to use
CGFloat placeholderStretchiness_; // Vertical force shown by streching tab.
// Frame targets for all the current views.
@@ -84,7 +86,7 @@ class ToolbarModel;
// you have retained them.
- (id)initWithView:(TabStripView*)view
switchView:(NSView*)switchView
- model:(TabStripModel*)model;
+ browser:(Browser*)browser;
// Return the view for the currently selected tab.
- (NSView *)selectedTabView;
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index e95e467..1fdf0fc 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -10,6 +10,8 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/cocoa/nsimage_cache.h"
+#include "chrome/browser/find_bar.h"
+#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
#import "chrome/browser/cocoa/tab_strip_view.h"
@@ -53,12 +55,13 @@ static const float kUseFullAvailableWidth = -1.0;
- (id)initWithView:(TabStripView*)view
switchView:(NSView*)switchView
- model:(TabStripModel*)model {
- DCHECK(view && switchView && model);
+ browser:(Browser*)browser {
+ DCHECK(view && switchView && browser);
if ((self = [super init])) {
tabView_ = view;
switchView_ = switchView;
- tabModel_ = model;
+ browser_ = browser;
+ tabModel_ = browser_->tabstrip_model();
bridge_.reset(new TabStripModelObserverBridge(tabModel_, self));
tabContentsArray_.reset([[NSMutableArray alloc] init]);
tabArray_.reset([[NSMutableArray alloc] init]);
@@ -493,6 +496,9 @@ static const float kUseFullAvailableWidth = -1.0;
if (newContents) {
newContents->DidBecomeSelected();
newContents->view()->RestoreFocus();
+
+ if (newContents->find_ui_active())
+ browser_->find_bar()->find_bar()->SetFocusAndSelection();
}
}
diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
index 9693ca0..723c69a 100644
--- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm
+++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
@@ -81,21 +81,18 @@ class TabStripControllerTest : public testing::Test {
initWithFrame:button_frame]);
[tab_strip_ addSubview:close_button.get()];
- // Create the controller using that view and a model we create that has
- // no other Browser ties.
delegate_.reset(new TestTabStripDelegate());
- model_.reset(new TabStripModel(delegate_.get(),
- browser_helper_.profile()));
+ model_ = browser_helper_.browser()->tabstrip_model();
controller_.reset([[TabStripController alloc]
initWithView:(TabStripView*)tab_strip_.get()
switchView:switch_view.get()
- model:model_.get()]);
+ browser:browser_helper_.browser()]);
}
CocoaTestHelper cocoa_helper_;
BrowserTestHelper browser_helper_;
scoped_ptr<TestTabStripDelegate> delegate_;
- scoped_ptr<TabStripModel> model_;
+ TabStripModel* model_;
scoped_nsobject<TabStripController> controller_;
scoped_nsobject<NSView> tab_strip_;
};
diff --git a/chrome/browser/find_bar_controller.cc b/chrome/browser/find_bar_controller.cc
index 4f8af9a..5c99628 100644
--- a/chrome/browser/find_bar_controller.cc
+++ b/chrome/browser/find_bar_controller.cc
@@ -97,10 +97,6 @@ void FindBarController::ChangeTabContents(TabContents* contents) {
// reason.
gfx::Rect new_pos = find_bar_->GetDialogPosition(gfx::Rect());
find_bar_->SetDialogPosition(new_pos, false);
-
- // Only modify focus and selection if Find is active, otherwise the Find
- // Bar will interfere with user input.
- find_bar_->SetFocusAndSelection();
}
UpdateFindBarForCurrentResult();
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 2687d41..9cd7735 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/gtk/about_chrome_dialog.h"
#include "chrome/browser/gtk/active_window_watcher.h"
#include "chrome/browser/gtk/bookmark_bar_gtk.h"
@@ -995,9 +996,6 @@ void BrowserWindowGtk::TabDetachedAt(TabContents* contents, int index) {
UpdateDevToolsForContents(NULL);
}
-// TODO(estade): this function should probably be unforked from the BrowserView
-// function of the same name by having a shared partial BrowserWindow
-// implementation.
void BrowserWindowGtk::TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
@@ -1016,8 +1014,11 @@ void BrowserWindowGtk::TabSelectedAt(TabContents* old_contents,
new_contents->DidBecomeSelected();
// TODO(estade): after we manage browser activation, add a check to make sure
// we are the active browser before calling RestoreFocus().
- if (!browser_->tabstrip_model()->closing_all())
+ if (!browser_->tabstrip_model()->closing_all()) {
new_contents->view()->RestoreFocus();
+ if (new_contents->find_ui_active())
+ browser_->find_bar()->find_bar()->SetFocusAndSelection();
+ }
// Update all the UI bits.
UpdateTitleBar();
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index e1fbe6a..85b8999 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1050,6 +1050,8 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// We only restore focus if our window is visible, to avoid invoking blur
// handlers when we are eventually shown.
new_contents->view()->RestoreFocus();
+ if (new_contents->find_ui_active())
+ browser_->find_bar()->find_bar()->SetFocusAndSelection();
}
// Update all the UI bits.