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" |
11 #include "chrome/browser/extensions/extension_browser_event_router.h" | 11 #include "chrome/browser/extensions/extension_browser_event_router.h" |
12 #include "chrome/browser/extensions/extensions_service.h" | 12 #include "chrome/browser/extensions/extensions_service.h" |
13 #include "chrome/browser/extensions/extension_tabs_module.h" | 13 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 14 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/view_ids.h" | 16 #include "chrome/browser/view_ids.h" |
16 #include "chrome/browser/views/extensions/extension_popup.h" | 17 #include "chrome/browser/views/extensions/extension_popup.h" |
17 #include "chrome/browser/views/toolbar_view.h" | 18 #include "chrome/browser/views/toolbar_view.h" |
18 #include "chrome/common/notification_source.h" | 19 #include "chrome/common/notification_source.h" |
19 #include "chrome/common/notification_type.h" | 20 #include "chrome/common/notification_type.h" |
20 #include "grit/app_resources.h" | 21 #include "grit/app_resources.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "third_party/skia/include/core/SkTypeface.h" | 23 #include "third_party/skia/include/core/SkTypeface.h" |
23 #include "third_party/skia/include/effects/SkGradientShader.h" | 24 #include "third_party/skia/include/effects/SkGradientShader.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 445 |
445 void BrowserActionsContainer::BubbleBrowserWindowMoved(BrowserBubble* bubble) { | 446 void BrowserActionsContainer::BubbleBrowserWindowMoved(BrowserBubble* bubble) { |
446 } | 447 } |
447 | 448 |
448 void BrowserActionsContainer::BubbleBrowserWindowClosing( | 449 void BrowserActionsContainer::BubbleBrowserWindowClosing( |
449 BrowserBubble* bubble) { | 450 BrowserBubble* bubble) { |
450 HidePopup(); | 451 HidePopup(); |
451 } | 452 } |
452 | 453 |
453 void BrowserActionsContainer::BubbleGotFocus(BrowserBubble* bubble) { | 454 void BrowserActionsContainer::BubbleGotFocus(BrowserBubble* bubble) { |
| 455 if (!popup_) |
| 456 return; |
| 457 |
| 458 // Forward the focus to the renderer. |
| 459 popup_->host()->render_view_host()->view()->Focus(); |
454 } | 460 } |
455 | 461 |
456 void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble) { | 462 void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble) { |
457 if (!popup_) | 463 if (!popup_) |
458 return; | 464 return; |
459 | 465 |
460 // This is a bit annoying. If you click on the button that generated the | 466 // This is a bit annoying. If you click on the button that generated the |
461 // current popup, then we first get this lost focus message, and then | 467 // current popup, then we first get this lost focus message, and then |
462 // we get the click action. This results in the popup being immediately | 468 // we get the click action. This results in the popup being immediately |
463 // shown again. To workaround this, we put in a delay. | 469 // shown again. To workaround this, we put in a delay. |
(...skipping 10 matching lines...) Expand all Loading... |
474 std::min(static_cast<int>(browser_action_views_.size()), | 480 std::min(static_cast<int>(browser_action_views_.size()), |
475 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; | 481 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; |
476 | 482 |
477 // Even if available_width is <= 0, we still return at least the |min_width|. | 483 // Even if available_width is <= 0, we still return at least the |min_width|. |
478 if (available_width <= 0) | 484 if (available_width <= 0) |
479 return min_width; | 485 return min_width; |
480 | 486 |
481 return std::max(min_width, available_width - available_width % kButtonSize + | 487 return std::max(min_width, available_width - available_width % kButtonSize + |
482 kHorizontalPadding * 2); | 488 kHorizontalPadding * 2); |
483 } | 489 } |
OLD | NEW |