Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tabs / tab_controller.h
blob8456e6ba9569ff6da86521f8d17b6d4e3a1f8e11
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
9 #include "base/memory/scoped_ptr.h"
10 #import "chrome/browser/ui/cocoa/hover_close_button.h"
11 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
12 #include "chrome/browser/ui/tabs/tab_menu_model.h"
13 #include "chrome/browser/ui/tabs/tab_utils.h"
14 #include "url/gurl.h"
16 // The loading/waiting state of the tab.
17 enum TabLoadingState {
18 kTabDone,
19 kTabLoading,
20 kTabWaiting,
21 kTabCrashed,
24 @class MediaIndicatorButton;
25 @class MenuController;
26 namespace TabControllerInternal {
27 class MenuDelegate;
29 @class SpriteView;
30 @class TabView;
31 @protocol TabControllerTarget;
33 // A class that manages a single tab in the tab strip. Set its target/action
34 // to be sent a message when the tab is selected by the user clicking. Setting
35 // the |loading| property to YES visually indicates that this tab is currently
36 // loading content via a spinner.
38 // The tab has the notion of an "icon view" which can be used to display
39 // identifying characteristics such as a favicon, or since it's a full-fledged
40 // view, something with state and animation such as a throbber for illustrating
41 // progress. The default in the nib is an image view so nothing special is
42 // required if that's all you need.
44 @interface TabController : NSViewController<TabDraggingEventTarget> {
45 @private
46 base::scoped_nsobject<SpriteView> iconView_;
47 base::scoped_nsobject<MediaIndicatorButton> mediaIndicatorButton_;
48 base::scoped_nsobject<HoverCloseButton> closeButton_;
50 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib
51 BOOL isIconShowing_; // last state of iconView_ in updateVisibility
53 BOOL app_;
54 BOOL mini_;
55 BOOL pinned_;
56 BOOL active_;
57 BOOL selected_;
58 GURL url_;
59 TabLoadingState loadingState_;
60 id<TabControllerTarget> target_; // weak, where actions are sent
61 SEL action_; // selector sent when tab is selected by clicking
62 scoped_ptr<ui::SimpleMenuModel> contextMenuModel_;
63 scoped_ptr<TabControllerInternal::MenuDelegate> contextMenuDelegate_;
64 base::scoped_nsobject<MenuController> contextMenuController_;
67 @property(assign, nonatomic) TabLoadingState loadingState;
69 @property(assign, nonatomic) SEL action;
70 @property(assign, nonatomic) BOOL app;
71 @property(assign, nonatomic) BOOL mini;
72 @property(assign, nonatomic) BOOL pinned;
73 @property(assign, nonatomic) NSString* toolTip;
74 // Note that |-selected| will return YES if the controller is |-active|, too.
75 // |-setSelected:| affects the selection, while |-setActive:| affects the key
76 // status/focus of the content.
77 @property(assign, nonatomic) BOOL active;
78 @property(assign, nonatomic) BOOL selected;
79 @property(assign, nonatomic) id target;
80 @property(assign, nonatomic) GURL url;
81 @property(readonly, nonatomic) NSView* iconView;
82 @property(readonly, nonatomic) MediaIndicatorButton* mediaIndicatorButton;
83 @property(readonly, nonatomic) HoverCloseButton* closeButton;
85 // Default height for tabs.
86 + (CGFloat)defaultTabHeight;
88 // Minimum and maximum allowable tab width. The minimum width does not show
89 // the icon or the close button. The active tab always has at least a close
90 // button so it has a different minimum width.
91 + (CGFloat)minTabWidth;
92 + (CGFloat)maxTabWidth;
93 + (CGFloat)minActiveTabWidth;
94 + (CGFloat)miniTabWidth;
95 + (CGFloat)appTabWidth;
97 // The view associated with this controller, pre-casted as a TabView
98 - (TabView*)tabView;
100 // Sets the tab's icon image.
101 // |image| must be 16x16 in size.
102 // |image| can be a horizontal strip of image sprites which will be animated.
103 // Setting |animate| to YES will animate away the old image before animating
104 // the new image back to position.
105 - (void)setIconImage:(NSImage*)image;
106 - (void)setIconImage:(NSImage*)image withToastAnimation:(BOOL)animate;
108 // Sets the current tab media state and updates the views.
109 - (void)setMediaState:(TabMediaState)mediaState;
111 // Closes the associated TabView by relaying the message to |target_| to
112 // perform the close.
113 - (void)closeTab:(id)sender;
115 // Selects the associated TabView by sending |action_| to |target_|.
116 - (void)selectTab:(id)sender;
118 // Called by the tabs to determine whether we are in rapid (tab) closure mode.
119 // In this mode, we handle clicks slightly differently due to animation.
120 // Ideally, tabs would know about their own animation and wouldn't need this.
121 - (BOOL)inRapidClosureMode;
123 // Updates the visibility of certain subviews, such as the icon and close
124 // button, based on criteria such as the tab's selected state and its current
125 // width.
126 - (void)updateVisibility;
128 // Update the title color to match the tabs current state.
129 - (void)updateTitleColor;
130 @end
132 @interface TabController(TestingAPI)
133 - (int)iconCapacity;
134 - (BOOL)shouldShowIcon;
135 - (BOOL)shouldShowMediaIndicator;
136 - (BOOL)shouldShowCloseButton;
137 @end // TabController(TestingAPI)
139 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_