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

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 114017: Use Chrome facilities for omnibox state save and restore on Mac. (Closed)
Patch Set: Wordsmithing. Created 11 years, 7 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
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 #import "chrome/browser/cocoa/toolbar_controller.h" 5 #import "chrome/browser/cocoa/toolbar_controller.h"
6 6
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
10 #import "chrome/browser/cocoa/location_bar_view_mac.h" 10 #import "chrome/browser/cocoa/location_bar_view_mac.h"
(...skipping 30 matching lines...) Expand all
41 return self; 41 return self;
42 } 42 }
43 43
44 // Called after the view is done loading and the outlets have been hooked up. 44 // Called after the view is done loading and the outlets have been hooked up.
45 // Now we can hook up bridges that rely on UI objects such as the location 45 // Now we can hook up bridges that rely on UI objects such as the location
46 // bar and button state. 46 // bar and button state.
47 - (void)awakeFromNib { 47 - (void)awakeFromNib {
48 [self initCommandStatus:commands_]; 48 [self initCommandStatus:commands_];
49 locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_, 49 locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_,
50 toolbarModel_, profile_)); 50 toolbarModel_, profile_));
51 [locationBar_ setStringValue:@"http://dev.chromium.org"];
52 } 51 }
53 52
54 - (void)dealloc { 53 - (void)dealloc {
55 [super dealloc]; 54 [super dealloc];
56 } 55 }
57 56
58 - (LocationBar*)locationBar { 57 - (LocationBar*)locationBar {
59 return locationBarView_.get(); 58 return locationBarView_.get();
60 } 59 }
61 60
(...skipping 29 matching lines...) Expand all
91 - (void)initCommandStatus:(CommandUpdater*)commands { 90 - (void)initCommandStatus:(CommandUpdater*)commands {
92 [backButton_ setEnabled:commands->IsCommandEnabled(IDC_BACK) ? YES : NO]; 91 [backButton_ setEnabled:commands->IsCommandEnabled(IDC_BACK) ? YES : NO];
93 [forwardButton_ 92 [forwardButton_
94 setEnabled:commands->IsCommandEnabled(IDC_FORWARD) ? YES : NO]; 93 setEnabled:commands->IsCommandEnabled(IDC_FORWARD) ? YES : NO];
95 [reloadButton_ 94 [reloadButton_
96 setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO]; 95 setEnabled:commands->IsCommandEnabled(IDC_RELOAD) ? YES : NO];
97 // TODO(pinkerton): Add home button. 96 // TODO(pinkerton): Add home button.
98 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; 97 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO];
99 } 98 }
100 99
101 - (void)updateToolbarWithContents:(TabContents*)tab { 100 - (void)updateToolbarWithContents:(TabContents*)tab
102 // TODO(pinkerton): there's a lot of ui code in autocomplete_edit.cc 101 shouldRestoreState:(BOOL)shouldRestore {
103 // that we'll want to duplicate. For now, just handle setting the text. 102 locationBarView_->Update(tab, shouldRestore ? true : false);
104
105 // TODO(shess): This is the start of what pinkerton refers to.
106 // Unfortunately, I'm going to need to spend some time wiring things
107 // up. This call should suffice to close any open autocomplete
108 // pulldown. It should also be the right thing to do to save and
109 // restore state, but at this time it's not clear that this is the
110 // right place, and tab is not the right parameter.
111 if (locationBarView_.get()) {
112 locationBarView_->SaveStateToContents(NULL);
113 }
114
115 // TODO(pinkerton): update the security lock icon and background color
116
117 // TODO(shess): Determine whether this should happen via
118 // locationBarView_, instead, in which case this class can
119 // potentially lose the locationBar_ reference.
120 NSString* urlString = base::SysWideToNSString(toolbarModel_->GetText());
121 [locationBar_ setStringValue:urlString];
122 } 103 }
123 104
124 - (void)setStarredState:(BOOL)isStarred { 105 - (void)setStarredState:(BOOL)isStarred {
125 NSString* starImageName = kStarImageName; 106 NSString* starImageName = kStarImageName;
126 if (isStarred) 107 if (isStarred)
127 starImageName = kStarredImageName; 108 starImageName = kStarredImageName;
128 [starButton_ setImage:[NSImage imageNamed:starImageName]]; 109 [starButton_ setImage:[NSImage imageNamed:starImageName]];
129 } 110 }
130 111
131 - (void)setIsLoading:(BOOL)isLoading { 112 - (void)setIsLoading:(BOOL)isLoading {
132 NSString* imageName = @"go"; 113 NSString* imageName = @"go";
133 if (isLoading) 114 if (isLoading)
134 imageName = @"stop"; 115 imageName = @"stop";
135 [goButton_ setImage:[NSImage imageNamed:imageName]]; 116 [goButton_ setImage:[NSImage imageNamed:imageName]];
136 } 117 }
137 118
138 // Returns an array of views in the order of the outlets above. 119 // Returns an array of views in the order of the outlets above.
139 - (NSArray*)toolbarViews { 120 - (NSArray*)toolbarViews {
140 return [NSArray arrayWithObjects:backButton_, forwardButton_, reloadButton_, 121 return [NSArray arrayWithObjects:backButton_, forwardButton_, reloadButton_,
141 starButton_, goButton_, locationBar_, nil]; 122 starButton_, goButton_, locationBar_, nil];
142 } 123 }
143 124
144 @end 125 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698