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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 700453003: Revert of Make extensions that desire to act pop out if in overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/extensions/browser_actions_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 ExtensionPopupController* popup = [ExtensionPopupController popup]; 238 ExtensionPopupController* popup = [ExtensionPopupController popup];
239 if (popup || !browser_->window()->IsActive()) 239 if (popup || !browser_->window()->IsActive())
240 return false; 240 return false;
241 241
242 BrowserActionButton* button = [owner_ buttonForId:extension->id()]; 242 BrowserActionButton* button = [owner_ buttonForId:extension->id()];
243 return button && [button viewController]->ExecuteAction(grant_active_tab); 243 return button && [button viewController]->ExecuteAction(grant_active_tab);
244 } 244 }
245 245
246 void ToolbarVisibleCountChanged() override {} 246 void ToolbarVisibleCountChanged() override {}
247 247
248 void OnToolbarReorderNecessary(content::WebContents* web_contents) override {
249 // TODO(devlin): Implement on mac.
250 }
251
252 void ToolbarHighlightModeChanged(bool is_highlighting) override {} 248 void ToolbarHighlightModeChanged(bool is_highlighting) override {}
253 249
254 Browser* GetBrowser() override { return browser_; } 250 Browser* GetBrowser() override { return browser_; }
255 251
256 private: 252 private:
257 // The object we need to inform when we get a notification. Weak. Owns us. 253 // The object we need to inform when we get a notification. Weak. Owns us.
258 BrowserActionsController* owner_; 254 BrowserActionsController* owner_;
259 255
260 // The browser we listen for events from. Weak. 256 // The browser we listen for events from. Weak.
261 Browser* browser_; 257 Browser* browser_;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 348
353 - (NSUInteger)buttonCount { 349 - (NSUInteger)buttonCount {
354 return [buttons_ count]; 350 return [buttons_ count];
355 } 351 }
356 352
357 - (NSUInteger)visibleButtonCount { 353 - (NSUInteger)visibleButtonCount {
358 return [self buttonCount] - [hiddenButtons_ count]; 354 return [self buttonCount] - [hiddenButtons_ count];
359 } 355 }
360 356
361 - (void)resizeContainerAndAnimate:(BOOL)animate { 357 - (void)resizeContainerAndAnimate:(BOOL)animate {
362 int iconCount = toolbarModel_->visible_icon_count(); 358 int iconCount = toolbarModel_->GetVisibleIconCount();
359 if (iconCount < 0) // If no buttons are hidden.
360 iconCount = [self buttonCount];
363 361
364 [containerView_ resizeToWidth:[self containerWidthWithButtonCount:iconCount] 362 [containerView_ resizeToWidth:[self containerWidthWithButtonCount:iconCount]
365 animate:animate]; 363 animate:animate];
366 NSRect frame = animate ? [containerView_ animationEndFrame] : 364 NSRect frame = animate ? [containerView_ animationEndFrame] :
367 [containerView_ frame]; 365 [containerView_ frame];
368 366
369 [self showChevronIfNecessaryInFrame:frame animate:animate]; 367 [self showChevronIfNecessaryInFrame:frame animate:animate];
370 368
371 if (!animate) { 369 if (!animate) {
372 [[NSNotificationCenter defaultCenter] 370 [[NSNotificationCenter defaultCenter]
373 postNotificationName:kBrowserActionVisibilityChangedNotification 371 postNotificationName:kBrowserActionVisibilityChangedNotification
374 object:self]; 372 object:self];
375 } 373 }
376 } 374 }
377 375
378 - (CGFloat)savedWidth { 376 - (CGFloat)savedWidth {
379 if (!toolbarModel_) 377 if (!toolbarModel_)
380 return 0; 378 return 0;
381 379
382 int savedButtonCount = toolbarModel_->visible_icon_count(); 380 int savedButtonCount = toolbarModel_->GetVisibleIconCount();
383 if (static_cast<NSUInteger>(savedButtonCount) > [self buttonCount]) 381 if (savedButtonCount < 0 || // all icons are visible
382 static_cast<NSUInteger>(savedButtonCount) > [self buttonCount])
384 savedButtonCount = [self buttonCount]; 383 savedButtonCount = [self buttonCount];
385 return [self containerWidthWithButtonCount:savedButtonCount]; 384 return [self containerWidthWithButtonCount:savedButtonCount];
386 } 385 }
387 386
388 - (NSPoint)popupPointForId:(const std::string&)id { 387 - (NSPoint)popupPointForId:(const std::string&)id {
389 NSButton* button = [self buttonForId:id]; 388 NSButton* button = [self buttonForId:id];
390 if (!button) 389 if (!button)
391 return NSZeroPoint; 390 return NSZeroPoint;
392 391
393 if ([hiddenButtons_ containsObject:button]) 392 if ([hiddenButtons_ containsObject:button])
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 const extensions::ExtensionList& toolbar_items = 833 const extensions::ExtensionList& toolbar_items =
835 toolbarModel_->toolbar_items(); 834 toolbarModel_->toolbar_items();
836 if (index < toolbar_items.size()) { 835 if (index < toolbar_items.size()) {
837 const Extension* extension = toolbar_items[index].get(); 836 const Extension* extension = toolbar_items[index].get();
838 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; 837 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())];
839 } 838 }
840 return nil; 839 return nil;
841 } 840 }
842 841
843 @end 842 @end
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model_unittest.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698