summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-19 23:33:49 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-19 23:33:49 +0000
commit871f8af23e4ce5ffba6da0b74bf174dd85263006 (patch)
tree3ae016c39fc93b19c0938d55b1d73bd7db3f1868
parenta99db32f764f2b093356baa664877a9d90522f96 (diff)
downloadchromium_src-871f8af23e4ce5ffba6da0b74bf174dd85263006.zip
chromium_src-871f8af23e4ce5ffba6da0b74bf174dd85263006.tar.gz
chromium_src-871f8af23e4ce5ffba6da0b74bf174dd85263006.tar.bz2
Revert 168440 - Disable find if constrained window is shown
(Reverting this CL because it included an unintentional change to chrome_browser_main.cc. I'll reland this afterwards with that change removed.) This CL disables the "find in place" command if a constrained window is shown. BUG=156969 Review URL: https://chromiumcodereview.appspot.com/11293259 TBR=sail@chromium.org Review URL: https://codereview.chromium.org/11419076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168633 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_main.cc18
-rw-r--r--chrome/browser/ui/browser.cc2
-rw-r--r--chrome/browser/ui/browser_command_controller.cc30
-rw-r--r--chrome/browser/ui/browser_command_controller.h5
-rw-r--r--chrome/browser/ui/browser_command_controller_browsertest.cc37
-rw-r--r--chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc69
-rw-r--r--chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h38
-rw-r--r--chrome/chrome_tests.gypi1
8 files changed, 37 insertions, 163 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 11a7b79..e93cc98 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -822,24 +822,6 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
g_set_application_name(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str());
#endif
-#if !defined(OS_ANDROID)
- if (is_first_run_) {
- first_run::ProcessMasterPreferencesResult pmp_result =
- first_run::ProcessMasterPreferences(user_data_dir_,
- master_prefs_.get());
- if (pmp_result == first_run::EULA_EXIT_NOW)
- return chrome::RESULT_CODE_EULA_REFUSED;
-
- first_run_ui_bypass_ = (pmp_result == first_run::SKIP_FIRST_RUN);
-
- AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs);
- }
-#endif
-
-#if defined(OS_CHROMEOS)
- first_run_ui_bypass_ = true;
-#endif
-
// Android does first run in Java instead of native.
#if !defined(OS_ANDROID)
// On first run, we need to process the predictor preferences before the
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 9dece5a..b66d998 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1789,6 +1789,8 @@ void Browser::SetTabContentBlocked(content::WebContents* web_contents,
return;
}
tab_strip_model_->SetTabBlocked(index, blocked);
+ command_controller_->PrintingStateChanged();
+ command_controller_->FullscreenStateChanged();
if (!blocked && tab_strip_model_->GetActiveWebContents() == web_contents)
web_contents->Focus();
}
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 4dfc03c..93df2cd 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -730,14 +730,6 @@ void BrowserCommandController::TabReplacedAt(TabStripModel* tab_strip_model,
AddInterstitialObservers(new_contents);
}
-void BrowserCommandController::TabBlockedStateChanged(
- content::WebContents* contents,
- int index) {
- PrintingStateChanged();
- FullscreenStateChanged();
- UpdateCommandsForFind();
-}
-
////////////////////////////////////////////////////////////////////////////////
// BrowserCommandController, TabRestoreServiceObserver implementation:
@@ -897,6 +889,13 @@ void BrowserCommandController::InitCommandState() {
#endif
command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window);
+ // Find-in-page
+ command_updater_.UpdateCommandEnabled(IDC_FIND, !browser_->is_devtools());
+ command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT,
+ !browser_->is_devtools());
+ command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS,
+ !browser_->is_devtools());
+
// Show various bits of UI
command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window);
@@ -1005,7 +1004,6 @@ void BrowserCommandController::UpdateCommandsForTabState() {
UpdateCommandsForContentRestrictionState();
UpdateCommandsForBookmarkEditing();
- UpdateCommandsForFind();
}
void BrowserCommandController::UpdateCommandsForContentRestrictionState() {
@@ -1109,8 +1107,8 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode(
#if defined(OS_MACOSX)
// The Mac implementation doesn't support switching to fullscreen while
// a tab modal dialog is displayed.
- int tab_index = chrome::IndexOfFirstBlockedTab(browser_->tab_strip_model());
- bool has_blocked_tab = tab_index != browser_->tab_strip_model()->count();
+ int tabIndex = chrome::IndexOfFirstBlockedTab(browser_->tab_strip_model());
+ bool has_blocked_tab = tabIndex != browser_->tab_strip_model()->count();
fullscreen_enabled &= !has_blocked_tab;
#endif
@@ -1169,16 +1167,6 @@ void BrowserCommandController::UpdateReloadStopState(bool is_loading,
command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
}
-void BrowserCommandController::UpdateCommandsForFind() {
- TabStripModel* model = browser_->tab_strip_model();
- bool enabled = !model->IsTabBlocked(model->active_index()) &&
- !browser_->is_devtools();
-
- command_updater_.UpdateCommandEnabled(IDC_FIND, enabled);
- command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, enabled);
- command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, enabled);
-}
-
void BrowserCommandController::AddInterstitialObservers(WebContents* contents) {
registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED,
content::Source<WebContents>(contents));
diff --git a/chrome/browser/ui/browser_command_controller.h b/chrome/browser/ui/browser_command_controller.h
index 1d8e96c..2d549ff 100644
--- a/chrome/browser/ui/browser_command_controller.h
+++ b/chrome/browser/ui/browser_command_controller.h
@@ -102,8 +102,6 @@ class BrowserCommandController : public CommandUpdater::CommandUpdaterDelegate,
content::WebContents* old_contents,
content::WebContents* new_contents,
int index) OVERRIDE;
- virtual void TabBlockedStateChanged(content::WebContents* contents,
- int index) OVERRIDE;
// Overridden from TabRestoreServiceObserver:
virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE;
@@ -161,9 +159,6 @@ class BrowserCommandController : public CommandUpdater::CommandUpdaterDelegate,
// |force| is true if the button should change its icon immediately.
void UpdateReloadStopState(bool is_loading, bool force);
- // Updates commands for find.
- void UpdateCommandsForFind();
-
// Add/remove observers for interstitial attachment/detachment from
// |contents|.
void AddInterstitialObservers(content::WebContents* contents);
diff --git a/chrome/browser/ui/browser_command_controller_browsertest.cc b/chrome/browser/ui/browser_command_controller_browsertest.cc
deleted file mode 100644
index 9a362d5..0000000
--- a/chrome/browser/ui/browser_command_controller_browsertest.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/browser_command_controller.h"
-
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h"
-#include "chrome/test/base/in_process_browser_test.h"
-
-typedef InProcessBrowserTest BrowserCommandControllerBrowserTest;
-
-// Verify that showing a constrained window disables find.
-IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, DisableFind) {
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND));
-
- // Showing constrained window should disable find.
- content::WebContents* web_contents = chrome::GetActiveWebContents(browser());
- MockTabModalConfirmDialogDelegate* delegate =
- new MockTabModalConfirmDialogDelegate(web_contents, NULL);
- TabModalConfirmDialog::Create(delegate, web_contents);
- EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND));
-
- // Switching to a new (unblocked) tab should reenable it.
- AddBlankTabAndShow(browser());
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND));
-
- // Switching back to the blocked tab should disable it again.
- chrome::ActivateTabAt(browser(), 0, false);
- EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FIND));
-
- // Closing the constrained window should reenable it.
- delegate->Cancel();
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND));
-}
diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc
index b12d6ce..3da874a 100644
--- a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc
+++ b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc
@@ -10,47 +10,37 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-MockTabModalConfirmDialogDelegate::MockTabModalConfirmDialogDelegate(
- content::WebContents* web_contents,
- Delegate* delegate)
- : TabModalConfirmDialogDelegate(web_contents),
- delegate_(delegate) {
-}
+class MockTabModalConfirmDialogDelegate : public TabModalConfirmDialogDelegate {
+ public:
+ explicit MockTabModalConfirmDialogDelegate(content::WebContents* web_contents)
+ : TabModalConfirmDialogDelegate(web_contents) {}
-MockTabModalConfirmDialogDelegate::~MockTabModalConfirmDialogDelegate() {
-}
+ virtual string16 GetTitle() OVERRIDE {
+ return string16();
+ }
+ virtual string16 GetMessage() OVERRIDE {
+ return string16();
+ }
-string16 MockTabModalConfirmDialogDelegate::GetTitle() {
- return string16();
-}
+ MOCK_METHOD0(OnAccepted, void());
+ MOCK_METHOD0(OnCanceled, void());
-string16 MockTabModalConfirmDialogDelegate::GetMessage() {
- return string16();
-}
-
-void MockTabModalConfirmDialogDelegate::OnAccepted() {
- if (delegate_)
- delegate_->OnAccepted();
-}
-
-void MockTabModalConfirmDialogDelegate::OnCanceled() {
- if (delegate_)
- delegate_->OnCanceled();
-}
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate);
+};
TabModalConfirmDialogTest::TabModalConfirmDialogTest()
: delegate_(NULL),
- dialog_(NULL),
- accepted_count_(0),
- canceled_count_(0) {
-}
+ dialog_(NULL) {}
void TabModalConfirmDialogTest::SetUpOnMainThread() {
delegate_ = new MockTabModalConfirmDialogDelegate(
- chrome::GetActiveWebContents(browser()), this);
+ chrome::GetActiveWebContents(browser()));
dialog_ = TabModalConfirmDialog::Create(
delegate_, chrome::GetActiveWebContents(browser()));
content::RunAllPendingInMessageLoop();
@@ -58,38 +48,27 @@ void TabModalConfirmDialogTest::SetUpOnMainThread() {
void TabModalConfirmDialogTest::CleanUpOnMainThread() {
content::RunAllPendingInMessageLoop();
-}
-
-void TabModalConfirmDialogTest::OnAccepted() {
- ++accepted_count_;
-}
-
-void TabModalConfirmDialogTest::OnCanceled() {
- ++canceled_count_;
+ ::testing::Mock::VerifyAndClearExpectations(delegate_);
}
IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Accept) {
+ EXPECT_CALL(*delegate_, OnAccepted());
dialog_->AcceptTabModalDialog();
- EXPECT_EQ(1, accepted_count_);
- EXPECT_EQ(0, canceled_count_);
}
IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Cancel) {
+ EXPECT_CALL(*delegate_, OnCanceled());
dialog_->CancelTabModalDialog();
- EXPECT_EQ(0, accepted_count_);
- EXPECT_EQ(1, canceled_count_);
}
IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, CancelSelf) {
+ EXPECT_CALL(*delegate_, OnCanceled());
delegate_->Cancel();
- EXPECT_EQ(0, accepted_count_);
- EXPECT_EQ(1, canceled_count_);
}
IN_PROC_BROWSER_TEST_F(TabModalConfirmDialogTest, Quit) {
+ EXPECT_CALL(*delegate_, OnCanceled());
MessageLoopForUI::current()->PostTask(FROM_HERE,
base::Bind(&browser::AttemptExit));
content::RunMessageLoop();
- EXPECT_EQ(0, accepted_count_);
- EXPECT_EQ(1, canceled_count_);
}
diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h
index 0f22b37..9e954d9 100644
--- a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h
+++ b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h
@@ -8,48 +8,17 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
-#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "chrome/test/base/in_process_browser_test.h"
-class MockTabModalConfirmDialogDelegate : public TabModalConfirmDialogDelegate {
- public:
- class Delegate {
- public:
- virtual void OnAccepted() = 0;
- virtual void OnCanceled() = 0;
- protected:
- virtual ~Delegate() {}
- };
-
- MockTabModalConfirmDialogDelegate(content::WebContents* web_contents,
- Delegate* delegate);
- virtual ~MockTabModalConfirmDialogDelegate();
-
- virtual string16 GetTitle() OVERRIDE;
- virtual string16 GetMessage() OVERRIDE;
-
- virtual void OnAccepted() OVERRIDE;
- virtual void OnCanceled() OVERRIDE;
-
- private:
- Delegate* delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate);
-};
+class MockTabModalConfirmDialogDelegate;
-class TabModalConfirmDialogTest
- : public InProcessBrowserTest,
- public MockTabModalConfirmDialogDelegate::Delegate {
+class TabModalConfirmDialogTest : public InProcessBrowserTest {
public:
TabModalConfirmDialogTest();
virtual void SetUpOnMainThread() OVERRIDE;
virtual void CleanUpOnMainThread() OVERRIDE;
- // MockTabModalConfirmDialogDelegate::Delegate:
- virtual void OnAccepted() OVERRIDE;
- virtual void OnCanceled() OVERRIDE;
-
protected:
// Owned by |dialog_|.
MockTabModalConfirmDialogDelegate* delegate_;
@@ -57,9 +26,6 @@ class TabModalConfirmDialogTest
// Deletes itself.
TabModalConfirmDialog* dialog_;
- int accepted_count_;
- int canceled_count_;
-
private:
DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogTest);
};
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a97b553..c0b0b3f 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1045,7 +1045,6 @@
'browser/ui/bookmarks/bookmark_browsertest.cc',
'browser/ui/browser_browsertest.cc',
'browser/ui/browser_close_browsertest.cc',
- 'browser/ui/browser_command_controller_browsertest.cc',
'browser/ui/browser_navigator_browsertest.cc',
'browser/ui/browser_navigator_browsertest.h',
'browser/ui/browser_navigator_browsertest_chromeos.cc',