diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 19:35:15 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 19:35:15 +0000 |
commit | 5e5df50b03c73dad60d81c989b11d8e1ee436dbe (patch) | |
tree | 9d64b42c5c109dfe14581e56c9bb6a731d82e352 /chrome/browser | |
parent | d62232baeefd5a2b0385238647266d26332628d0 (diff) | |
download | chromium_src-5e5df50b03c73dad60d81c989b11d8e1ee436dbe.zip chromium_src-5e5df50b03c73dad60d81c989b11d8e1ee436dbe.tar.gz chromium_src-5e5df50b03c73dad60d81c989b11d8e1ee436dbe.tar.bz2 |
Reverting r12383, caused a build breakage on all platforms.
TBR=idanan
Review URL: http://codereview.chromium.org/42571
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 66 | ||||
-rw-r--r-- | chrome/browser/browser.h | 11 | ||||
-rw-r--r-- | chrome/browser/location_bar.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/go_button.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/go_button.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 13 |
9 files changed, 40 insertions, 86 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index ccdb32d..94cb54f 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1029,7 +1029,7 @@ void AutomationProvider::GoBack(int handle, IPC::Message* reply_message) { tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, AUTOMATION_MSG_NAVIGATION_ERROR); - browser->GoBack(CURRENT_TAB); + browser->GoBack(); return; } } @@ -1048,7 +1048,7 @@ void AutomationProvider::GoForward(int handle, IPC::Message* reply_message) { tab, reply_message, AUTOMATION_MSG_NAVIGATION_SUCCESS, AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, AUTOMATION_MSG_NAVIGATION_ERROR); - browser->GoForward(CURRENT_TAB); + browser->GoForward(); return; } } diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 5e1b4ca..eecdd1a 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -551,7 +551,7 @@ void Browser::ShowSingleDOMUITab(const GURL& url) { /////////////////////////////////////////////////////////////////////////////// // Browser, Assorted browser commands: -void Browser::GoBack(WindowOpenDisposition disposition) { +void Browser::GoBack() { UserMetrics::RecordAction(L"Back", profile_); // If we are showing an interstitial, just hide it. @@ -565,37 +565,14 @@ void Browser::GoBack(WindowOpenDisposition disposition) { web_contents->interstitial_page()->DontProceed(); return; } - - if (current_tab->controller()->CanGoBack()) { - NavigationController* controller = 0; - if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB){ - controller = GetSelectedTabContents()->controller()->Clone(); - tabstrip_model_.AddTabContents( - controller->active_contents(), -1, - PageTransition::LINK, disposition == NEW_FOREGROUND_TAB); - } else { - // Default disposition is CURRENT_TAB. - controller = current_tab->controller(); - } - controller->GoBack(); - } + if (current_tab->controller()->CanGoBack()) + current_tab->controller()->GoBack(); } -void Browser::GoForward(WindowOpenDisposition disp) { +void Browser::GoForward() { UserMetrics::RecordAction(L"Forward", profile_); - if (GetSelectedTabContents()->controller()->CanGoForward()) { - NavigationController* controller = 0; - if (disp == NEW_FOREGROUND_TAB || disp == NEW_BACKGROUND_TAB) { - controller = GetSelectedTabContents()->controller()->Clone(); - tabstrip_model_.AddTabContents( - controller->active_contents(), -1, - PageTransition::LINK, disp == NEW_FOREGROUND_TAB); - } else { - // Default disposition is CURRENT_TAB. - controller = GetSelectedTabContents()->controller(); - } - controller->GoForward(); - } + if (GetSelectedTabContents()->controller()->CanGoForward()) + GetSelectedTabContents()->controller()->GoForward(); } void Browser::Reload() { @@ -620,9 +597,11 @@ void Browser::Reload() { } } -void Browser::Home(WindowOpenDisposition disposition) { +void Browser::Home() { UserMetrics::RecordAction(L"Home", profile_); - OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); + GURL homepage_url = GetHomePage(); + GetSelectedTabContents()->controller()->LoadURL( + homepage_url, GURL(), PageTransition::AUTO_BOOKMARK); } void Browser::OpenCurrentURL() { @@ -633,9 +612,9 @@ void Browser::OpenCurrentURL() { location_bar->GetPageTransition()); } -void Browser::Go(WindowOpenDisposition disposition) { +void Browser::Go() { UserMetrics::RecordAction(L"Go", profile_); - window_->GetLocationBar()->AcceptInputWithDisposition(disposition); + window_->GetLocationBar()->AcceptInput(); } void Browser::Stop() { @@ -1116,8 +1095,10 @@ Browser* Browser::GetBrowserForController( return NULL; } -void Browser::ExecuteCommandWithDisposition( - int id, WindowOpenDisposition disposition) { +/////////////////////////////////////////////////////////////////////////////// +// Browser, CommandUpdater::CommandUpdaterDelegate implementation: + +void Browser::ExecuteCommand(int id) { // No commands are enabled if there is not yet any selected tab. // TODO(pkasting): It seems like we should not need this, because either // most/all commands should not have been enabled yet anyway or the ones that @@ -1134,12 +1115,12 @@ void Browser::ExecuteCommandWithDisposition( // declaration order in browser.h! switch (id) { // Navigation commands - case IDC_BACK: GoBack(disposition); break; - case IDC_FORWARD: GoForward(disposition); break; + case IDC_BACK: GoBack(); break; + case IDC_FORWARD: GoForward(); break; case IDC_RELOAD: Reload(); break; - case IDC_HOME: Home(disposition); break; + case IDC_HOME: Home(); break; case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; - case IDC_GO: Go(disposition); break; + case IDC_GO: Go(); break; case IDC_STOP: Stop(); break; // Window management commands @@ -1294,13 +1275,6 @@ void Browser::ExecuteCommandWithDisposition( } /////////////////////////////////////////////////////////////////////////////// -// Browser, CommandUpdater::CommandUpdaterDelegate implementation: - -void Browser::ExecuteCommand(int id) { - ExecuteCommandWithDisposition(id, CURRENT_TAB); -} - -/////////////////////////////////////////////////////////////////////////////// // Browser, TabStripModelDelegate implementation: GURL Browser::GetBlankTabURL() const { diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index bb91b29..17d11d7 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -249,12 +249,12 @@ class Browser : public TabStripModelDelegate, // how they appear in the GUI/menus (left to right, top to bottom, etc.). // Navigation commands - void GoBack(WindowOpenDisposition disposition); - void GoForward(WindowOpenDisposition disposition); + void GoBack(); + void GoForward(); void Reload(); - void Home(WindowOpenDisposition disposition); + void Home(); void OpenCurrentURL(); - void Go(WindowOpenDisposition disposition); + void Go(); void Stop(); // Window management commands void NewWindow(); @@ -361,9 +361,6 @@ class Browser : public TabStripModelDelegate, static Browser* GetBrowserForController( const NavigationController* controller, int* index); - // Calls ExecuteCommandWithDisposition with the given disposition. - void ExecuteCommandWithDisposition(int id, WindowOpenDisposition); - // Interface implementations //////////////////////////////////////////////// // Overridden from CommandUpdater::CommandUpdaterDelegate: diff --git a/chrome/browser/location_bar.h b/chrome/browser/location_bar.h index a7b0c0d..b6499d8 100644 --- a/chrome/browser/location_bar.h +++ b/chrome/browser/location_bar.h @@ -37,9 +37,6 @@ class LocationBar { // Accepts the current string of text entered in the location bar. virtual void AcceptInput() = 0; - // Accept the current input, overriding the disposition. - virtual void AcceptInputWithDisposition(WindowOpenDisposition) = 0; - // Focuses and selects the contents of the location bar. virtual void FocusLocation() = 0; diff --git a/chrome/browser/views/go_button.cc b/chrome/browser/views/go_button.cc index 48773ae..db205c4 100644 --- a/chrome/browser/views/go_button.cc +++ b/chrome/browser/views/go_button.cc @@ -5,8 +5,7 @@ #include "chrome/browser/views/go_button.h" #include "chrome/app/chrome_dll_resource.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/views/event_utils.h" +#include "chrome/browser/command_updater.h" #include "chrome/browser/views/location_bar_view.h" #include "chrome/common/l10n_util.h" #include "grit/generated_resources.h" @@ -14,17 +13,16 @@ //////////////////////////////////////////////////////////////////////////////// // GoButton, public: -GoButton::GoButton(LocationBarView* location_bar, Browser* browser) +GoButton::GoButton(LocationBarView* location_bar, + CommandUpdater* command_updater) : ToggleImageButton(this), location_bar_(location_bar), - browser_(browser), + command_updater_(command_updater), intended_mode_(MODE_GO), visible_mode_(MODE_GO), button_delay_(NULL), stop_timer_(this) { DCHECK(location_bar_); - set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | - views::Event::EF_MIDDLE_BUTTON_DOWN); } GoButton::~GoButton() { @@ -66,14 +64,14 @@ void GoButton::ScheduleChangeMode(Mode mode) { void GoButton::ButtonPressed(views::Button* button) { if (visible_mode_ == MODE_STOP) { - browser_->Stop(); + command_updater_->ExecuteCommand(IDC_STOP); // The user has clicked, so we can feel free to update the button, // even if the mouse is still hovering. ChangeMode(MODE_GO); } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) { // If the go button is visible and not within the double click timer, go. - browser_->Go(event_utils::DispositionFromEventFlags(mouse_event_flags())); + command_updater_->ExecuteCommand(IDC_GO); // Figure out the system double-click time. if (button_delay_ == NULL) diff --git a/chrome/browser/views/go_button.h b/chrome/browser/views/go_button.h index a830191..c9d8252 100644 --- a/chrome/browser/views/go_button.h +++ b/chrome/browser/views/go_button.h @@ -8,7 +8,7 @@ #include "chrome/views/controls/button/image_button.h" #include "base/task.h" -class Browser; +class CommandUpdater; class LocationBarView; //////////////////////////////////////////////////////////////////////////////// @@ -26,7 +26,9 @@ class LocationBarView; class GoButton : public views::ToggleImageButton, public views::ButtonListener { public: - GoButton(LocationBarView* location_bar, Browser* Browser); + // TODO(beng): get rid of the command updater param and instead have a + // delegate. + GoButton(LocationBarView* location_bar, CommandUpdater* command_updater); virtual ~GoButton(); typedef enum Mode { MODE_GO = 0, MODE_STOP }; @@ -40,7 +42,7 @@ class GoButton : public views::ToggleImageButton, // Overridden from views::ButtonListener: virtual void ButtonPressed(views::Button* button); - + // Overridden from views::View: virtual void OnMouseExited(const views::MouseEvent& e); virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); @@ -52,7 +54,7 @@ class GoButton : public views::ToggleImageButton, ScopedRunnableMethodFactory<GoButton> stop_timer_; LocationBarView* location_bar_; - Browser* browser_; + CommandUpdater* command_updater_; // The mode we should be in Mode intended_mode_; diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 2ece304..1bbc95c 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -1082,10 +1082,6 @@ void LocationBarView::AcceptInput() { location_entry_->model()->AcceptInput(CURRENT_TAB, false); } -void LocationBarView::AcceptInputWithDisposition(WindowOpenDisposition disp) { - location_entry_->model()->AcceptInput(disp, false); -} - void LocationBarView::FocusLocation() { location_entry_->SetFocus(); location_entry_->SelectAll(true); diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index d0bcdb2..920fc88 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -118,7 +118,6 @@ class LocationBarView : public LocationBar, virtual WindowOpenDisposition GetWindowOpenDisposition() const; virtual PageTransition::Type GetPageTransition() const; virtual void AcceptInput(); - virtual void AcceptInputWithDisposition(WindowOpenDisposition); virtual void FocusLocation(); virtual void FocusSearch(); virtual void UpdateFeedIcon(); diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 78a8ae6..5695eac 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -22,7 +22,6 @@ #include "chrome/browser/user_data_manager.h" #include "chrome/browser/views/bookmark_menu_button.h" #include "chrome/browser/views/dom_view.h" -#include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/go_button.h" #include "chrome/browser/views/location_bar_view.h" #include "chrome/browser/views/theme_helpers.h" @@ -134,8 +133,6 @@ void BrowserToolbarView::CreateLeftSideControls() { ResourceBundle &rb = ResourceBundle::GetSharedInstance(); back_ = new views::ButtonDropDown(this, back_menu_model_.get()); - back_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | - views::Event::EF_MIDDLE_BUTTON_DOWN); back_->set_tag(IDC_BACK); back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, views::ImageButton::ALIGN_TOP); @@ -151,8 +148,6 @@ void BrowserToolbarView::CreateLeftSideControls() { AddChildView(back_); forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); - forward_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | - views::Event::EF_MIDDLE_BUTTON_DOWN); forward_->set_tag(IDC_FORWARD); forward_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_FORWARD)); @@ -181,8 +176,6 @@ void BrowserToolbarView::CreateLeftSideControls() { AddChildView(reload_); home_ = new views::ImageButton(this); - home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | - views::Event::EF_MIDDLE_BUTTON_DOWN); home_->set_tag(IDC_HOME); home_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_HOME)); home_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_HOME_H)); @@ -225,7 +218,7 @@ void BrowserToolbarView::CreateCenterStack(Profile *profile) { location_bar_->Init(); // The Go button. - go_ = new GoButton(location_bar_, browser_); + go_ = new GoButton(location_bar_, browser_->command_updater()); go_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_GO)); go_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_GO_H)); go_->SetImage(views::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_GO_P)); @@ -839,9 +832,7 @@ void BrowserToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { } void BrowserToolbarView::ButtonPressed(views::Button* sender) { - browser_->ExecuteCommandWithDisposition( - sender->tag(), - event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); + browser_->ExecuteCommand(sender->tag()); } // static |