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

Side by Side Diff: chrome/browser/cocoa/tab_controller.h

Issue 500030: Factor tab context menu into a shared model and fix mac and win to use it. Im... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_
6 #define CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_ 6 #define CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #import "chrome/browser/cocoa/hover_close_button.h" 9 #import "chrome/browser/cocoa/hover_close_button.h"
10 #include "chrome/browser/tab_menu_model.h"
10 11
11 // The loading/waiting state of the tab. 12 // The loading/waiting state of the tab.
12 // TODO(pinkerton): this really doesn't belong here, but something needs to 13 // TODO(pinkerton): this really doesn't belong here, but something needs to
13 // know the state and another parallel array in TabStripController doesn't seem 14 // know the state and another parallel array in TabStripController doesn't seem
14 // like the right place either. In a perfect world, this class shouldn't know 15 // like the right place either. In a perfect world, this class shouldn't know
15 // anything about states that are specific to a browser. 16 // anything about states that are specific to a browser.
16 enum TabLoadingState { 17 enum TabLoadingState {
17 kTabDone, 18 kTabDone,
18 kTabLoading, 19 kTabLoading,
19 kTabWaiting, 20 kTabWaiting,
20 kTabCrashed, 21 kTabCrashed,
21 }; 22 };
22 23
24 @class MenuController;
25 namespace TabControllerInternal {
26 class MenuDelegate;
27 }
23 @class TabView; 28 @class TabView;
24 @protocol TabControllerTarget; 29 @protocol TabControllerTarget;
25 30
26 // A class that manages a single tab in the tab strip. Set its target/action 31 // A class that manages a single tab in the tab strip. Set its target/action
27 // to be sent a message when the tab is selected by the user clicking. Setting 32 // to be sent a message when the tab is selected by the user clicking. Setting
28 // the |loading| property to YES visually indicates that this tab is currently 33 // the |loading| property to YES visually indicates that this tab is currently
29 // loading content via a spinner. 34 // loading content via a spinner.
30 // 35 //
31 // The tab has the notion of an "icon view" which can be used to display 36 // The tab has the notion of an "icon view" which can be used to display
32 // identifying characteristics such as a favicon, or since it's a full-fledged 37 // identifying characteristics such as a favicon, or since it's a full-fledged
33 // view, something with state and animation such as a throbber for illustrating 38 // view, something with state and animation such as a throbber for illustrating
34 // progress. The default in the nib is an image view so nothing special is 39 // progress. The default in the nib is an image view so nothing special is
35 // required if that's all you need. 40 // required if that's all you need.
36 41
37 @interface TabController : NSViewController { 42 @interface TabController : NSViewController {
38 @private 43 @private
39 IBOutlet NSView* iconView_; 44 IBOutlet NSView* iconView_;
40 IBOutlet NSTextField* titleView_; 45 IBOutlet NSTextField* titleView_;
41 IBOutlet NSMenu* contextMenu_;
42 IBOutlet HoverCloseButton* closeButton_; 46 IBOutlet HoverCloseButton* closeButton_;
43 47
44 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib 48 NSRect originalIconFrame_; // frame of iconView_ as loaded from nib
45 BOOL isIconShowing_; // last state of iconView_ in updateVisibility 49 BOOL isIconShowing_; // last state of iconView_ in updateVisibility
46 BOOL selected_; 50 BOOL selected_;
47 BOOL pinned_; 51 BOOL pinned_;
48 TabLoadingState loadingState_; 52 TabLoadingState loadingState_;
49 CGFloat iconTitleXOffset_; // between left edges of icon and title 53 CGFloat iconTitleXOffset_; // between left edges of icon and title
50 CGFloat titleCloseWidthOffset_; // between right edges of icon and close btn. 54 CGFloat titleCloseWidthOffset_; // between right edges of icon and close btn.
51 id<TabControllerTarget> target_; // weak, where actions are sent 55 id<TabControllerTarget> target_; // weak, where actions are sent
52 SEL action_; // selector sent when tab is selected by clicking 56 SEL action_; // selector sent when tab is selected by clicking
57 scoped_ptr<TabMenuModel> contextMenuModel_;
58 scoped_ptr<TabControllerInternal::MenuDelegate> contextMenuDelegate_;
59 scoped_nsobject<MenuController> contextMenuController_;
53 } 60 }
54 61
55 @property(assign, nonatomic) TabLoadingState loadingState; 62 @property(assign, nonatomic) TabLoadingState loadingState;
56 63
57 @property(assign, nonatomic) BOOL selected; 64 @property(assign, nonatomic) BOOL selected;
58 @property(assign, nonatomic) BOOL pinned; 65 @property(assign, nonatomic) BOOL pinned;
59 @property(assign, nonatomic) id target; 66 @property(assign, nonatomic) id target;
60 @property(assign, nonatomic) SEL action; 67 @property(assign, nonatomic) SEL action;
61 68
62 // Minimum and maximum allowable tab width. The minimum width does not show 69 // Minimum and maximum allowable tab width. The minimum width does not show
63 // the icon or the close button. The selected tab always has at least a close 70 // the icon or the close button. The selected tab always has at least a close
64 // button so it has a different minimum width. 71 // button so it has a different minimum width.
65 + (CGFloat)minTabWidth; 72 + (CGFloat)minTabWidth;
66 + (CGFloat)maxTabWidth; 73 + (CGFloat)maxTabWidth;
67 + (CGFloat)minSelectedTabWidth; 74 + (CGFloat)minSelectedTabWidth;
68 + (CGFloat)pinnedTabWidth; 75 + (CGFloat)pinnedTabWidth;
69 76
70 // The view associated with this controller, pre-casted as a TabView 77 // The view associated with this controller, pre-casted as a TabView
71 - (TabView*)tabView; 78 - (TabView*)tabView;
72 79
73 // Closes the associated TabView by relaying the message to |target_| to 80 // Closes the associated TabView by relaying the message to |target_| to
74 // perform the close. 81 // perform the close.
75 - (IBAction)closeTab:(id)sender; 82 - (IBAction)closeTab:(id)sender;
76 83
77 // Dispatches the command in the tag to the registered target object.
78 - (IBAction)commandDispatch:(id)sender;
79
80 // Replace the current icon view with the given view. |iconView| will be 84 // Replace the current icon view with the given view. |iconView| will be
81 // resized to the size of the current icon view. 85 // resized to the size of the current icon view.
82 - (void)setIconView:(NSView*)iconView; 86 - (void)setIconView:(NSView*)iconView;
83 - (NSView*)iconView; 87 - (NSView*)iconView;
84 88
85 // Called by the tabs to determine whether we are in rapid (tab) closure mode. 89 // Called by the tabs to determine whether we are in rapid (tab) closure mode.
86 // In this mode, we handle clicks slightly differently due to animation. 90 // In this mode, we handle clicks slightly differently due to animation.
87 // Ideally, tabs would know about their own animation and wouldn't need this. 91 // Ideally, tabs would know about their own animation and wouldn't need this.
88 - (BOOL)inRapidClosureMode; 92 - (BOOL)inRapidClosureMode;
89 93
90 // Updates the visibility of certain subviews, such as the icon and close 94 // Updates the visibility of certain subviews, such as the icon and close
91 // button, based on criteria such as the tab's selected state and its current 95 // button, based on criteria such as the tab's selected state and its current
92 // width. 96 // width.
93 - (void)updateVisibility; 97 - (void)updateVisibility;
94 98
95 // Update the title color to match the tabs current state. 99 // Update the title color to match the tabs current state.
96 - (void)updateTitleColor; 100 - (void)updateTitleColor;
97 @end 101 @end
98 102
99 @interface TabController(TestingAPI) 103 @interface TabController(TestingAPI)
100 - (NSString*)toolTip; 104 - (NSString*)toolTip;
101 - (int)iconCapacity; 105 - (int)iconCapacity;
102 - (BOOL)shouldShowIcon; 106 - (BOOL)shouldShowIcon;
103 - (BOOL)shouldShowCloseButton; 107 - (BOOL)shouldShowCloseButton;
104 @end // TabController(TestingAPI) 108 @end // TabController(TestingAPI)
105 109
106 #endif // CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_ 110 #endif // CHROME_BROWSER_COCOA_TAB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698