Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3597)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h

Issue 8141003: [Mac] Restore the old bookmark menus now that the experiment is over. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..20ea39e82608d0283b56ed14a618e157581cc69e
--- /dev/null
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_hover_state.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 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.
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/memory/scoped_nsobject.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
+
+// Hover state machine. Encapsulates the hover state for
+// BookmarkBarFolderController.
+// A strict call order is implied with these calls. It is ONLY valid to make
+// the following state transitions:
+// From: To: Via:
+// closed opening scheduleOpen...:
+// opening closed cancelPendingOpen...: or
+// open scheduleOpen...: completes.
+// open closing scheduleClose...:
+// closing open cancelPendingClose...: or
+// closed scheduleClose...: completes.
+//
+@interface BookmarkBarFolderHoverState : NSObject {
+ @private
+ // Enumeration of the valid states that the |hoverButton_| member can be in.
+ // Because the opening and closing of hover views can be done asyncronously
+ // there are periods where the hover state is in transtion between open and
+ // closed. During those times of transition the opening or closing operation
+ // can be cancelled. We serialize the opening and closing of the
+ // |hoverButton_| using this state information. This serialization is to
+ // avoid race conditions where one hover button is being opened while another
+ // is closing.
+ enum HoverState {
+ kHoverStateClosed = 0,
+ kHoverStateOpening = 1,
+ kHoverStateOpen = 2,
+ kHoverStateClosing = 3
+ };
+
+ // Like normal menus, hovering over a folder button causes it to
+ // open. This variable is set when a hover is initiated (but has
+ // not necessarily fired yet).
+ scoped_nsobject<BookmarkButton> hoverButton_;
+
+ // We model hover state as a state machine with specific allowable
+ // transitions. |hoverState_| is the state of this machine at any
+ // given time.
+ HoverState hoverState_;
+}
+
+// Designated initializer.
+- (id)init;
+
+// The BookmarkBarFolderHoverState decides when it is appropriate to hide
+// and show the button that the BookmarkBarFolderController drags over.
+- (NSDragOperation)draggingEnteredButton:(BookmarkButton*)button;
+
+// The BookmarkBarFolderHoverState decides the fate of the hover button
+// when the BookmarkBarFolderController's view is exited.
+- (void)draggingExited;
+
+@end
+
+// Exposing these for unit testing purposes. They are used privately in the
+// implementation as well.
+@interface BookmarkBarFolderHoverState(PrivateAPI)
+// State change APIs.
+- (void)scheduleCloseBookmarkFolderOnHoverButton;
+- (void)cancelPendingCloseBookmarkFolderOnHoverButton;
+- (void)scheduleOpenBookmarkFolderOnHoverButton:(BookmarkButton*)hoverButton;
+- (void)cancelPendingOpenBookmarkFolderOnHoverButton;
+@end
+
+// Exposing these for unit testing purposes. They are used only in tests.
+@interface BookmarkBarFolderHoverState(TestingAPI)
+// Accessors and setters for button and hover state.
+- (BookmarkButton*)hoverButton;
+- (HoverState)hoverState;
+@end

Powered by Google App Engine
This is Rietveld 408576698