Chromium Code Reviews| 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::Size menu_offset) { | |
| 44 gfx::Point screen_location; | 45 gfx::Point screen_location; |
| 45 views::View::ConvertPointToScreen(menu_button, &screen_location); | 46 views::View::ConvertPointToScreen(menu_button, &screen_location); |
| 47 screen_location.Offset(menu_offset.width(), menu_offset.height()); | |
|
Peter Kasting
2012/09/14 22:21:38
If you pass in the offset as a point rather than a
yefimt
2012/09/14 22:46:35
Done.
| |
| 46 menu_runner_.reset(new views::MenuRunner(root_)); | 48 menu_runner_.reset(new views::MenuRunner(root_)); |
| 47 // Ignore the result since we don't need to handle a deleted menu specially. | 49 // Ignore the result since we don't need to handle a deleted menu specially. |
| 48 ignore_result( | 50 ignore_result( |
| 49 menu_runner_->RunMenuAt(menu_button->GetWidget(), | 51 menu_runner_->RunMenuAt(menu_button->GetWidget(), |
| 50 menu_button, | 52 menu_button, |
| 51 gfx::Rect(screen_location, menu_button->size()), | 53 gfx::Rect(screen_location, menu_button->size()), |
| 52 views::MenuItemView::TOPRIGHT, | 54 views::MenuItemView::TOPRIGHT, |
| 53 views::MenuRunner::HAS_MNEMONICS)); | 55 views::MenuRunner::HAS_MNEMONICS)); |
| 54 } | 56 } |
| 55 | 57 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 const extensions::Extension* extension = | 140 const extensions::Extension* extension = |
| 139 model_->GetExtensionAt(model_index); | 141 model_->GetExtensionAt(model_index); |
| 140 BrowserActionView* view = new BrowserActionView(extension, | 142 BrowserActionView* view = new BrowserActionView(extension, |
| 141 browser_, this); | 143 browser_, this); |
| 142 // |menu_item| will own the |view| from now on. | 144 // |menu_item| will own the |view| from now on. |
| 143 menu_item->SetIconView(view); | 145 menu_item->SetIconView(view); |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 } | 148 } |
| 147 } | 149 } |
| OLD | NEW |