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/extensions/browser_action_overflow_menu_controlle
r.h" | 5 #include "chrome/browser/views/extensions/browser_action_overflow_menu_controlle
r.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/browser/views/browser_actions_container.h" | 10 #include "chrome/browser/views/browser_actions_container.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 start_index_(start_index) { | 22 start_index_(start_index) { |
23 menu_.reset(new views::MenuItemView(this)); | 23 menu_.reset(new views::MenuItemView(this)); |
24 menu_->set_has_icons(true); | 24 menu_->set_has_icons(true); |
25 | 25 |
26 TabContents* tab = BrowserList::GetLastActive()->GetSelectedTabContents(); | 26 TabContents* tab = BrowserList::GetLastActive()->GetSelectedTabContents(); |
27 int tab_id = tab->controller().session_id().id(); | 27 int tab_id = tab->controller().session_id().id(); |
28 | 28 |
29 size_t command_id = 0; | 29 size_t command_id = 0; |
30 for (size_t i = start_index; i < views_->size(); ++i) { | 30 for (size_t i = start_index; i < views_->size(); ++i) { |
31 BrowserActionView* view = (*views_)[i]; | 31 BrowserActionView* view = (*views_)[i]; |
| 32 SkBitmap icon = |
| 33 view->button()->extension()->browser_action()->GetIcon(tab_id); |
| 34 if (icon.isNull()) |
| 35 icon = view->button()->default_icon(); |
32 menu_->AppendMenuItemWithIcon( | 36 menu_->AppendMenuItemWithIcon( |
33 command_id, | 37 command_id, |
34 UTF8ToWide(view->button()->extension()->name()), | 38 UTF8ToWide(view->button()->extension()->name()), |
35 view->button()->extension()->browser_action()->GetIcon(tab_id)); | 39 icon); |
36 ++command_id; | 40 ++command_id; |
37 } | 41 } |
38 } | 42 } |
39 | 43 |
40 BrowserActionOverflowMenuController::~BrowserActionOverflowMenuController() { | 44 BrowserActionOverflowMenuController::~BrowserActionOverflowMenuController() { |
41 } | 45 } |
42 | 46 |
43 bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window) { | 47 bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window) { |
44 gfx::Rect bounds = menu_button_->GetBounds( | 48 gfx::Rect bounds = menu_button_->GetBounds( |
45 views::View::IGNORE_MIRRORING_TRANSFORMATION); | 49 views::View::IGNORE_MIRRORING_TRANSFORMATION); |
(...skipping 27 matching lines...) Expand all Loading... |
73 // This blocks until the user choses something or dismisses. | 77 // This blocks until the user choses something or dismisses. |
74 context_menu_->Run((*views_)[start_index_ + id]->button()->extension(), | 78 context_menu_->Run((*views_)[start_index_ + id]->button()->extension(), |
75 gfx::Point(x, y)); | 79 gfx::Point(x, y)); |
76 | 80 |
77 // The user is done with the context menu, so we can close the underlying | 81 // The user is done with the context menu, so we can close the underlying |
78 // menu. | 82 // menu. |
79 menu_->Cancel(); | 83 menu_->Cancel(); |
80 | 84 |
81 return true; | 85 return true; |
82 } | 86 } |
OLD | NEW |