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

Side by Side Diff: chrome/browser/ui/cocoa/app_menu/app_menu_controller.mm

Issue 1917973002: mac: Remove IsOSLion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted Created 4 years, 8 months 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) 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/app_menu/app_menu_controller.h" 5 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 using base::UserMetricsAction; 63 using base::UserMetricsAction;
64 64
65 @interface AppMenuController (Private) 65 @interface AppMenuController (Private)
66 - (void)createModel; 66 - (void)createModel;
67 - (void)adjustPositioning; 67 - (void)adjustPositioning;
68 - (void)performCommandDispatch:(NSNumber*)tag; 68 - (void)performCommandDispatch:(NSNumber*)tag;
69 - (NSButton*)zoomDisplay; 69 - (NSButton*)zoomDisplay;
70 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item; 70 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item;
71 - (void)removeAllItems:(NSMenu*)menu;
72 - (NSMenu*)recentTabsSubmenu; 71 - (NSMenu*)recentTabsSubmenu;
73 - (RecentTabsSubMenuModel*)recentTabsMenuModel; 72 - (RecentTabsSubMenuModel*)recentTabsMenuModel;
74 - (int)maxWidthForMenuModel:(ui::MenuModel*)model 73 - (int)maxWidthForMenuModel:(ui::MenuModel*)model
75 modelIndex:(int)modelIndex; 74 modelIndex:(int)modelIndex;
76 @end 75 @end
77 76
78 namespace AppMenuControllerInternal { 77 namespace AppMenuControllerInternal {
79 78
80 // A C++ delegate that handles the accelerators in the app menu. 79 // A C++ delegate that handles the accelerators in the app menu.
81 class AcceleratorDelegate : public ui::AcceleratorProvider { 80 class AcceleratorDelegate : public ui::AcceleratorProvider {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 UMA_HISTOGRAM_TIMES("Toolbar.AppMenuTimeToAction", 393 UMA_HISTOGRAM_TIMES("Toolbar.AppMenuTimeToAction",
395 base::TimeTicks::Now() - menuOpenTime_); 394 base::TimeTicks::Now() - menuOpenTime_);
396 menuOpenTime_ = base::TimeTicks(); 395 menuOpenTime_ = base::TimeTicks();
397 } 396 }
398 397
399 - (void)menuNeedsUpdate:(NSMenu*)menu { 398 - (void)menuNeedsUpdate:(NSMenu*)menu {
400 // We should never have a BrowserActionsController before creating the menu. 399 // We should never have a BrowserActionsController before creating the menu.
401 DCHECK(!browserActionsController_.get()); 400 DCHECK(!browserActionsController_.get());
402 401
403 // First empty out the menu and create a new model. 402 // First empty out the menu and create a new model.
404 [self removeAllItems:menu]; 403 [menu removeAllItems];
405 [self createModel]; 404 [self createModel];
406 [menu setMinimumWidth:0]; 405 [menu setMinimumWidth:0];
407 406
408 // Create a new menu, which cannot be swapped because the tracking is about to 407 // Create a new menu, which cannot be swapped because the tracking is about to
409 // start, so simply copy the items. 408 // start, so simply copy the items.
410 NSMenu* newMenu = [self menuFromModel:model_]; 409 NSMenu* newMenu = [self menuFromModel:model_];
411 NSArray* itemArray = [newMenu itemArray]; 410 NSArray* itemArray = [newMenu itemArray];
412 [self removeAllItems:newMenu]; 411 [newMenu removeAllItems];
413 for (NSMenuItem* item in itemArray) { 412 for (NSMenuItem* item in itemArray) {
414 [menu addItem:item]; 413 [menu addItem:item];
415 } 414 }
416 415
417 [self updateRecentTabsSubmenu]; 416 [self updateRecentTabsSubmenu];
418 [self updateBookmarkSubMenu]; 417 [self updateBookmarkSubMenu];
419 [self updateBrowserActionsSubmenu]; 418 [self updateBrowserActionsSubmenu];
420 } 419 }
421 420
422 // Used to dispatch commands from the App menu. The custom items within the 421 // Used to dispatch commands from the App menu. The custom items within the
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return [buttonViewController_ zoomDisplay]; 537 return [buttonViewController_ zoomDisplay];
539 } 538 }
540 539
541 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item { 540 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item {
542 if (browserActionsController_.get()) { 541 if (browserActionsController_.get()) {
543 [browserActionsController_ setFocusedInOverflow: 542 [browserActionsController_ setFocusedInOverflow:
544 (item == browserActionsMenuItem_)]; 543 (item == browserActionsMenuItem_)];
545 } 544 }
546 } 545 }
547 546
548 // -[NSMenu removeAllItems] is only available on 10.6+.
549 - (void)removeAllItems:(NSMenu*)menu {
550 while ([menu numberOfItems]) {
551 [menu removeItemAtIndex:0];
552 }
553 }
554
555 - (NSMenu*)recentTabsSubmenu { 547 - (NSMenu*)recentTabsSubmenu {
556 NSString* title = l10n_util::GetNSStringWithFixup(IDS_RECENT_TABS_MENU); 548 NSString* title = l10n_util::GetNSStringWithFixup(IDS_RECENT_TABS_MENU);
557 return [[[self menu] itemWithTitle:title] submenu]; 549 return [[[self menu] itemWithTitle:title] submenu];
558 } 550 }
559 551
560 // The recent tabs menu model is recognized by the existence of either the 552 // The recent tabs menu model is recognized by the existence of either the
561 // kRecentlyClosedHeaderCommandId or the kDisabledRecentlyClosedHeaderCommandId. 553 // kRecentlyClosedHeaderCommandId or the kDisabledRecentlyClosedHeaderCommandId.
562 - (RecentTabsSubMenuModel*)recentTabsMenuModel { 554 - (RecentTabsSubMenuModel*)recentTabsMenuModel {
563 int index = 0; 555 int index = 0;
564 // Start searching at the app menu model level, |model| will be updated only 556 // Start searching at the app menu model level, |model| will be updated only
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 // (and thus, after all our ability to adjust it normally). Throw in the 633 // (and thus, after all our ability to adjust it normally). Throw in the
642 // towel, and simply don't let the frame move from where it's supposed to be. 634 // towel, and simply don't let the frame move from where it's supposed to be.
643 // TODO(devlin): Yet another Cocoa hack. It'd be good to find a workaround, 635 // TODO(devlin): Yet another Cocoa hack. It'd be good to find a workaround,
644 // but unlikely unless we replace the Cocoa menu implementation. 636 // but unlikely unless we replace the Cocoa menu implementation.
645 NSView* containerSuperview = [overflowActionsContainerView_ superview]; 637 NSView* containerSuperview = [overflowActionsContainerView_ superview];
646 if (NSMinX([containerSuperview frame]) != 0) 638 if (NSMinX([containerSuperview frame]) != 0)
647 [containerSuperview setFrameOrigin:NSZeroPoint]; 639 [containerSuperview setFrameOrigin:NSZeroPoint];
648 } 640 }
649 641
650 @end // @implementation AppMenuButtonViewController 642 @end // @implementation AppMenuButtonViewController
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698