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

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

Issue 1419993010: chrome: Rename WrenchMenuController to AppMenuController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 1 month 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) 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"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/mac/sdk_forward_declarations.h" 12 #include "base/mac/sdk_forward_declarations.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/sys_string_conversions.h" 16 #include "base/strings/sys_string_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_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_classifier_factory.h" 19 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/command_observer.h" 21 #include "chrome/browser/command_observer.h"
22 #include "chrome/browser/command_updater.h" 22 #include "chrome/browser/command_updater.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search/search.h" 24 #include "chrome/browser/search/search.h"
25 #include "chrome/browser/sync/sync_global_error_factory.h" 25 #include "chrome/browser/sync/sync_global_error_factory.h"
26 #include "chrome/browser/themes/theme_service.h" 26 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_commands.h" 28 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
30 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h"
30 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 31 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
31 #include "chrome/browser/ui/cocoa/drag_util.h" 32 #include "chrome/browser/ui/cocoa/drag_util.h"
32 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 33 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
33 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" 34 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
34 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 35 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
35 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" 36 #import "chrome/browser/ui/cocoa/gradient_button_cell.h"
36 #import "chrome/browser/ui/cocoa/image_button_cell.h" 37 #import "chrome/browser/ui/cocoa/image_button_cell.h"
37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
38 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 39 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
39 #import "chrome/browser/ui/cocoa/menu_button.h" 40 #import "chrome/browser/ui/cocoa/menu_button.h"
40 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h" 41 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h"
41 #import "chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.h" 42 #import "chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.h"
42 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" 43 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h"
43 #import "chrome/browser/ui/cocoa/toolbar/toolbar_view_cocoa.h" 44 #import "chrome/browser/ui/cocoa/toolbar/toolbar_view_cocoa.h"
44 #import "chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h" 45 #import "chrome/browser/ui/cocoa/toolbar/wrench_toolbar_button_cell.h"
45 #import "chrome/browser/ui/cocoa/view_id_util.h" 46 #import "chrome/browser/ui/cocoa/view_id_util.h"
46 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" 47 #include "chrome/browser/ui/tabs/tab_strip_model.h"
48 #include "chrome/browser/ui/toolbar/app_menu_badge_controller.h" 48 #include "chrome/browser/ui/toolbar/app_menu_badge_controller.h"
49 #include "chrome/browser/ui/toolbar/app_menu_model.h" 49 #include "chrome/browser/ui/toolbar/app_menu_model.h"
50 #include "chrome/common/pref_names.h" 50 #include "chrome/common/pref_names.h"
51 #include "chrome/grit/chromium_strings.h" 51 #include "chrome/grit/chromium_strings.h"
52 #include "chrome/grit/generated_resources.h" 52 #include "chrome/grit/generated_resources.h"
53 #include "components/metrics/proto/omnibox_event.pb.h" 53 #include "components/metrics/proto/omnibox_event.pb.h"
54 #include "components/omnibox/browser/autocomplete_classifier.h" 54 #include "components/omnibox/browser/autocomplete_classifier.h"
55 #include "components/omnibox/browser/autocomplete_match.h" 55 #include "components/omnibox/browser/autocomplete_match.h"
56 #include "components/omnibox/browser/omnibox_view.h" 56 #include "components/omnibox/browser/omnibox_view.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 - (void)browserWillBeDestroyed { 388 - (void)browserWillBeDestroyed {
389 // Clear resize delegate so it doesn't get called during stopAnimation, and 389 // Clear resize delegate so it doesn't get called during stopAnimation, and
390 // stop any in-flight animation. 390 // stop any in-flight animation.
391 [[self toolbarView] setResizeDelegate:nil]; 391 [[self toolbarView] setResizeDelegate:nil];
392 [[self toolbarView] stopAnimation]; 392 [[self toolbarView] stopAnimation];
393 393
394 // Pass this call onto other reference counted objects. 394 // Pass this call onto other reference counted objects.
395 [backMenuController_ browserWillBeDestroyed]; 395 [backMenuController_ browserWillBeDestroyed];
396 [forwardMenuController_ browserWillBeDestroyed]; 396 [forwardMenuController_ browserWillBeDestroyed];
397 [browserActionsController_ browserWillBeDestroyed]; 397 [browserActionsController_ browserWillBeDestroyed];
398 [wrenchMenuController_ browserWillBeDestroyed]; 398 [appMenuController_ browserWillBeDestroyed];
399 399
400 [self cleanUp]; 400 [self cleanUp];
401 } 401 }
402 402
403 - (void)cleanUp { 403 - (void)cleanUp {
404 // Unset ViewIDs of toolbar elements. 404 // Unset ViewIDs of toolbar elements.
405 // ViewIDs of |toolbarView|, |reloadButton_|, |locationBar_| and 405 // ViewIDs of |toolbarView|, |reloadButton_|, |locationBar_| and
406 // |browserActionsContainerView_| are handled by themselves. 406 // |browserActionsContainerView_| are handled by themselves.
407 view_id_util::UnsetID(backButton_); 407 view_id_util::UnsetID(backButton_);
408 view_id_util::UnsetID(forwardButton_); 408 view_id_util::UnsetID(forwardButton_);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 - (void)setStarredState:(BOOL)isStarred { 557 - (void)setStarredState:(BOOL)isStarred {
558 locationBarView_->SetStarred(isStarred); 558 locationBarView_->SetStarred(isStarred);
559 } 559 }
560 560
561 - (void)setTranslateIconLit:(BOOL)on { 561 - (void)setTranslateIconLit:(BOOL)on {
562 locationBarView_->SetTranslateIconLit(on); 562 locationBarView_->SetTranslateIconLit(on);
563 } 563 }
564 564
565 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble { 565 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble {
566 locationBarView_->ZoomChangedForActiveTab( 566 locationBarView_->ZoomChangedForActiveTab(
567 canShowBubble && ![wrenchMenuController_ isMenuOpen]); 567 canShowBubble && ![appMenuController_ isMenuOpen]);
568 } 568 }
569 569
570 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force { 570 - (void)setIsLoading:(BOOL)isLoading force:(BOOL)force {
571 [reloadButton_ setIsLoading:isLoading force:force]; 571 [reloadButton_ setIsLoading:isLoading force:force];
572 } 572 }
573 573
574 - (void)setHasToolbar:(BOOL)toolbar hasLocationBar:(BOOL)locBar { 574 - (void)setHasToolbar:(BOOL)toolbar hasLocationBar:(BOOL)locBar {
575 [self view]; // Force nib loading. 575 [self view]; // Force nib loading.
576 576
577 hasToolbar_ = toolbar; 577 hasToolbar_ = toolbar;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 moveX *= -1; // Reverse the direction of the move. 656 moveX *= -1; // Reverse the direction of the move.
657 657
658 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] 658 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame]
659 byAmount:moveX]]; 659 byAmount:moveX]];
660 [homeButton_ setHidden:hide]; 660 [homeButton_ setHidden:hide];
661 } 661 }
662 662
663 // Install the menu wrench buttons. Calling this repeatedly is inexpensive so it 663 // Install the menu wrench buttons. Calling this repeatedly is inexpensive so it
664 // can be done every time the buttons are shown. 664 // can be done every time the buttons are shown.
665 - (void)installWrenchMenu { 665 - (void)installWrenchMenu {
666 if (wrenchMenuController_.get()) 666 if (appMenuController_.get())
667 return; 667 return;
668 668
669 wrenchMenuController_.reset( 669 appMenuController_.reset(
670 [[WrenchMenuController alloc] initWithBrowser:browser_]); 670 [[AppMenuController alloc] initWithBrowser:browser_]);
671 [wrenchMenuController_ setUseWithPopUpButtonCell:YES]; 671 [appMenuController_ setUseWithPopUpButtonCell:YES];
672 [wrenchButton_ setAttachedMenu:[wrenchMenuController_ menu]]; 672 [wrenchButton_ setAttachedMenu:[appMenuController_ menu]];
673 } 673 }
674 674
675 - (void)updateWrenchButtonSeverity:(AppMenuIconPainter::Severity)severity 675 - (void)updateWrenchButtonSeverity:(AppMenuIconPainter::Severity)severity
676 animate:(BOOL)animate { 676 animate:(BOOL)animate {
677 WrenchToolbarButtonCell* cell = 677 WrenchToolbarButtonCell* cell =
678 base::mac::ObjCCastStrict<WrenchToolbarButtonCell>([wrenchButton_ cell]); 678 base::mac::ObjCCastStrict<WrenchToolbarButtonCell>([wrenchButton_ cell]);
679 [cell setSeverity:severity shouldAnimate:animate]; 679 [cell setSeverity:severity shouldAnimate:animate];
680 } 680 }
681 681
682 - (void)prefChanged:(const std::string&)prefName { 682 - (void)prefChanged:(const std::string&)prefName {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 } 875 }
876 876
877 - (NSPoint)bookmarkBubblePoint { 877 - (NSPoint)bookmarkBubblePoint {
878 if (locationBarView_->IsStarEnabled()) 878 if (locationBarView_->IsStarEnabled())
879 return locationBarView_->GetBookmarkBubblePoint(); 879 return locationBarView_->GetBookmarkBubblePoint();
880 880
881 // Grab bottom middle of hotdogs. 881 // Grab bottom middle of hotdogs.
882 NSRect frame = wrenchButton_.frame; 882 NSRect frame = wrenchButton_.frame;
883 NSPoint point = NSMakePoint(NSMidX(frame), NSMinY(frame)); 883 NSPoint point = NSMakePoint(NSMidX(frame), NSMinY(frame));
884 // Inset to account for the whitespace around the hotdogs. 884 // Inset to account for the whitespace around the hotdogs.
885 point.y += wrench_menu_controller::kWrenchBubblePointOffsetY; 885 point.y += app_menu_controller::kAppMenuBubblePointOffsetY;
886 return [self.view convertPoint:point toView:nil]; 886 return [self.view convertPoint:point toView:nil];
887 } 887 }
888 888
889 - (NSPoint)managePasswordsBubblePoint { 889 - (NSPoint)managePasswordsBubblePoint {
890 return locationBarView_->GetManagePasswordsBubblePoint(); 890 return locationBarView_->GetManagePasswordsBubblePoint();
891 } 891 }
892 892
893 - (NSPoint)translateBubblePoint { 893 - (NSPoint)translateBubblePoint {
894 return locationBarView_->GetTranslateBubblePoint(); 894 return locationBarView_->GetTranslateBubblePoint();
895 } 895 }
(...skipping 14 matching lines...) Expand all
910 } 910 }
911 911
912 - (BrowserActionsController*)browserActionsController { 912 - (BrowserActionsController*)browserActionsController {
913 return browserActionsController_.get(); 913 return browserActionsController_.get();
914 } 914 }
915 915
916 - (NSView*)wrenchButton { 916 - (NSView*)wrenchButton {
917 return wrenchButton_; 917 return wrenchButton_;
918 } 918 }
919 919
920 - (WrenchMenuController*)wrenchMenuController { 920 - (AppMenuController*)appMenuController {
921 return wrenchMenuController_.get(); 921 return appMenuController_.get();
922 } 922 }
923 923
924 // (URLDropTargetController protocol) 924 // (URLDropTargetController protocol)
925 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point { 925 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point {
926 // TODO(viettrungluu): This code is more or less copied from the code in 926 // TODO(viettrungluu): This code is more or less copied from the code in
927 // |TabStripController|. I'll refactor this soon to make it common and expand 927 // |TabStripController|. I'll refactor this soon to make it common and expand
928 // its capabilities (e.g., allow text DnD). 928 // its capabilities (e.g., allow text DnD).
929 if ([urls count] < 1) { 929 if ([urls count] < 1) {
930 NOTREACHED(); 930 NOTREACHED();
931 return; 931 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 - (void)hideDropURLsIndicatorInView:(NSView*)view { 975 - (void)hideDropURLsIndicatorInView:(NSView*)view {
976 // Do nothing. 976 // Do nothing.
977 } 977 }
978 978
979 // (URLDropTargetController protocol) 979 // (URLDropTargetController protocol)
980 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { 980 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info {
981 return drag_util::IsUnsupportedDropData(profile_, info); 981 return drag_util::IsUnsupportedDropData(profile_, info);
982 } 982 }
983 983
984 @end 984 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698