| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/action_box_menu.h" | 5 #include "chrome/browser/ui/views/action_box_menu.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/toolbar/action_box_menu_model.h" | 7 #include "chrome/browser/ui/toolbar/action_box_menu_model.h" |
| 8 #include "chrome/browser/ui/views/browser_action_view.h" | 8 #include "chrome/browser/ui/views/browser_action_view.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ActionBoxMenu::~ActionBoxMenu() { | 33 ActionBoxMenu::~ActionBoxMenu() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ActionBoxMenu::Init() { | 36 void ActionBoxMenu::Init() { |
| 37 DCHECK(!root_); | 37 DCHECK(!root_); |
| 38 root_ = new views::MenuItemView(this); | 38 root_ = new views::MenuItemView(this); |
| 39 root_->set_has_icons(true); | 39 root_->set_has_icons(true); |
| 40 PopulateMenu(); | 40 PopulateMenu(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ActionBoxMenu::RunMenu(views::MenuButton* menu_button) { | 43 void ActionBoxMenu::RunMenu(views::MenuButton* menu_button, |
| 44 gfx::Point screen_location; | 44 gfx::Point menu_offset) { |
| 45 views::View::ConvertPointToScreen(menu_button, &screen_location); | 45 views::View::ConvertPointToScreen(menu_button, &menu_offset); |
| 46 menu_runner_.reset(new views::MenuRunner(root_)); | 46 menu_runner_.reset(new views::MenuRunner(root_)); |
| 47 // Ignore the result since we don't need to handle a deleted menu specially. | 47 // Ignore the result since we don't need to handle a deleted menu specially. |
| 48 ignore_result( | 48 ignore_result( |
| 49 menu_runner_->RunMenuAt(menu_button->GetWidget(), | 49 menu_runner_->RunMenuAt(menu_button->GetWidget(), |
| 50 menu_button, | 50 menu_button, |
| 51 gfx::Rect(screen_location, menu_button->size()), | 51 gfx::Rect(menu_offset, menu_button->size()), |
| 52 views::MenuItemView::TOPRIGHT, | 52 views::MenuItemView::TOPRIGHT, |
| 53 views::MenuRunner::HAS_MNEMONICS)); | 53 views::MenuRunner::HAS_MNEMONICS)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ActionBoxMenu::ExecuteCommand(int id) { | 56 void ActionBoxMenu::ExecuteCommand(int id) { |
| 57 model_->ExecuteCommand(id); | 57 model_->ExecuteCommand(id); |
| 58 } | 58 } |
| 59 | 59 |
| 60 views::Border* ActionBoxMenu::CreateMenuBorder() { | 60 views::Border* ActionBoxMenu::CreateMenuBorder() { |
| 61 // TODO(yefim): Use correct theme color on non-Windows. | 61 // TODO(yefim): Use correct theme color on non-Windows. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 const extensions::Extension* extension = | 138 const extensions::Extension* extension = |
| 139 model_->GetExtensionAt(model_index); | 139 model_->GetExtensionAt(model_index); |
| 140 BrowserActionView* view = new BrowserActionView(extension, | 140 BrowserActionView* view = new BrowserActionView(extension, |
| 141 browser_, this); | 141 browser_, this); |
| 142 // |menu_item| will own the |view| from now on. | 142 // |menu_item| will own the |view| from now on. |
| 143 menu_item->SetIconView(view); | 143 menu_item->SetIconView(view); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| OLD | NEW |