| OLD | NEW |
| 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/autocomplete_text_field.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 11 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 11 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 12 #import "chrome/browser/cocoa/gradient_button_cell.h" |
| 12 #import "chrome/browser/cocoa/location_bar_view_mac.h" | 13 #import "chrome/browser/cocoa/location_bar_view_mac.h" |
| 13 #include "chrome/browser/cocoa/nsimage_cache.h" | 14 #include "chrome/browser/cocoa/nsimage_cache.h" |
| 14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/toolbar_model.h" | 16 #include "chrome/browser/toolbar_model.h" |
| 16 #include "chrome/common/notification_details.h" | 17 #include "chrome/common/notification_details.h" |
| 17 #include "chrome/common/notification_observer.h" | 18 #include "chrome/common/notification_observer.h" |
| 18 #include "chrome/common/notification_type.h" | 19 #include "chrome/common/notification_type.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/pref_service.h" | 21 #include "chrome/common/pref_service.h" |
| 21 | 22 |
| 22 // Names of images in the bundle for the star icon (normal and 'starred'). | 23 // Name of image in the bundle for the yellow of the star icon. |
| 23 static NSString* const kStarImageName = @"star_Template.pdf"; | |
| 24 static NSString* const kStarredImageName = @"starred.pdf"; | 24 static NSString* const kStarredImageName = @"starred.pdf"; |
| 25 | 25 |
| 26 @interface ToolbarController(Private) | 26 @interface ToolbarController(Private) |
| 27 - (void)initCommandStatus:(CommandUpdater*)commands; | 27 - (void)initCommandStatus:(CommandUpdater*)commands; |
| 28 - (void)prefChanged:(std::wstring*)prefName; | 28 - (void)prefChanged:(std::wstring*)prefName; |
| 29 @end | 29 @end |
| 30 | 30 |
| 31 namespace ToolbarControllerInternal { | 31 namespace ToolbarControllerInternal { |
| 32 | 32 |
| 33 // A C++ class registered for changes in preferences. Bridges the | 33 // A C++ class registered for changes in preferences. Bridges the |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 [homeButton_ setEnabled:commands->IsCommandEnabled(IDC_HOME) ? YES : NO]; | 162 [homeButton_ setEnabled:commands->IsCommandEnabled(IDC_HOME) ? YES : NO]; |
| 163 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; | 163 [starButton_ setEnabled:commands->IsCommandEnabled(IDC_STAR) ? YES : NO]; |
| 164 } | 164 } |
| 165 | 165 |
| 166 - (void)updateToolbarWithContents:(TabContents*)tab | 166 - (void)updateToolbarWithContents:(TabContents*)tab |
| 167 shouldRestoreState:(BOOL)shouldRestore { | 167 shouldRestoreState:(BOOL)shouldRestore { |
| 168 locationBarView_->Update(tab, shouldRestore ? true : false); | 168 locationBarView_->Update(tab, shouldRestore ? true : false); |
| 169 } | 169 } |
| 170 | 170 |
| 171 - (void)setStarredState:(BOOL)isStarred { | 171 - (void)setStarredState:(BOOL)isStarred { |
| 172 NSString* starImageName = kStarImageName; | 172 NSImage* starImage = nil; |
| 173 BOOL isTemplate = YES; | 173 if (isStarred) |
| 174 if (isStarred) { | 174 starImage = nsimage_cache::ImageNamed(kStarredImageName); |
| 175 starImageName = kStarredImageName; | 175 |
| 176 isTemplate = NO; | 176 [(GradientButtonCell*)[starButton_ cell] setUnderlayImage:starImage]; |
| 177 } | |
| 178 NSImage* starImage = nsimage_cache::ImageNamed(starImageName); | |
| 179 if (isTemplate) | |
| 180 [starImage setTemplate:YES]; | |
| 181 [starButton_ setImage:starImage]; | |
| 182 } | 177 } |
| 183 | 178 |
| 184 - (void)setIsLoading:(BOOL)isLoading { | 179 - (void)setIsLoading:(BOOL)isLoading { |
| 185 NSString* imageName = @"go_Template.pdf"; | 180 NSString* imageName = @"go_Template.pdf"; |
| 186 NSInteger tag = IDC_GO; | 181 NSInteger tag = IDC_GO; |
| 187 if (isLoading) { | 182 if (isLoading) { |
| 188 imageName = @"stop_Template.pdf"; | 183 imageName = @"stop_Template.pdf"; |
| 189 tag = IDC_STOP; | 184 tag = IDC_STOP; |
| 190 } | 185 } |
| 191 NSImage* stopStartImage = nsimage_cache::ImageNamed(imageName); | 186 NSImage* stopStartImage = nsimage_cache::ImageNamed(imageName); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 forView:pageButton_]; | 320 forView:pageButton_]; |
| 326 } | 321 } |
| 327 | 322 |
| 328 - (IBAction)showWrenchMenu:(id)sender { | 323 - (IBAction)showWrenchMenu:(id)sender { |
| 329 [NSMenu popUpContextMenu:wrenchMenu_ | 324 [NSMenu popUpContextMenu:wrenchMenu_ |
| 330 withEvent:[NSApp currentEvent] | 325 withEvent:[NSApp currentEvent] |
| 331 forView:wrenchButton_]; | 326 forView:wrenchButton_]; |
| 332 } | 327 } |
| 333 | 328 |
| 334 @end | 329 @end |
| OLD | NEW |