| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 : profile_(profile), | 222 : profile_(profile), |
| 223 toolbar_(toolbar), | 223 toolbar_(toolbar), |
| 224 popup_(NULL), | 224 popup_(NULL), |
| 225 popup_button_(NULL), | 225 popup_button_(NULL), |
| 226 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { | 226 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { |
| 227 ExtensionsService* extension_service = profile->GetExtensionsService(); | 227 ExtensionsService* extension_service = profile->GetExtensionsService(); |
| 228 if (!extension_service) // The |extension_service| can be NULL in Incognito. | 228 if (!extension_service) // The |extension_service| can be NULL in Incognito. |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 231 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
| 232 Source<ExtensionsService>(extension_service)); | 232 Source<Profile>(profile_)); |
| 233 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 233 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 234 Source<ExtensionsService>(extension_service)); | 234 Source<Profile>(profile_)); |
| 235 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, | 235 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, |
| 236 Source<ExtensionsService>(extension_service)); | 236 Source<Profile>(profile_)); |
| 237 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 237 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 238 Source<Profile>(profile_)); | 238 Source<Profile>(profile_)); |
| 239 | 239 |
| 240 for (size_t i = 0; i < extension_service->extensions()->size(); ++i) | 240 for (size_t i = 0; i < extension_service->extensions()->size(); ++i) |
| 241 AddBrowserAction(extension_service->extensions()->at(i)); | 241 AddBrowserAction(extension_service->extensions()->at(i)); |
| 242 | 242 |
| 243 SetID(VIEW_ID_BROWSER_ACTION_TOOLBAR); | 243 SetID(VIEW_ID_BROWSER_ACTION_TOOLBAR); |
| 244 } | 244 } |
| 245 | 245 |
| 246 BrowserActionsContainer::~BrowserActionsContainer() { | 246 BrowserActionsContainer::~BrowserActionsContainer() { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 std::min(static_cast<int>(browser_action_views_.size()), | 459 std::min(static_cast<int>(browser_action_views_.size()), |
| 460 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; | 460 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; |
| 461 | 461 |
| 462 // Even if available_width is <= 0, we still return at least the |min_width|. | 462 // Even if available_width is <= 0, we still return at least the |min_width|. |
| 463 if (available_width <= 0) | 463 if (available_width <= 0) |
| 464 return min_width; | 464 return min_width; |
| 465 | 465 |
| 466 return std::max(min_width, available_width - available_width % kButtonSize + | 466 return std::max(min_width, available_width - available_width % kButtonSize + |
| 467 kHorizontalPadding * 2); | 467 kHorizontalPadding * 2); |
| 468 } | 468 } |
| OLD | NEW |