OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/browser_actions_container.h" | 5 #include "chrome/browser/views/browser_actions_container.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (tab_id < 0) | 354 if (tab_id < 0) |
355 return; | 355 return; |
356 | 356 |
357 action->PaintBadge(canvas, gfx::Rect(width(), height()), tab_id); | 357 action->PaintBadge(canvas, gfx::Rect(width(), height()), tab_id); |
358 } | 358 } |
359 | 359 |
360 //////////////////////////////////////////////////////////////////////////////// | 360 //////////////////////////////////////////////////////////////////////////////// |
361 // BrowserActionsContainer | 361 // BrowserActionsContainer |
362 | 362 |
363 BrowserActionsContainer::BrowserActionsContainer( | 363 BrowserActionsContainer::BrowserActionsContainer( |
364 Browser* browser, View* owner_view, bool should_save_size) | 364 Browser* browser, View* owner_view) |
365 : profile_(browser->profile()), | 365 : profile_(browser->profile()), |
366 browser_(browser), | 366 browser_(browser), |
367 owner_view_(owner_view), | 367 owner_view_(owner_view), |
368 should_save_size_(should_save_size), | |
369 popup_(NULL), | 368 popup_(NULL), |
370 popup_button_(NULL), | 369 popup_button_(NULL), |
371 model_(NULL), | 370 model_(NULL), |
372 resize_gripper_(NULL), | 371 resize_gripper_(NULL), |
373 chevron_(NULL), | 372 chevron_(NULL), |
374 overflow_menu_(NULL), | 373 overflow_menu_(NULL), |
375 suppress_chevron_(false), | 374 suppress_chevron_(false), |
376 resize_amount_(0), | 375 resize_amount_(0), |
377 animation_target_size_(0), | 376 animation_target_size_(0), |
378 drop_indicator_position_(-1), | 377 drop_indicator_position_(-1), |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 void BrowserActionsContainer::AnimationEnded(const Animation* animation) { | 1133 void BrowserActionsContainer::AnimationEnded(const Animation* animation) { |
1135 container_size_.set_width(animation_target_size_); | 1134 container_size_.set_width(animation_target_size_); |
1136 animation_target_size_ = 0; | 1135 animation_target_size_ = 0; |
1137 resize_amount_ = 0; | 1136 resize_amount_ = 0; |
1138 OnBrowserActionVisibilityChanged(); | 1137 OnBrowserActionVisibilityChanged(); |
1139 suppress_chevron_ = false; | 1138 suppress_chevron_ = false; |
1140 | 1139 |
1141 // Don't save the icon count in incognito because there may be fewer icons | 1140 // Don't save the icon count in incognito because there may be fewer icons |
1142 // in that mode. The result is that the container in a normal window is always | 1141 // in that mode. The result is that the container in a normal window is always |
1143 // at least as wide as in an incognito window. | 1142 // at least as wide as in an incognito window. |
1144 if (!profile_->IsOffTheRecord() && should_save_size_) | 1143 if (!profile_->IsOffTheRecord()) |
1145 model_->SetVisibleIconCount(VisibleBrowserActions()); | 1144 model_->SetVisibleIconCount(VisibleBrowserActions()); |
1146 } | 1145 } |
1147 | 1146 |
1148 void BrowserActionsContainer::NotifyMenuDeleted( | 1147 void BrowserActionsContainer::NotifyMenuDeleted( |
1149 BrowserActionOverflowMenuController* controller) { | 1148 BrowserActionOverflowMenuController* controller) { |
1150 DCHECK(controller == overflow_menu_); | 1149 DCHECK(controller == overflow_menu_); |
1151 overflow_menu_ = NULL; | 1150 overflow_menu_ = NULL; |
1152 } | 1151 } |
1153 | 1152 |
1154 void BrowserActionsContainer::InspectPopup( | 1153 void BrowserActionsContainer::InspectPopup( |
1155 ExtensionAction* action) { | 1154 ExtensionAction* action) { |
1156 OnBrowserActionExecuted(GetBrowserActionView(action)->button(), | 1155 OnBrowserActionExecuted(GetBrowserActionView(action)->button(), |
1157 true); // |inspect_with_devtools|. | 1156 true); // |inspect_with_devtools|. |
1158 } | 1157 } |
1159 | 1158 |
1160 void BrowserActionsContainer::ExtensionPopupIsClosing(ExtensionPopup* popup) { | 1159 void BrowserActionsContainer::ExtensionPopupIsClosing(ExtensionPopup* popup) { |
1161 // ExtensionPopup is ref-counted, so we don't need to delete it. | 1160 // ExtensionPopup is ref-counted, so we don't need to delete it. |
1162 DCHECK_EQ(popup_, popup); | 1161 DCHECK_EQ(popup_, popup); |
1163 popup_ = NULL; | 1162 popup_ = NULL; |
1164 popup_button_->SetButtonNotPushed(); | 1163 popup_button_->SetButtonNotPushed(); |
1165 popup_button_ = NULL; | 1164 popup_button_ = NULL; |
1166 } | 1165 } |
1167 | 1166 |
1168 bool BrowserActionsContainer::ShouldDisplayBrowserAction(Extension* extension) { | 1167 bool BrowserActionsContainer::ShouldDisplayBrowserAction(Extension* extension) { |
1169 // Only display incognito-enabled extensions while in incognito mode. | 1168 // Only display incognito-enabled extensions while in incognito mode. |
1170 return (!profile_->IsOffTheRecord() || | 1169 return (!profile_->IsOffTheRecord() || |
1171 profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); | 1170 profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); |
1172 } | 1171 } |
OLD | NEW |