blob: b6ec8d444d2a9ff67358c6ccbbc35237ff79a530 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Copyright (c) 2009 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.
#ifndef CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_
#define CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#include "base/scoped_ptr.h"
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/command_observer_bridge.h"
#import "chrome/browser/cocoa/bookmark_bar_controller.h"
#include "chrome/common/pref_member.h"
@class BookmarkBarView;
class CommandUpdater;
class LocationBar;
class LocationBarViewMac;
namespace ToolbarControllerInternal {
class PrefObserverBridge;
}
class Profile;
class TabContents;
class ToolbarModel;
class ToolbarView;
// Field editor used for the location bar.
@interface LocationBarFieldEditor : NSTextView
// Copy contents of the TextView to the designated clipboard as plain text.
- (void)performCopy:(NSPasteboard*)pb;
// Same as above, note that this calls through to performCopy.
- (void)performCut:(NSPasteboard*)pb;
@end
// A controller for the toolbar in the browser window. Manages
// updating the state for location bar and back/fwd/reload/go buttons.
// Manages the bookmark bar and it's position in the window relative to
// the web content view.
@interface ToolbarController : NSViewController<CommandObserverProtocol> {
@private
ToolbarModel* toolbarModel_; // weak, one per window
CommandUpdater* commands_; // weak, one per window
Profile* profile_; // weak, one per window
scoped_ptr<CommandObserverBridge> commandObserver_;
scoped_ptr<LocationBarViewMac> locationBarView_;
scoped_nsobject<LocationBarFieldEditor> locationBarFieldEditor_; // strong
scoped_nsobject<BookmarkBarController> bookmarkBarController_;
id<BookmarkURLOpener> bookmarkBarDelegate_; // weak
NSView* webContentView_; // weak; where the web goes
// Used for monitoring the optional toolbar button prefs.
scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_;
BooleanPrefMember showHomeButton_;
BooleanPrefMember showPageOptionButtons_;
IBOutlet NSMenu* pageMenu_;
IBOutlet NSMenu* wrenchMenu_;
// The ordering is important for unit tests. If new items are added or the
// ordering is changed, make sure to update |-toolbarViews| and the
// corresponding enum in the unit tests.
IBOutlet NSButton* backButton_;
IBOutlet NSButton* forwardButton_;
IBOutlet NSButton* reloadButton_;
IBOutlet NSButton* homeButton_;
IBOutlet NSButton* starButton_;
IBOutlet NSButton* goButton_;
IBOutlet NSButton* pageButton_;
IBOutlet NSButton* wrenchButton_;
IBOutlet NSTextField* locationBar_;
IBOutlet BookmarkBarView* bookmarkBarView_;
}
// Initialize the toolbar and register for command updates. The profile is
// needed for initializing the location bar.
- (id)initWithModel:(ToolbarModel*)model
commands:(CommandUpdater*)commands
profile:(Profile*)profile
webContentView:(NSView*)webContentView
bookmarkDelegate:(id<BookmarkURLOpener>)delegate;
// Get the C++ bridge object representing the location bar for this tab.
- (LocationBar*)locationBar;
// Called by the Window delegate so we can provide a custom field editor if
// needed.
// Note that this may be called for objects unrelated to the toolbar.
// returns nil if we don't want to override the custom field editor for |obj|.
- (id)customFieldEditorForObject:(id)obj;
// Make the location bar the first responder, if possible.
- (void)focusLocationBar;
// Updates the toolbar (and transitively the location bar) with the states of
// the specified |tab|. If |shouldRestore| is true, we're switching
// (back?) to this tab and should restore any previous location bar state
// (such as user editing) as well.
- (void)updateToolbarWithContents:(TabContents*)tabForRestoring
shouldRestoreState:(BOOL)shouldRestore;
// Sets whether or not the current page in the frontmost tab is bookmarked.
- (void)setStarredState:(BOOL)isStarred;
// Called to update the loading state. Handles updating the go/stop button
// state.
- (void)setIsLoading:(BOOL)isLoading;
// Return the bookmark bar controller.
- (BookmarkBarController*)bookmarkBarController;
// Actions for the optional menu buttons for the page and wrench menus. These
// will show a menu while the mouse is down.
- (IBAction)showPageMenu:(id)sender;
- (IBAction)showWrenchMenu:(id)sender;
@end
// A set of private methods used by tests, in the absence of "friends" in ObjC.
@interface ToolbarController(PrivateTestMethods)
// Returns an array of views in the order of the outlets above.
- (NSArray*)toolbarViews;
- (void)showOptionalHomeButton;
- (void)showOptionalPageWrenchButtons;
@end
#endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_
|