summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/reload_button.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 22:20:14 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-07 22:20:14 +0000
commit35b1eb2a2e8bca7732421539e9094813fc7e77e2 (patch)
tree7145b80fb0892e45a5eb8737833f63cabad6a0b9 /chrome/browser/cocoa/reload_button.h
parent9281f8359ca7e19cb067ca9e4995ff158252f44c (diff)
downloadchromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.zip
chromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.tar.gz
chromium_src-35b1eb2a2e8bca7732421539e9094813fc7e77e2.tar.bz2
[Mac] Don't change state from stop to reload when hovered.
Hold the reload button state change from stop to reload until the mouse exits. Also short-circuit the stop message when the real state should be reload. Also prevent multi-clicks from sending multiple actions. Toolbar.xib: reload button made kind of ReloadButton. BUG=47184 TEST=Browse to a slow page, mouse over stop button. Should not go to reload button when throbber (in tab) stops. TEST=After page loaded, click stop. Should not crash. TEST=Hover over reload button. Command-r should start a reload and change the button to stop button. Review URL: http://codereview.chromium.org/2847051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/reload_button.h')
-rw-r--r--chrome/browser/cocoa/reload_button.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/reload_button.h b/chrome/browser/cocoa/reload_button.h
new file mode 100644
index 0000000..c26f047
--- /dev/null
+++ b/chrome/browser/cocoa/reload_button.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef CHROME_BROWSER_COCOA_RELOAD_BUTTON_H_
+#define CHROME_BROWSER_COCOA_RELOAD_BUTTON_H_
+
+#import <Cocoa/Cocoa.h>
+
+#import "base/scoped_nsobject.h"
+
+// NSButton subclass which defers certain state changes when the mouse
+// is hovering over it.
+
+@interface ReloadButton : NSButton {
+ @private
+ // Tracks whether the mouse is hovering for purposes of not making
+ // unexpected state changes.
+ BOOL isMouseInside_;
+ scoped_nsobject<NSTrackingArea> trackingArea_;
+
+ // Set when reload mode is requested, but not forced, and the mouse
+ // is hovering.
+ BOOL pendingReloadMode_;
+}
+
+// Returns YES if the mouse is currently inside the bounds.
+- (BOOL)isMouseInside;
+
+// Update the button to be a reload button or stop button depending on
+// |isLoading|. If |force|, always sets the indicated mode. If
+// |!force|, and the mouse is over the button, defer the transition
+// from stop button to reload button until the mouse has left the
+// button. This prevents an inadvertent click _just_ as the state
+// changes.
+- (void)setIsLoading:(BOOL)isLoading force:(BOOL)force;
+
+@end
+
+@interface ReloadButton (PrivateTestingMethods)
+- (NSTrackingArea*)trackingArea;
+@end
+
+#endif // CHROME_BROWSER_COCOA_RELOAD_BUTTON_H_