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

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

Issue 2947593005: Use ContainsValue() instead of std::find() in chrome/browser/ui/ (Closed)
Patch Set: Created 3 years, 6 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) 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/stl_util.h"
13 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 15 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 19 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
19 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" 20 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
20 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 21 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
21 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h" 22 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h"
22 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_views_pre senter.h" 23 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_views_pre senter.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 new ui::NinePartImageIds(IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT))); 454 new ui::NinePartImageIds(IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT)));
454 } 455 }
455 [containerView_ setHighlight:std::move(highlight)]; 456 [containerView_ setHighlight:std::move(highlight)];
456 457
457 std::vector<ToolbarActionViewController*> toolbarActions = 458 std::vector<ToolbarActionViewController*> toolbarActions =
458 toolbarActionsBar_->GetActions(); 459 toolbarActionsBar_->GetActions();
459 // Check that every button has an action in the referenced actions. 460 // Check that every button has an action in the referenced actions.
460 // Tracking down crbug.com/653100. 461 // Tracking down crbug.com/653100.
461 // TODO(devlin): Remove or relax this one the bug is fixed? 462 // TODO(devlin): Remove or relax this one the bug is fixed?
462 for (BrowserActionButton* button in buttons_.get()) { 463 for (BrowserActionButton* button in buttons_.get()) {
463 CHECK(std::find(toolbarActions.begin(), toolbarActions.end(), 464 CHECK(base::ContainsValue(toolbarActions, [button viewController]));
464 [button viewController]) != toolbarActions.end());
465 } 465 }
466 // Reorder |buttons_| to reflect |toolbarActions|. (Ugly n^2 sort, but the 466 // Reorder |buttons_| to reflect |toolbarActions|. (Ugly n^2 sort, but the
467 // data set should be tiny.) 467 // data set should be tiny.)
468 for (size_t refIndex = 0; refIndex < toolbarActions.size(); ++refIndex) { 468 for (size_t refIndex = 0; refIndex < toolbarActions.size(); ++refIndex) {
469 NSUInteger buttonIndex = refIndex; 469 NSUInteger buttonIndex = refIndex;
470 ToolbarActionViewController* refAction = toolbarActions[refIndex]; 470 ToolbarActionViewController* refAction = toolbarActions[refIndex];
471 for (; buttonIndex < [buttons_ count]; ++buttonIndex) { 471 for (; buttonIndex < [buttons_ count]; ++buttonIndex) {
472 if ([[self buttonAtIndex:buttonIndex] viewController] == refAction) 472 if ([[self buttonAtIndex:buttonIndex] viewController] == refAction)
473 break; 473 break;
474 } 474 }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 848 }
849 849
850 #pragma mark - 850 #pragma mark -
851 #pragma mark Testing Methods 851 #pragma mark Testing Methods
852 852
853 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { 853 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index {
854 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; 854 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil;
855 } 855 }
856 856
857 @end 857 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698