OLD | NEW |
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 #include "chrome/browser/ui/views/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
49 #include "ui/base/theme_provider.h" | 49 #include "ui/base/theme_provider.h" |
50 #include "ui/gfx/canvas.h" | 50 #include "ui/gfx/canvas.h" |
51 #include "ui/views/controls/button/text_button.h" | 51 #include "ui/views/controls/button/text_button.h" |
52 #include "ui/views/controls/menu/menu_item_view.h" | 52 #include "ui/views/controls/menu/menu_item_view.h" |
53 #include "ui/views/controls/menu/menu_model_adapter.h" | 53 #include "ui/views/controls/menu/menu_model_adapter.h" |
54 #include "ui/views/controls/menu/menu_runner.h" | 54 #include "ui/views/controls/menu/menu_runner.h" |
55 #include "ui/views/controls/resize_area.h" | 55 #include "ui/views/controls/resize_area.h" |
56 #include "ui/views/metrics.h" | 56 #include "ui/views/metrics.h" |
57 | 57 |
| 58 using extensions::Extension; |
| 59 |
58 namespace { | 60 namespace { |
59 | 61 |
60 // Horizontal spacing between most items in the container, as well as after the | 62 // Horizontal spacing between most items in the container, as well as after the |
61 // last item or chevron (if visible). | 63 // last item or chevron (if visible). |
62 const int kItemSpacing = ToolbarView::kStandardSpacing; | 64 const int kItemSpacing = ToolbarView::kStandardSpacing; |
63 | 65 |
64 // Horizontal spacing before the chevron (if visible). | 66 // Horizontal spacing before the chevron (if visible). |
65 const int kChevronSpacing = kItemSpacing - 2; | 67 const int kChevronSpacing = kItemSpacing - 2; |
66 | 68 |
67 void RegisterUserPrefs(PrefService* prefs) { | 69 void RegisterUserPrefs(PrefService* prefs) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 void BrowserActionsContainer::RefreshBrowserActionViews() { | 478 void BrowserActionsContainer::RefreshBrowserActionViews() { |
477 for (size_t i = 0; i < browser_action_views_.size(); ++i) | 479 for (size_t i = 0; i < browser_action_views_.size(); ++i) |
478 browser_action_views_[i]->button()->UpdateState(); | 480 browser_action_views_[i]->button()->UpdateState(); |
479 } | 481 } |
480 | 482 |
481 void BrowserActionsContainer::CreateBrowserActionViews() { | 483 void BrowserActionsContainer::CreateBrowserActionViews() { |
482 DCHECK(browser_action_views_.empty()); | 484 DCHECK(browser_action_views_.empty()); |
483 if (!model_) | 485 if (!model_) |
484 return; | 486 return; |
485 | 487 |
486 for (ExtensionList::iterator iter = model_->begin(); iter != model_->end(); | 488 for (extensions::ExtensionList::iterator iter = model_->begin(); |
487 ++iter) { | 489 iter != model_->end(); ++iter) { |
488 if (!ShouldDisplayBrowserAction(*iter)) | 490 if (!ShouldDisplayBrowserAction(*iter)) |
489 continue; | 491 continue; |
490 | 492 |
491 BrowserActionView* view = new BrowserActionView(*iter, this); | 493 BrowserActionView* view = new BrowserActionView(*iter, this); |
492 browser_action_views_.push_back(view); | 494 browser_action_views_.push_back(view); |
493 AddChildView(view); | 495 AddChildView(view); |
494 } | 496 } |
495 } | 497 } |
496 | 498 |
497 void BrowserActionsContainer::DeleteBrowserActionViews() { | 499 void BrowserActionsContainer::DeleteBrowserActionViews() { |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 } | 1133 } |
1132 } | 1134 } |
1133 | 1135 |
1134 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1136 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
1135 const Extension* extension) { | 1137 const Extension* extension) { |
1136 // Only display incognito-enabled extensions while in incognito mode. | 1138 // Only display incognito-enabled extensions while in incognito mode. |
1137 return | 1139 return |
1138 (!profile_->IsOffTheRecord() || | 1140 (!profile_->IsOffTheRecord() || |
1139 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 1141 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); |
1140 } | 1142 } |
OLD | NEW |