OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_keybinding_registry_tracker.h" | |
10 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
11 #include "chrome/browser/extensions/extension_view_host.h" | 12 #include "chrome/browser/extensions/extension_view_host.h" |
12 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
18 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
19 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 20 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
946 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); | 947 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); |
947 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); | 948 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); |
948 } | 949 } |
949 | 950 |
950 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { | 951 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { |
951 SetVisible(!browser_action_views_.empty()); | 952 SetVisible(!browser_action_views_.empty()); |
952 if (owner_view_) { | 953 if (owner_view_) { |
953 owner_view_->Layout(); | 954 owner_view_->Layout(); |
954 owner_view_->SchedulePaint(); | 955 owner_view_->SchedulePaint(); |
955 } | 956 } |
957 | |
958 if (GetWidget()->IsActive()) | |
Devlin
2014/09/11 18:41:01
This is probably not the best point for this. Thi
David Tseng
2014/09/11 19:34:20
Done. (sky@ feel free to suggest alternatives).
| |
959 extensions::ExtensionKeybindingRegistryTracker::Get(profile()) | |
960 ->Update(extension_keybinding_registry_.get()); | |
956 } | 961 } |
957 | 962 |
958 int BrowserActionsContainer::GetPreferredWidth() { | 963 int BrowserActionsContainer::GetPreferredWidth() { |
959 size_t visible_actions = GetIconCount(); | 964 size_t visible_actions = GetIconCount(); |
960 return IconCountToWidth( | 965 return IconCountToWidth( |
961 visible_actions, | 966 visible_actions, |
962 chevron_ && visible_actions < browser_action_views_.size()); | 967 chevron_ && visible_actions < browser_action_views_.size()); |
963 } | 968 } |
964 | 969 |
965 void BrowserActionsContainer::SetChevronVisibility() { | 970 void BrowserActionsContainer::SetChevronVisibility() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 size_t absolute_model_size = | 1079 size_t absolute_model_size = |
1075 model_size == -1 ? extensions.size() : model_size; | 1080 model_size == -1 ? extensions.size() : model_size; |
1076 | 1081 |
1077 // The main container will try to show |model_size| icons, but reduce if there | 1082 // The main container will try to show |model_size| icons, but reduce if there |
1078 // aren't enough displayable icons to do so. | 1083 // aren't enough displayable icons to do so. |
1079 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); | 1084 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); |
1080 // The overflow will display the extras, if any. | 1085 // The overflow will display the extras, if any. |
1081 return in_overflow_mode() ? | 1086 return in_overflow_mode() ? |
1082 displayable_icon_count - main_displayed : main_displayed; | 1087 displayable_icon_count - main_displayed : main_displayed; |
1083 } | 1088 } |
OLD | NEW |