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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 673063002: Fix "#if defined(DEBUG)" statements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar/wrench_menu.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/tab_helper.h" 10 #include "chrome/browser/extensions/tab_helper.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" 15 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
16 #include "chrome/browser/ui/view_ids.h" 16 #include "chrome/browser/ui/view_ids.h"
17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
18 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" 18 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h"
19 #include "chrome/browser/ui/views/extensions/extension_popup.h" 19 #include "chrome/browser/ui/views/extensions/extension_popup.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h" 21 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h"
22 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 22 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
23 #include "chrome/common/extensions/command.h" 23 #include "chrome/common/extensions/command.h"
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "components/crx_file/id_util.h"
25 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
26 #include "extensions/browser/runtime_data.h" 27 #include "extensions/browser/runtime_data.h"
27 #include "extensions/common/feature_switch.h" 28 #include "extensions/common/feature_switch.h"
28 #include "grit/theme_resources.h" 29 #include "grit/theme_resources.h"
29 #include "third_party/skia/include/core/SkColor.h" 30 #include "third_party/skia/include/core/SkColor.h"
30 #include "ui/accessibility/ax_view_state.h" 31 #include "ui/accessibility/ax_view_state.h"
31 #include "ui/base/dragdrop/drag_utils.h" 32 #include "ui/base/dragdrop/drag_utils.h"
32 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/nine_image_painter_factory.h" 34 #include "ui/base/nine_image_painter_factory.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 if (!initialized) { 749 if (!initialized) {
749 initialized = true; 750 initialized = true;
750 icon_height = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 751 icon_height = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
751 IDR_BROWSER_ACTION)->height(); 752 IDR_BROWSER_ACTION)->height();
752 } 753 }
753 return icon_height; 754 return icon_height;
754 } 755 }
755 756
756 void BrowserActionsContainer::ToolbarExtensionAdded(const Extension* extension, 757 void BrowserActionsContainer::ToolbarExtensionAdded(const Extension* extension,
757 int index) { 758 int index) {
758 #if defined(DEBUG) 759 DCHECK(!GetViewForExtension(extension)) <<
759 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 760 "Asked to add a browser action view for an extension that already exists";
760 DCHECK(browser_action_views_[i]->extension() != extension) <<
761 "Asked to add a browser action view for an extension that already "
762 "exists.";
763 }
764 #endif
765 if (chevron_) 761 if (chevron_)
766 chevron_->CloseMenu(); 762 chevron_->CloseMenu();
767 763
768 // Add the new browser action to the vector and the view hierarchy. 764 // Add the new browser action to the vector and the view hierarchy.
769 BrowserActionView* view = new BrowserActionView( 765 BrowserActionView* view = new BrowserActionView(
770 make_scoped_ptr(new ExtensionActionViewController( 766 make_scoped_ptr(new ExtensionActionViewController(
771 extension, 767 extension,
772 browser_, 768 browser_,
773 extensions::ExtensionActionManager::Get(profile_)-> 769 extensions::ExtensionActionManager::Get(profile_)->
774 GetExtensionAction(*extension))), 770 GetExtensionAction(*extension))),
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 995
1000 size_t BrowserActionsContainer::GetIconCount() const { 996 size_t BrowserActionsContainer::GetIconCount() const {
1001 if (!model_) 997 if (!model_)
1002 return 0u; 998 return 0u;
1003 999
1004 // Find the absolute value for the model's visible count. 1000 // Find the absolute value for the model's visible count.
1005 int model_visible_size = model_->GetVisibleIconCount(); 1001 int model_visible_size = model_->GetVisibleIconCount();
1006 size_t absolute_model_visible_size = model_visible_size == -1 ? 1002 size_t absolute_model_visible_size = model_visible_size == -1 ?
1007 model_->toolbar_items().size() : model_visible_size; 1003 model_->toolbar_items().size() : model_visible_size;
1008 1004
1009 #if defined(DEBUG) 1005 #if !defined(NDEBUG)
1010 // Good time for some sanity checks: We should never try to display more 1006 // Good time for some sanity checks: We should never try to display more
1011 // icons than we have, and we should always have a view per item in the model. 1007 // icons than we have, and we should always have a view per item in the model.
1012 // (The only exception is if this is in initialization.) 1008 // (The only exception is if this is in initialization.)
1013 if (initialized_) { 1009 if (initialized_) {
1014 size_t num_extension_actions = 0u; 1010 size_t num_extension_actions = 0u;
1015 for (const BrowserActionView* view : browser_action_views_) { 1011 for (BrowserActionView* view : browser_action_views_) {
1016 num_extension_actions += 1012 // No component action should ever have a valid extension id, so we can
1017 view->view_controller()->GetType() == 1013 // use this to check the extension amount.
1018 ToolbarActionViewController::TYPE_EXTENSION_ACTION ? 1 : 0; 1014 // TODO(devlin): Fix this to just check model size when the model also
1015 // includes component actions.
1016 if (crx_file::id_util::IdIsValid(view->view_controller()->GetId()))
1017 ++num_extension_actions;
1019 } 1018 }
1020 DCHECK_LE(absolute_model_visible_size, browser_action_views_.size()); 1019 DCHECK_LE(absolute_model_visible_size, num_extension_actions);
1021 DCHECK_EQ(model_->toolbar_items().size(), browser_action_views_.size()); 1020 DCHECK_EQ(model_->toolbar_items().size(), num_extension_actions);
1022 } 1021 }
1023 #endif 1022 #endif
1024 1023
1025 // The overflow displays any icons not shown by the main bar. 1024 // The overflow displays any icons not shown by the main bar.
1026 return in_overflow_mode() ? 1025 return in_overflow_mode() ?
1027 model_->toolbar_items().size() - absolute_model_visible_size : 1026 model_->toolbar_items().size() - absolute_model_visible_size :
1028 absolute_model_visible_size; 1027 absolute_model_visible_size;
1029 } 1028 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698