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

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

Issue 1895213002: [Extensions UI Mac] Delete the overflow container when the menu closes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 381
382 - (void)menuDidClose:(NSMenu*)menu { 382 - (void)menuDidClose:(NSMenu*)menu {
383 [super menuDidClose:menu]; 383 [super menuDidClose:menu];
384 // We don't need to observe changes to zoom or toolbar size when the menu is 384 // We don't need to observe changes to zoom or toolbar size when the menu is
385 // closed, since we instantiate it with the proper value and recreate the menu 385 // closed, since we instantiate it with the proper value and recreate the menu
386 // on each show. (We do this in -menuNeedsUpdate:, which is called when the 386 // on each show. (We do this in -menuNeedsUpdate:, which is called when the
387 // menu is about to be displayed at the start of a tracking session.) 387 // menu is about to be displayed at the start of a tracking session.)
388 zoom_level_observer_.reset(); 388 zoom_level_observer_.reset();
389 toolbar_actions_bar_observer_.reset(); 389 toolbar_actions_bar_observer_.reset();
390 // Make sure to reset() the BrowserActionsController since the view will also
391 // be destroyed. If a new one's needed, it'll be created when we create the
392 // model in -menuNeedsUpdate:.
393 browserActionsController_.reset();
390 UMA_HISTOGRAM_TIMES("Toolbar.AppMenuTimeToAction", 394 UMA_HISTOGRAM_TIMES("Toolbar.AppMenuTimeToAction",
391 base::TimeTicks::Now() - menuOpenTime_); 395 base::TimeTicks::Now() - menuOpenTime_);
392 menuOpenTime_ = base::TimeTicks(); 396 menuOpenTime_ = base::TimeTicks();
393 } 397 }
394 398
395 - (void)menuNeedsUpdate:(NSMenu*)menu { 399 - (void)menuNeedsUpdate:(NSMenu*)menu {
400 // We should never have a BrowserActionsController before creating the menu.
401 DCHECK(!browserActionsController_.get());
402
396 // First empty out the menu and create a new model. 403 // First empty out the menu and create a new model.
397 [self removeAllItems:menu]; 404 [self removeAllItems:menu];
398 // Delete the BrowserActionsController; if a new one's needed, it'll be
399 // created as we add items to the menu.
400 browserActionsController_.reset();
401 [self createModel]; 405 [self createModel];
402 [menu setMinimumWidth:0]; 406 [menu setMinimumWidth:0];
403 407
404 // Create a new menu, which cannot be swapped because the tracking is about to 408 // Create a new menu, which cannot be swapped because the tracking is about to
405 // start, so simply copy the items. 409 // start, so simply copy the items.
406 NSMenu* newMenu = [self menuFromModel:model_]; 410 NSMenu* newMenu = [self menuFromModel:model_];
407 NSArray* itemArray = [newMenu itemArray]; 411 NSArray* itemArray = [newMenu itemArray];
408 [self removeAllItems:newMenu]; 412 [self removeAllItems:newMenu];
409 for (NSMenuItem* item in itemArray) { 413 for (NSMenuItem* item in itemArray) {
410 [menu addItem:item]; 414 [menu addItem:item];
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // (and thus, after all our ability to adjust it normally). Throw in the 641 // (and thus, after all our ability to adjust it normally). Throw in the
638 // towel, and simply don't let the frame move from where it's supposed to be. 642 // towel, and simply don't let the frame move from where it's supposed to be.
639 // TODO(devlin): Yet another Cocoa hack. It'd be good to find a workaround, 643 // TODO(devlin): Yet another Cocoa hack. It'd be good to find a workaround,
640 // but unlikely unless we replace the Cocoa menu implementation. 644 // but unlikely unless we replace the Cocoa menu implementation.
641 NSView* containerSuperview = [overflowActionsContainerView_ superview]; 645 NSView* containerSuperview = [overflowActionsContainerView_ superview];
642 if (NSMinX([containerSuperview frame]) != 0) 646 if (NSMinX([containerSuperview frame]) != 0)
643 [containerSuperview setFrameOrigin:NSZeroPoint]; 647 [containerSuperview setFrameOrigin:NSZeroPoint];
644 } 648 }
645 649
646 @end // @implementation AppMenuButtonViewController 650 @end // @implementation AppMenuButtonViewController
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698