OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 - (void)toolbarFrameChanged; | 154 - (void)toolbarFrameChanged; |
155 - (void)showLocationBarOnly; | 155 - (void)showLocationBarOnly; |
156 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; | 156 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; |
157 - (void)maintainMinimumLocationBarWidth; | 157 - (void)maintainMinimumLocationBarWidth; |
158 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; | 158 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; |
159 - (void)browserActionsContainerDragged:(NSNotification*)notification; | 159 - (void)browserActionsContainerDragged:(NSNotification*)notification; |
160 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; | 160 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; |
161 - (void)browserActionsContainerWillAnimate:(NSNotification*)notification; | 161 - (void)browserActionsContainerWillAnimate:(NSNotification*)notification; |
162 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; | 162 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; |
163 - (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity | 163 - (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity |
| 164 iconType:(AppMenuIconController::IconType)iconType |
164 animate:(BOOL)animate; | 165 animate:(BOOL)animate; |
165 @end | 166 @end |
166 | 167 |
167 namespace ToolbarControllerInternal { | 168 namespace ToolbarControllerInternal { |
168 | 169 |
169 // A C++ bridge class that handles listening for updates to commands and | 170 // A C++ bridge class that handles listening for updates to commands and |
170 // passing them back to ToolbarController. ToolbarController will create one of | 171 // passing them back to ToolbarController. ToolbarController will create one of |
171 // these bridges, pass them to CommandUpdater::AddCommandObserver, and then wait | 172 // these bridges, pass them to CommandUpdater::AddCommandObserver, and then wait |
172 // for update notifications, delivered via | 173 // for update notifications, delivered via |
173 // -enabledStateChangedForCommand:enabled:. | 174 // -enabledStateChangedForCommand:enabled:. |
(...skipping 24 matching lines...) Expand all Loading... |
198 explicit NotificationBridge(ToolbarController* controller) | 199 explicit NotificationBridge(ToolbarController* controller) |
199 : controller_(controller), | 200 : controller_(controller), |
200 app_menu_icon_controller_([controller browser]->profile(), this) {} | 201 app_menu_icon_controller_([controller browser]->profile(), this) {} |
201 ~NotificationBridge() override {} | 202 ~NotificationBridge() override {} |
202 | 203 |
203 void UpdateSeverity() { app_menu_icon_controller_.UpdateDelegate(); } | 204 void UpdateSeverity() { app_menu_icon_controller_.UpdateDelegate(); } |
204 | 205 |
205 void UpdateSeverity(AppMenuIconController::IconType type, | 206 void UpdateSeverity(AppMenuIconController::IconType type, |
206 AppMenuIconPainter::Severity severity, | 207 AppMenuIconPainter::Severity severity, |
207 bool animate) override { | 208 bool animate) override { |
208 [controller_ updateAppMenuButtonSeverity:severity animate:animate]; | 209 [controller_ updateAppMenuButtonSeverity:severity |
| 210 iconType:type |
| 211 animate:animate]; |
209 } | 212 } |
210 | 213 |
211 void OnPreferenceChanged(const std::string& pref_name) { | 214 void OnPreferenceChanged(const std::string& pref_name) { |
212 [controller_ prefChanged:pref_name]; | 215 [controller_ prefChanged:pref_name]; |
213 } | 216 } |
214 | 217 |
215 private: | 218 private: |
216 ToolbarController* controller_; // weak, owns us | 219 ToolbarController* controller_; // weak, owns us |
217 | 220 |
218 AppMenuIconController app_menu_icon_controller_; | 221 AppMenuIconController app_menu_icon_controller_; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 if (appMenuController_.get()) | 813 if (appMenuController_.get()) |
811 return; | 814 return; |
812 | 815 |
813 appMenuController_.reset( | 816 appMenuController_.reset( |
814 [[AppMenuController alloc] initWithBrowser:browser_]); | 817 [[AppMenuController alloc] initWithBrowser:browser_]); |
815 [appMenuController_ setUseWithPopUpButtonCell:YES]; | 818 [appMenuController_ setUseWithPopUpButtonCell:YES]; |
816 [appMenuButton_ setAttachedMenu:[appMenuController_ menu]]; | 819 [appMenuButton_ setAttachedMenu:[appMenuController_ menu]]; |
817 } | 820 } |
818 | 821 |
819 - (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity | 822 - (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity |
| 823 iconType:(AppMenuIconController::IconType)iconType |
820 animate:(BOOL)animate { | 824 animate:(BOOL)animate { |
821 if (!ui::MaterialDesignController::IsModeMaterial()) { | 825 if (!ui::MaterialDesignController::IsModeMaterial()) { |
822 AppToolbarButtonCell* cell = | 826 AppToolbarButtonCell* cell = |
823 base::mac::ObjCCastStrict<AppToolbarButtonCell>([appMenuButton_ cell]); | 827 base::mac::ObjCCastStrict<AppToolbarButtonCell>([appMenuButton_ cell]); |
824 [cell setSeverity:severity shouldAnimate:animate]; | 828 [cell setSeverity:severity shouldAnimate:animate]; |
825 return; | 829 return; |
826 } | 830 } |
827 AppToolbarButton* appMenuButton = | 831 AppToolbarButton* appMenuButton = |
828 base::mac::ObjCCastStrict<AppToolbarButton>(appMenuButton_); | 832 base::mac::ObjCCastStrict<AppToolbarButton>(appMenuButton_); |
829 [appMenuButton setSeverity:severity shouldAnimate:animate]; | 833 [appMenuButton setSeverity:severity iconType:iconType shouldAnimate:animate]; |
830 } | 834 } |
831 | 835 |
832 - (void)prefChanged:(const std::string&)prefName { | 836 - (void)prefChanged:(const std::string&)prefName { |
833 if (prefName == prefs::kShowHomeButton) { | 837 if (prefName == prefs::kShowHomeButton) { |
834 [self showOptionalHomeButton]; | 838 [self showOptionalHomeButton]; |
835 } | 839 } |
836 } | 840 } |
837 | 841 |
838 - (void)createBrowserActionButtons { | 842 - (void)createBrowserActionButtons { |
839 if (!browserActionsController_.get()) { | 843 if (!browserActionsController_.get()) { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1179 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
1176 // Do nothing. | 1180 // Do nothing. |
1177 } | 1181 } |
1178 | 1182 |
1179 // (URLDropTargetController protocol) | 1183 // (URLDropTargetController protocol) |
1180 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1184 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
1181 return drag_util::IsUnsupportedDropData(profile_, info); | 1185 return drag_util::IsUnsupportedDropData(profile_, info); |
1182 } | 1186 } |
1183 | 1187 |
1184 @end | 1188 @end |
OLD | NEW |