| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 | 250 |
| 251 int BrowserActionsContainer::GetCurrentTabId() { | 251 int BrowserActionsContainer::GetCurrentTabId() { |
| 252 TabContents* tab_contents = toolbar_->browser()->GetSelectedTabContents(); | 252 TabContents* tab_contents = toolbar_->browser()->GetSelectedTabContents(); |
| 253 if (!tab_contents) | 253 if (!tab_contents) |
| 254 return -1; | 254 return -1; |
| 255 | 255 |
| 256 return tab_contents->controller().session_id().id(); | 256 return tab_contents->controller().session_id().id(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 BrowserActionView* BrowserActionsContainer::GetBrowserActionView( |
| 260 Extension* extension) { |
| 261 for (std::vector<BrowserActionView*>::iterator iter = |
| 262 browser_action_views_.begin(); iter != browser_action_views_.end(); |
| 263 ++iter) { |
| 264 if ((*iter)->button()->extension() == extension) |
| 265 return *iter; |
| 266 } |
| 267 |
| 268 return NULL; |
| 269 } |
| 270 |
| 259 void BrowserActionsContainer::RefreshBrowserActionViews() { | 271 void BrowserActionsContainer::RefreshBrowserActionViews() { |
| 260 for (size_t i = 0; i < browser_action_views_.size(); ++i) | 272 for (size_t i = 0; i < browser_action_views_.size(); ++i) |
| 261 browser_action_views_[i]->button()->UpdateState(); | 273 browser_action_views_[i]->button()->UpdateState(); |
| 262 } | 274 } |
| 263 | 275 |
| 264 void BrowserActionsContainer::AddBrowserAction(Extension* extension) { | 276 void BrowserActionsContainer::AddBrowserAction(Extension* extension) { |
| 265 #if defined(DEBUG) | 277 #if defined(DEBUG) |
| 266 for (size_t i = 0; i < browser_action_views_.size(); ++i) { | 278 for (size_t i = 0; i < browser_action_views_.size(); ++i) { |
| 267 DCHECK(browser_action_views_[i]->button()->extension() != extension) << | 279 DCHECK(browser_action_views_[i]->button()->extension() != extension) << |
| 268 "Asked to add a browser action view for an extension that already " | 280 "Asked to add a browser action view for an extension that already " |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 std::min(static_cast<int>(browser_action_views_.size()), | 469 std::min(static_cast<int>(browser_action_views_.size()), |
| 458 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; | 470 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; |
| 459 | 471 |
| 460 // Even if available_width is <= 0, we still return at least the |min_width|. | 472 // Even if available_width is <= 0, we still return at least the |min_width|. |
| 461 if (available_width <= 0) | 473 if (available_width <= 0) |
| 462 return min_width; | 474 return min_width; |
| 463 | 475 |
| 464 return std::max(min_width, available_width - available_width % kButtonSize + | 476 return std::max(min_width, available_width - available_width % kButtonSize + |
| 465 kHorizontalPadding * 2); | 477 kHorizontalPadding * 2); |
| 466 } | 478 } |
| OLD | NEW |