| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ui/cocoa/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
| 11 #include "app/mac/nsimage_cache.h" |
| 11 #include "app/menus/accelerator_cocoa.h" | 12 #include "app/menus/accelerator_cocoa.h" |
| 12 #include "app/menus/menu_model.h" | 13 #include "app/menus/menu_model.h" |
| 13 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
| 14 #include "base/mac_util.h" | 15 #include "base/mac_util.h" |
| 15 #include "base/nsimage_cache_mac.h" | |
| 16 #include "base/singleton.h" | 16 #include "base/singleton.h" |
| 17 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
| 18 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete.h" | 19 #include "chrome/browser/autocomplete/autocomplete.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 21 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 22 #include "chrome/browser/autocomplete/autocomplete_match.h" | 22 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 23 #include "chrome/browser/net/url_fixer_upper.h" | 23 #include "chrome/browser/net/url_fixer_upper.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Called after the view is done loading and the outlets have been hooked up. | 218 // Called after the view is done loading and the outlets have been hooked up. |
| 219 // Now we can hook up bridges that rely on UI objects such as the location | 219 // Now we can hook up bridges that rely on UI objects such as the location |
| 220 // bar and button state. | 220 // bar and button state. |
| 221 - (void)awakeFromNib { | 221 - (void)awakeFromNib { |
| 222 // A bug in AppKit (<rdar://7298597>, <http://openradar.me/7298597>) causes | 222 // A bug in AppKit (<rdar://7298597>, <http://openradar.me/7298597>) causes |
| 223 // images loaded directly from nibs in a framework to not get their "template" | 223 // images loaded directly from nibs in a framework to not get their "template" |
| 224 // flags set properly. Thus, despite the images being set on the buttons in | 224 // flags set properly. Thus, despite the images being set on the buttons in |
| 225 // the xib, we must set them in code. | 225 // the xib, we must set them in code. |
| 226 [backButton_ setImage:nsimage_cache::ImageNamed(kBackButtonImageName)]; | 226 [backButton_ setImage:app::mac::GetCachedImageWithName(kBackButtonImageName)]; |
| 227 [forwardButton_ setImage:nsimage_cache::ImageNamed(kForwardButtonImageName)]; | 227 [forwardButton_ setImage: |
| 228 [reloadButton_ | 228 app::mac::GetCachedImageWithName(kForwardButtonImageName)]; |
| 229 setImage:nsimage_cache::ImageNamed(kReloadButtonReloadImageName)]; | 229 [reloadButton_ setImage: |
| 230 [homeButton_ setImage:nsimage_cache::ImageNamed(kHomeButtonImageName)]; | 230 app::mac::GetCachedImageWithName(kReloadButtonReloadImageName)]; |
| 231 [wrenchButton_ setImage:nsimage_cache::ImageNamed(kWrenchButtonImageName)]; | 231 [homeButton_ setImage: |
| 232 app::mac::GetCachedImageWithName(kHomeButtonImageName)]; |
| 233 [wrenchButton_ setImage: |
| 234 app::mac::GetCachedImageWithName(kWrenchButtonImageName)]; |
| 232 | 235 |
| 233 if (UpgradeDetector::GetInstance()->notify_upgrade()) | 236 if (UpgradeDetector::GetInstance()->notify_upgrade()) |
| 234 [self badgeWrenchMenu]; | 237 [self badgeWrenchMenu]; |
| 235 | 238 |
| 236 [backButton_ setShowsBorderOnlyWhileMouseInside:YES]; | 239 [backButton_ setShowsBorderOnlyWhileMouseInside:YES]; |
| 237 [forwardButton_ setShowsBorderOnlyWhileMouseInside:YES]; | 240 [forwardButton_ setShowsBorderOnlyWhileMouseInside:YES]; |
| 238 [reloadButton_ setShowsBorderOnlyWhileMouseInside:YES]; | 241 [reloadButton_ setShowsBorderOnlyWhileMouseInside:YES]; |
| 239 [homeButton_ setShowsBorderOnlyWhileMouseInside:YES]; | 242 [homeButton_ setShowsBorderOnlyWhileMouseInside:YES]; |
| 240 [wrenchButton_ setShowsBorderOnlyWhileMouseInside:YES]; | 243 [wrenchButton_ setShowsBorderOnlyWhileMouseInside:YES]; |
| 241 | 244 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 [wrenchButton_ setAttachedMenu:[wrenchMenuController_ menu]]; | 525 [wrenchButton_ setAttachedMenu:[wrenchMenuController_ menu]]; |
| 523 } | 526 } |
| 524 | 527 |
| 525 - (WrenchMenuController*)wrenchMenuController { | 528 - (WrenchMenuController*)wrenchMenuController { |
| 526 return wrenchMenuController_; | 529 return wrenchMenuController_; |
| 527 } | 530 } |
| 528 | 531 |
| 529 - (void)badgeWrenchMenu { | 532 - (void)badgeWrenchMenu { |
| 530 NSImage* badge = ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 533 NSImage* badge = ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 531 IDR_UPDATE_BADGE); | 534 IDR_UPDATE_BADGE); |
| 532 NSImage* wrenchImage = nsimage_cache::ImageNamed(kWrenchButtonImageName); | 535 NSImage* wrenchImage = |
| 536 app::mac::GetCachedImageWithName(kWrenchButtonImageName); |
| 533 NSSize wrenchImageSize = [wrenchImage size]; | 537 NSSize wrenchImageSize = [wrenchImage size]; |
| 534 | 538 |
| 535 scoped_nsobject<NSImage> overlayImage( | 539 scoped_nsobject<NSImage> overlayImage( |
| 536 [[NSImage alloc] initWithSize:wrenchImageSize]); | 540 [[NSImage alloc] initWithSize:wrenchImageSize]); |
| 537 | 541 |
| 538 [overlayImage lockFocus]; | 542 [overlayImage lockFocus]; |
| 539 [badge drawAtPoint:NSZeroPoint | 543 [badge drawAtPoint:NSZeroPoint |
| 540 fromRect:NSZeroRect | 544 fromRect:NSZeroRect |
| 541 operation:NSCompositeSourceOver | 545 operation:NSCompositeSourceOver |
| 542 fraction:1.0]; | 546 fraction:1.0]; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 767 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
| 764 // Do nothing. | 768 // Do nothing. |
| 765 } | 769 } |
| 766 | 770 |
| 767 // (URLDropTargetController protocol) | 771 // (URLDropTargetController protocol) |
| 768 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 772 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 769 // Do nothing. | 773 // Do nothing. |
| 770 } | 774 } |
| 771 | 775 |
| 772 @end | 776 @end |
| OLD | NEW |