| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const CGFloat kMinimumLocationBarWidth = 100.0; | 74 const CGFloat kMinimumLocationBarWidth = 100.0; |
| 75 | 75 |
| 76 // The duration of any animation that occurs within the toolbar in seconds. | 76 // The duration of any animation that occurs within the toolbar in seconds. |
| 77 const CGFloat kAnimationDuration = 0.2; | 77 const CGFloat kAnimationDuration = 0.2; |
| 78 | 78 |
| 79 // The amount of left padding that the wrench menu should have. | 79 // The amount of left padding that the wrench menu should have. |
| 80 const CGFloat kWrenchMenuLeftPadding = 3.0; | 80 const CGFloat kWrenchMenuLeftPadding = 3.0; |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 @interface ToolbarController(Private) | 84 @interface ToolbarController() |
| 85 @property(assign, nonatomic) Browser* browser; |
| 85 - (void)addAccessibilityDescriptions; | 86 - (void)addAccessibilityDescriptions; |
| 86 - (void)initCommandStatus:(CommandUpdater*)commands; | 87 - (void)initCommandStatus:(CommandUpdater*)commands; |
| 87 - (void)prefChanged:(std::string*)prefName; | 88 - (void)prefChanged:(std::string*)prefName; |
| 88 - (BackgroundGradientView*)backgroundGradientView; | 89 - (BackgroundGradientView*)backgroundGradientView; |
| 89 - (void)toolbarFrameChanged; | 90 - (void)toolbarFrameChanged; |
| 90 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; | 91 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; |
| 91 - (void)maintainMinimumLocationBarWidth; | 92 - (void)maintainMinimumLocationBarWidth; |
| 92 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; | 93 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; |
| 93 - (void)browserActionsContainerDragged:(NSNotification*)notification; | 94 - (void)browserActionsContainerDragged:(NSNotification*)notification; |
| 94 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; | 95 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 121 | 122 |
| 122 // A class registered for C++ notifications. This is used to detect changes in | 123 // A class registered for C++ notifications. This is used to detect changes in |
| 123 // preferences and upgrade available notifications. Bridges the notification | 124 // preferences and upgrade available notifications. Bridges the notification |
| 124 // back to the ToolbarController. | 125 // back to the ToolbarController. |
| 125 class NotificationBridge : public NotificationObserver { | 126 class NotificationBridge : public NotificationObserver { |
| 126 public: | 127 public: |
| 127 explicit NotificationBridge(ToolbarController* controller) | 128 explicit NotificationBridge(ToolbarController* controller) |
| 128 : controller_(controller) { | 129 : controller_(controller) { |
| 129 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 130 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 130 NotificationService::AllSources()); | 131 NotificationService::AllSources()); |
| 132 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 133 Source<Profile>([controller browser]->profile())); |
| 131 } | 134 } |
| 132 | 135 |
| 133 // Overridden from NotificationObserver: | 136 // Overridden from NotificationObserver: |
| 134 virtual void Observe(int type, | 137 virtual void Observe(int type, |
| 135 const NotificationSource& source, | 138 const NotificationSource& source, |
| 136 const NotificationDetails& details) { | 139 const NotificationDetails& details) { |
| 137 switch (type) { | 140 switch (type) { |
| 138 case chrome::NOTIFICATION_PREF_CHANGED: | 141 case chrome::NOTIFICATION_PREF_CHANGED: |
| 139 [controller_ prefChanged:Details<std::string>(details).ptr()]; | 142 [controller_ prefChanged:Details<std::string>(details).ptr()]; |
| 140 break; | 143 break; |
| 141 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 144 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 145 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 142 [controller_ badgeWrenchMenuIfNeeded]; | 146 [controller_ badgeWrenchMenuIfNeeded]; |
| 143 break; | 147 break; |
| 144 default: | 148 default: |
| 145 NOTREACHED(); | 149 NOTREACHED(); |
| 146 } | 150 } |
| 147 } | 151 } |
| 148 | 152 |
| 149 private: | 153 private: |
| 150 ToolbarController* controller_; // weak, owns us | 154 ToolbarController* controller_; // weak, owns us |
| 151 | 155 |
| 152 NotificationRegistrar registrar_; | 156 NotificationRegistrar registrar_; |
| 153 }; | 157 }; |
| 154 | 158 |
| 155 } // namespace ToolbarControllerInternal | 159 } // namespace ToolbarControllerInternal |
| 156 | 160 |
| 157 @implementation ToolbarController | 161 @implementation ToolbarController |
| 158 | 162 |
| 163 @synthesize browser = browser_; |
| 164 |
| 159 - (id)initWithModel:(ToolbarModel*)model | 165 - (id)initWithModel:(ToolbarModel*)model |
| 160 commands:(CommandUpdater*)commands | 166 commands:(CommandUpdater*)commands |
| 161 profile:(Profile*)profile | 167 profile:(Profile*)profile |
| 162 browser:(Browser*)browser | 168 browser:(Browser*)browser |
| 163 resizeDelegate:(id<ViewResizer>)resizeDelegate | 169 resizeDelegate:(id<ViewResizer>)resizeDelegate |
| 164 nibFileNamed:(NSString*)nibName { | 170 nibFileNamed:(NSString*)nibName { |
| 165 DCHECK(model && commands && profile && [nibName length]); | 171 DCHECK(model && commands && profile && [nibName length]); |
| 166 if ((self = [super initWithNibName:nibName | 172 if ((self = [super initWithNibName:nibName |
| 167 bundle:base::mac::MainAppBundle()])) { | 173 bundle:base::mac::MainAppBundle()])) { |
| 168 toolbarModel_ = model; | 174 toolbarModel_ = model; |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 811 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 806 // Do nothing. | 812 // Do nothing. |
| 807 } | 813 } |
| 808 | 814 |
| 809 // (URLDropTargetController protocol) | 815 // (URLDropTargetController protocol) |
| 810 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 816 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 811 return drag_util::IsUnsupportedDropData(profile_, info); | 817 return drag_util::IsUnsupportedDropData(profile_, info); |
| 812 } | 818 } |
| 813 | 819 |
| 814 @end | 820 @end |
| OLD | NEW |