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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6
7 #include "base/memory/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
9
10 // Hover state machine. Encapsulates the hover state for
11 // BookmarkBarFolderController.
12 // A strict call order is implied with these calls. It is ONLY valid to make
13 // the following state transitions:
14 // From: To: Via:
15 // closed opening scheduleOpen...:
16 // opening closed cancelPendingOpen...: or
17 // open scheduleOpen...: completes.
18 // open closing scheduleClose...:
19 // closing open cancelPendingClose...: or
20 // closed scheduleClose...: completes.
21 //
22 @interface BookmarkBarFolderHoverState : NSObject {
23 @private
24 // Enumeration of the valid states that the |hoverButton_| member can be in.
25 // Because the opening and closing of hover views can be done asyncronously
26 // there are periods where the hover state is in transtion between open and
27 // closed. During those times of transition the opening or closing operation
28 // can be cancelled. We serialize the opening and closing of the
29 // |hoverButton_| using this state information. This serialization is to
30 // avoid race conditions where one hover button is being opened while another
31 // is closing.
32 enum HoverState {
33 kHoverStateClosed = 0,
34 kHoverStateOpening = 1,
35 kHoverStateOpen = 2,
36 kHoverStateClosing = 3
37 };
38
39 // Like normal menus, hovering over a folder button causes it to
40 // open. This variable is set when a hover is initiated (but has
41 // not necessarily fired yet).
42 scoped_nsobject<BookmarkButton> hoverButton_;
43
44 // We model hover state as a state machine with specific allowable
45 // transitions. |hoverState_| is the state of this machine at any
46 // given time.
47 HoverState hoverState_;
48 }
49
50 // Designated initializer.
51 - (id)init;
52
53 // The BookmarkBarFolderHoverState decides when it is appropriate to hide
54 // and show the button that the BookmarkBarFolderController drags over.
55 - (NSDragOperation)draggingEnteredButton:(BookmarkButton*)button;
56
57 // The BookmarkBarFolderHoverState decides the fate of the hover button
58 // when the BookmarkBarFolderController's view is exited.
59 - (void)draggingExited;
60
61 @end
62
63 // Exposing these for unit testing purposes. They are used privately in the
64 // implementation as well.
65 @interface BookmarkBarFolderHoverState(PrivateAPI)
66 // State change APIs.
67 - (void)scheduleCloseBookmarkFolderOnHoverButton;
68 - (void)cancelPendingCloseBookmarkFolderOnHoverButton;
69 - (void)scheduleOpenBookmarkFolderOnHoverButton:(BookmarkButton*)hoverButton;
70 - (void)cancelPendingOpenBookmarkFolderOnHoverButton;
71 @end
72
73 // Exposing these for unit testing purposes. They are used only in tests.
74 @interface BookmarkBarFolderHoverState(TestingAPI)
75 // Accessors and setters for button and hover state.
76 - (BookmarkButton*)hoverButton;
77 - (HoverState)hoverState;
78 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698