summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/reload_button.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-25 19:40:10 +0000
committerBen Murdoch <benm@google.com>2010-12-03 13:52:53 +0000
commit4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7 (patch)
tree938665d93a11fe7a6d0124e3c1e020d1f9d3f947 /chrome/browser/views/reload_button.cc
parent7c627d87728a355737862918d144f98f69406954 (diff)
downloadexternal_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.zip
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.gz
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.bz2
Merge Chromium at r66597: Initial merge by git.
Change-Id: I9639f8a997f90ec219573aa22a49f5dbde78cc7b
Diffstat (limited to 'chrome/browser/views/reload_button.cc')
-rw-r--r--chrome/browser/views/reload_button.cc137
1 files changed, 0 insertions, 137 deletions
diff --git a/chrome/browser/views/reload_button.cc b/chrome/browser/views/reload_button.cc
deleted file mode 100644
index 43015e7..0000000
--- a/chrome/browser/views/reload_button.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright (c) 2010 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/views/reload_button.h"
-
-#include "app/l10n_util.h"
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/views/event_utils.h"
-#include "chrome/browser/views/location_bar/location_bar_view.h"
-#include "grit/generated_resources.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// ReloadButton, public:
-
-ReloadButton::ReloadButton(LocationBarView* location_bar, Browser* browser)
- : ALLOW_THIS_IN_INITIALIZER_LIST(ToggleImageButton(this)),
- location_bar_(location_bar),
- browser_(browser),
- intended_mode_(MODE_RELOAD),
- visible_mode_(MODE_RELOAD),
- double_click_timer_delay_(
- base::TimeDelta::FromMilliseconds(GetDoubleClickTimeMS())),
- stop_to_reload_timer_delay_(base::TimeDelta::FromMilliseconds(1350)),
- testing_mouse_hovered_(false),
- testing_reload_count_(0) {
-}
-
-ReloadButton::~ReloadButton() {
-}
-
-void ReloadButton::ChangeMode(Mode mode, bool force) {
- intended_mode_ = mode;
-
- // If the change is forced, or the user isn't hovering the icon, or it's safe
- // to change it to the other image type, make the change immediately;
- // otherwise we'll let it happen later.
- if (force || (!IsMouseHovered() && !testing_mouse_hovered_) ||
- ((mode == MODE_STOP) ?
- !double_click_timer_.IsRunning() : (visible_mode_ != MODE_STOP))) {
- double_click_timer_.Stop();
- stop_to_reload_timer_.Stop();
- SetToggled(mode == MODE_STOP);
- visible_mode_ = mode;
- SetEnabled(true);
-
- // We want to disable the button if we're preventing a change from stop to
- // reload due to hovering, but not if we're preventing a change from reload to
- // stop due to the double-click timer running. (There is no disabled reload
- // state.)
- } else if (visible_mode_ != MODE_RELOAD) {
- SetEnabled(false);
-
- // Go ahead and change to reload after a bit, which allows repeated reloads
- // without moving the mouse.
- if (!stop_to_reload_timer_.IsRunning()) {
- stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this,
- &ReloadButton::OnStopToReloadTimer);
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ReloadButton, views::ButtonListener implementation:
-
-void ReloadButton::ButtonPressed(views::Button* /* button */,
- const views::Event& event) {
- if (visible_mode_ == MODE_STOP) {
- if (browser_)
- browser_->Stop();
- // The user has clicked, so we can feel free to update the button,
- // even if the mouse is still hovering.
- ChangeMode(MODE_RELOAD, true);
- } else if (!double_click_timer_.IsRunning()) {
- // Shift-clicking or ctrl-clicking the reload button means we should ignore
- // any cached content.
- // TODO(avayvod): eliminate duplication of this logic in
- // CompactLocationBarView.
- int command;
- int flags = mouse_event_flags();
- if (event.IsShiftDown() || event.IsControlDown()) {
- command = IDC_RELOAD_IGNORING_CACHE;
- // Mask off Shift and Control so they don't affect the disposition below.
- flags &= ~(views::Event::EF_SHIFT_DOWN | views::Event::EF_CONTROL_DOWN);
- } else {
- command = IDC_RELOAD;
- }
-
- WindowOpenDisposition disposition =
- event_utils::DispositionFromEventFlags(flags);
- if ((disposition == CURRENT_TAB) && location_bar_) {
- // Forcibly reset the location bar, since otherwise it won't discard any
- // ongoing user edits, since it doesn't realize this is a user-initiated
- // action.
- location_bar_->Revert();
- }
-
- // Start a timer - while this timer is running, the reload button cannot be
- // changed to a stop button. We do not set |intended_mode_| to MODE_STOP
- // here as the browser will do that when it actually starts loading (which
- // may happen synchronously, thus the need to do this before telling the
- // browser to execute the reload command).
- double_click_timer_.Start(double_click_timer_delay_, this,
- &ReloadButton::OnDoubleClickTimer);
-
- if (browser_)
- browser_->ExecuteCommandWithDisposition(command, disposition);
- ++testing_reload_count_;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ReloadButton, View overrides:
-
-void ReloadButton::OnMouseExited(const views::MouseEvent& e) {
- ChangeMode(intended_mode_, true);
- if (state() != BS_DISABLED)
- SetState(BS_NORMAL);
-}
-
-bool ReloadButton::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
- tooltip->assign(l10n_util::GetString((visible_mode_ == MODE_RELOAD) ?
- IDS_TOOLTIP_RELOAD : IDS_TOOLTIP_STOP));
- return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ReloadButton, private:
-
-void ReloadButton::OnDoubleClickTimer() {
- ChangeMode(intended_mode_, false);
-}
-
-void ReloadButton::OnStopToReloadTimer() {
- ChangeMode(intended_mode_, true);
-}