Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tabs / tab_controller.h
blob7e4aa0d1a85d5f22de164735c88198fbda7a7a16
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 "url/gurl.h"
15 // The loading/waiting state of the tab.
16 enum TabLoadingState {
17 kTabDone,
18 kTabLoading,
19 kTabWaiting,
20 kTabCrashed,
23 @class GTMFadeTruncatingTextFieldCell;
24 @class MediaIndicatorView;
25 @class MenuController;
26 namespace TabControllerInternal {
27 class MenuDelegate;
29 @class TabView;
30 @protocol TabControllerTarget;
32 // A class that manages a single tab in the tab strip. Set its target/action
33 // to be sent a message when the tab is selected by the user clicking. Setting
34 // the |loading| property to YES visually indicates that this tab is currently
35 // loading content via a spinner.
37 // The tab has the notion of an "icon view" which can be used to display
38 // identifying characteristics such as a favicon, or since it's a full-fledged
39 // view, something with state and animation such as a throbber for illustrating
40 // progress. The default in the nib is an image view so nothing special is
41 // required if that's all you need.
43 @interface TabController : NSViewController<TabDraggingEventTarget> {
44 @private
45 base::scoped_nsobject<NSView> iconView_;
46 base::scoped_nsobject<NSTextField> titleView_;
47 GTMFadeTruncatingTextFieldCell* titleViewCell_; // weak
48 base::scoped_nsobject<MediaIndicatorView> mediaIndicatorView_;
49 base::scoped_nsobject<HoverCloseButton> closeButton_;
51 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib
52 BOOL isIconShowing_; // last state of iconView_ in updateVisibility
54 BOOL app_;
55 BOOL mini_;
56 BOOL pinned_;
57 BOOL active_;
58 BOOL selected_;
59 GURL url_;
60 TabLoadingState loadingState_;
61 id<TabControllerTarget> target_; // weak, where actions are sent
62 SEL action_; // selector sent when tab is selected by clicking
63 scoped_ptr<ui::SimpleMenuModel> contextMenuModel_;
64 scoped_ptr<TabControllerInternal::MenuDelegate> contextMenuDelegate_;
65 base::scoped_nsobject<MenuController> contextMenuController_;
68 @property(assign, nonatomic) TabLoadingState loadingState;
70 @property(assign, nonatomic) SEL action;
71 @property(assign, nonatomic) BOOL app;
72 @property(assign, nonatomic) BOOL mini;
73 @property(assign, nonatomic) BOOL pinned;
74 @property(assign, nonatomic) NSString* toolTip;
75 // Note that |-selected| will return YES if the controller is |-active|, too.
76 // |-setSelected:| affects the selection, while |-setActive:| affects the key
77 // status/focus of the content.
78 @property(assign, nonatomic) BOOL active;
79 @property(assign, nonatomic) BOOL selected;
80 @property(assign, nonatomic) id target;
81 @property(assign, nonatomic) GURL url;
82 @property(assign, nonatomic) NSView* iconView;
83 @property(readonly, nonatomic) NSTextField* titleView;
84 @property(assign, nonatomic) MediaIndicatorView* mediaIndicatorView;
85 @property(readonly, nonatomic) HoverCloseButton* closeButton;
87 // Minimum and maximum allowable tab width. The minimum width does not show
88 // the icon or the close button. The selected tab always has at least a close
89 // button so it has a different minimum width.
90 + (CGFloat)minTabWidth;
91 + (CGFloat)maxTabWidth;
92 + (CGFloat)minSelectedTabWidth;
93 + (CGFloat)miniTabWidth;
94 + (CGFloat)appTabWidth;
96 // The view associated with this controller, pre-casted as a TabView
97 - (TabView*)tabView;
99 // Closes the associated TabView by relaying the message to |target_| to
100 // perform the close.
101 - (void)closeTab:(id)sender;
103 // Selects the associated TabView by sending |action_| to |target_|.
104 - (void)selectTab:(id)sender;
106 // Called by the tabs to determine whether we are in rapid (tab) closure mode.
107 // In this mode, we handle clicks slightly differently due to animation.
108 // Ideally, tabs would know about their own animation and wouldn't need this.
109 - (BOOL)inRapidClosureMode;
111 // Updates the visibility of certain subviews, such as the icon and close
112 // button, based on criteria such as the tab's selected state and its current
113 // width.
114 - (void)updateVisibility;
116 // Update the title color to match the tabs current state.
117 - (void)updateTitleColor;
118 @end
120 @interface TabController(TestingAPI)
121 - (int)iconCapacity;
122 - (BOOL)shouldShowIcon;
123 - (BOOL)shouldShowMediaIndicator;
124 - (BOOL)shouldShowCloseButton;
125 @end // TabController(TestingAPI)
127 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_CONTROLLER_H_