diff options
Diffstat (limited to 'chrome/browser/ui')
22 files changed, 97 insertions, 61 deletions
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc index 0041557..d12c67f 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.cc +++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc @@ -448,7 +448,7 @@ void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) { DCHECK_EQ(settings_button_, source); gfx::Point screen_point; views::View::ConvertPointToScreen(source, &screen_point); - settings_menu_.RunMenuAt(source->GetWidget()->GetNativeWindow(), + settings_menu_.RunMenuAt(source->GetWidget(), settings_button_, gfx::Rect(screen_point, source->size()), views::MenuItemView::TOPRIGHT, true); } diff --git a/chrome/browser/ui/views/avatar_menu.cc b/chrome/browser/ui/views/avatar_menu.cc index 656be6c..346f521 100644 --- a/chrome/browser/ui/views/avatar_menu.cc +++ b/chrome/browser/ui/views/avatar_menu.cc @@ -194,6 +194,6 @@ void AvatarMenu::RunMenu(views::MenuButton* host) { gfx::Point screen_loc; views::View::ConvertPointToScreen(host, &screen_loc); gfx::Rect bounds(screen_loc, host->size()); - root_->RunMenuAt(host->GetWidget()->GetNativeWindow(), host, bounds, - views::MenuItemView::TOPLEFT, true); + root_->RunMenuAt(host->GetWidget(), host, bounds, + views::MenuItemView::TOPLEFT, true); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index f489a8a..5f5d238 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -1066,8 +1066,7 @@ void BookmarkBarView::RunMenu(views::View* view, const gfx::Point& pt) { } bookmark_menu_ = new BookmarkMenuController( - profile_, page_navigator_, GetWidget()->GetNativeWindow(), node, - start_index); + profile_, page_navigator_, GetWidget(), node, start_index); bookmark_menu_->set_observer(this); bookmark_menu_->RunMenuAt(this, false); } @@ -1141,7 +1140,7 @@ void BookmarkBarView::ShowContextMenuForView(View* source, bool close_on_remove = (parent == profile_->GetBookmarkModel()->other_node() && parent->child_count() == 1); - BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, + BookmarkContextMenu controller(GetWidget(), profile_, navigator, parent, nodes, close_on_remove); controller.RunMenuAt(p); } @@ -1395,8 +1394,7 @@ void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) { drop_info_->is_menu_showing = true; bookmark_drop_menu_ = new BookmarkMenuController( - profile_, page_navigator_, GetWidget()->GetNativeWindow(), node, - start_index); + profile_, page_navigator_, GetWidget(), node, start_index); bookmark_drop_menu_->set_observer(this); bookmark_drop_menu_->RunMenuAt(this, true); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc index 4504833..0a4633f 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc @@ -14,21 +14,22 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "views/controls/menu/menu_item_view.h" +#include "views/widget/widget.h" //////////////////////////////////////////////////////////////////////////////// // BookmarkContextMenu, public: BookmarkContextMenu::BookmarkContextMenu( - gfx::NativeWindow parent_window, + views::Widget* parent_widget, Profile* profile, PageNavigator* page_navigator, const BookmarkNode* parent, const std::vector<const BookmarkNode*>& selection, bool close_on_remove) : ALLOW_THIS_IN_INITIALIZER_LIST( - controller_(new BookmarkContextMenuControllerViews(parent_window, + controller_(new BookmarkContextMenuControllerViews(parent_widget, this, profile, page_navigator, parent, selection))), - parent_window_(parent_window), + parent_widget_(parent_widget), ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))), parent_node_(parent), observer_(NULL), @@ -47,7 +48,7 @@ void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { // width/height don't matter here. views::MenuItemView::AnchorPosition anchor = base::i18n::IsRTL() ? views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT; - menu_->RunMenuAt(parent_window_, NULL, gfx::Rect(point.x(), point.y(), 0, 0), + menu_->RunMenuAt(parent_widget_, NULL, gfx::Rect(point.x(), point.y(), 0, 0), anchor, true); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h index 5fb95c5..de732d1 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h @@ -9,6 +9,10 @@ #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h" #include "views/controls/menu/menu_delegate.h" +namespace views { +class Widget; +} + // Observer for the BookmarkContextMenu. class BookmarkContextMenuObserver { public: @@ -27,7 +31,7 @@ class BookmarkContextMenu : public BookmarkContextMenuControllerViewsDelegate, public views::MenuDelegate { public: BookmarkContextMenu( - gfx::NativeWindow parent_window, + views::Widget* parent_widget, Profile* profile, PageNavigator* page_navigator, const BookmarkNode* parent, @@ -63,7 +67,7 @@ class BookmarkContextMenu : public BookmarkContextMenuControllerViewsDelegate, scoped_ptr<BookmarkContextMenuControllerViews> controller_; // The parent of dialog boxes opened from the context menu. - gfx::NativeWindow parent_window_; + views::Widget* parent_widget_; // The menu itself. scoped_ptr<views::MenuItemView> menu_; diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc index be87e71..fe6ff6b 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc @@ -18,15 +18,16 @@ #include "chrome/common/pref_names.h" #include "content/browser/tab_contents/page_navigator.h" #include "grit/generated_resources.h" +#include "views/widget/widget.h" BookmarkContextMenuControllerViews::BookmarkContextMenuControllerViews( - gfx::NativeWindow parent_window, + views::Widget* parent_widget, BookmarkContextMenuControllerViewsDelegate* delegate, Profile* profile, PageNavigator* navigator, const BookmarkNode* parent, const std::vector<const BookmarkNode*>& selection) - : parent_window_(parent_window), + : parent_widget_(parent_widget), delegate_(delegate), profile_(profile), navigator_(navigator), @@ -111,7 +112,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { UserMetrics::RecordAction( UserMetricsAction("BookmarkBar_ContextMenu_OpenAllIncognito")); } - bookmark_utils::OpenAll(parent_window_, profile_, navigator_, selection_, + bookmark_utils::OpenAll(parent_widget_->GetNativeWindow(), + profile_, navigator_, selection_, initial_disposition); break; } @@ -127,12 +129,12 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { } if (selection_[0]->is_url()) { - BookmarkEditor::Show(parent_window_, profile_, parent_, - BookmarkEditor::EditDetails(selection_[0]), - BookmarkEditor::SHOW_TREE); + BookmarkEditor::Show(parent_widget_->GetNativeWindow(), profile_, + parent_, BookmarkEditor::EditDetails(selection_[0]), + BookmarkEditor::SHOW_TREE); } else { - BookmarkFolderEditorController::Show(profile_, parent_window_, - selection_[0], -1, + BookmarkFolderEditorController::Show(profile_, + parent_widget_->GetNativeWindow(), selection_[0], -1, BookmarkFolderEditorController::EXISTING_BOOKMARK); } break; @@ -157,7 +159,7 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { // TODO: this should honor the index from GetParentForNewNodes. BookmarkEditor::Show( - parent_window_, profile_, + parent_widget_->GetNativeWindow(), profile_, bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); break; @@ -169,8 +171,9 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { int index; const BookmarkNode* parent = bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); - BookmarkFolderEditorController::Show(profile_, parent_window_, parent, - index, BookmarkFolderEditorController::NEW_BOOKMARK); + BookmarkFolderEditorController::Show(profile_, + parent_widget_->GetNativeWindow(), parent, index, + BookmarkFolderEditorController::NEW_BOOKMARK); break; } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h index 7870d21..3166194 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h @@ -10,11 +10,14 @@ #include "base/basictypes.h" #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" -#include "ui/gfx/native_widget_types.h" class PageNavigator; class Profile; +namespace views { +class Widget; +} + // An interface implemented by an object that performs actions on the actual // menu for the controller. class BookmarkContextMenuControllerViewsDelegate { @@ -42,14 +45,14 @@ class BookmarkContextMenuControllerViewsDelegate { class BookmarkContextMenuControllerViews : public BaseBookmarkModelObserver { public: // Creates the bookmark context menu. - // |parent_window| is the window that this menu should be added to. + // |parent_widget| is the window that this menu should be added to. // |delegate| is described above. // |profile| is used for opening urls as well as enabling 'open incognito'. // |navigator| is used if |browser| is null, and is provided for testing. // |parent| is the parent for newly created nodes if |selection| is empty. // |selection| is the nodes the context menu operates on and may be empty. BookmarkContextMenuControllerViews( - gfx::NativeWindow parent_window, + views::Widget* parent_widget, BookmarkContextMenuControllerViewsDelegate* delegate, Profile* profile, PageNavigator* navigator, @@ -78,7 +81,7 @@ class BookmarkContextMenuControllerViews : public BaseBookmarkModelObserver { // Returns true if selection_ has at least one bookmark of type url. bool HasURLs() const; - gfx::NativeWindow parent_window_; + views::Widget* parent_widget_; BookmarkContextMenuControllerViewsDelegate* delegate_; Profile* profile_; PageNavigator* navigator_; diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc index 3307ea3..d6f5e81 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc @@ -24,12 +24,13 @@ #include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/resource/resource_bundle.h" #include "views/controls/button/menu_button.h" +#include "views/widget/widget.h" using views::MenuItemView; BookmarkMenuController::BookmarkMenuController(Profile* profile, PageNavigator* navigator, - gfx::NativeWindow parent, + views::Widget* parent, const BookmarkNode* node, int start_child_index) : menu_delegate_(new BookmarkMenuDelegate(profile, navigator, parent, 1)), diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h index ae9adee..770d2b8 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h @@ -10,7 +10,6 @@ #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" #include "chrome/browser/bookmarks/bookmark_node_data.h" -#include "ui/gfx/native_widget_types.h" #include "views/controls/menu/menu_delegate.h" #include "views/controls/menu/menu_item_view.h" @@ -30,6 +29,7 @@ class OSExchangeData; namespace views { class MenuButton; +class Widget; } // namespace views // BookmarkMenuController is responsible for showing a menu of bookmarks, @@ -52,7 +52,7 @@ class BookmarkMenuController : public BaseBookmarkModelObserver, // at |start_child_index|. BookmarkMenuController(Profile* profile, PageNavigator* page_navigator, - gfx::NativeWindow parent, + views::Widget* parent, const BookmarkNode* node, int start_child_index); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc index 83188af..2f5d002 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc @@ -26,6 +26,7 @@ #include "views/controls/button/menu_button.h" #include "views/controls/menu/menu_item_view.h" #include "views/controls/menu/submenu_view.h" +#include "views/widget/widget.h" using views::MenuItemView; @@ -35,7 +36,7 @@ static const int kMaxMenuWidth = 400; BookmarkMenuDelegate::BookmarkMenuDelegate(Profile* profile, PageNavigator* navigator, - gfx::NativeWindow parent, + views::Widget* parent, int first_menu_id) : profile_(profile), page_navigator_(navigator), @@ -117,8 +118,8 @@ void BookmarkMenuDelegate::ExecuteCommand(int id, int mouse_event_flags) { WindowOpenDisposition initial_disposition = event_utils::DispositionFromEventFlags(mouse_event_flags); - bookmark_utils::OpenAll(parent_, profile_, page_navigator_, selection, - initial_disposition); + bookmark_utils::OpenAll(parent_->GetNativeWindow(), profile_, page_navigator_, + selection, initial_disposition); } bool BookmarkMenuDelegate::GetDropFormats( diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h index 105c8d6..9ad6ca6 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h @@ -12,7 +12,6 @@ #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" #include "chrome/browser/bookmarks/bookmark_node_data.h" #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" -#include "ui/gfx/native_widget_types.h" #include "views/controls/menu/menu_delegate.h" class BookmarkNode; @@ -25,6 +24,7 @@ class OSExchangeData; namespace views { class MenuItemView; +class Widget; } // BookmarkMenuDelegate acts as the (informal) views::MenuDelegate for showing @@ -47,7 +47,7 @@ class BookmarkMenuDelegate : public BaseBookmarkModelObserver, BookmarkMenuDelegate(Profile* profile, PageNavigator* navigator, - gfx::NativeWindow parent, + views::Widget* parent, int first_menu_id); virtual ~BookmarkMenuDelegate(); @@ -75,7 +75,7 @@ class BookmarkMenuDelegate : public BaseBookmarkModelObserver, Profile* profile() { return profile_; } - gfx::NativeWindow parent() { return parent_; } + views::Widget* parent() { return parent_; } // Returns true if we're in the process of mutating the model. This happens // when the user deletes menu items using the context menu. @@ -153,7 +153,7 @@ class BookmarkMenuDelegate : public BaseBookmarkModelObserver, PageNavigator* page_navigator_; // Parent of menus. - gfx::NativeWindow parent_; + views::Widget* parent_; // Maps from menu id to BookmarkNode. std::map<int, const BookmarkNode*> menu_id_to_node_map_; diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index cc124c8..a8a369e 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -261,8 +261,8 @@ void BrowserActionButton::ShowContextMenu(const gfx::Point& p, context_menu_ = &menu; gfx::Point screen_loc; views::View::ConvertPointToScreen(this, &screen_loc); - context_menu_->RunMenuAt(GetWidget()->GetNativeWindow(), NULL, - gfx::Rect(screen_loc, size()), views::MenuItemView::TOPLEFT, true); + context_menu_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), + views::MenuItemView::TOPLEFT, true); SetButtonNotPushed(); context_menu_ = NULL; @@ -712,7 +712,7 @@ void BrowserActionsContainer::RunMenu(View* source, const gfx::Point& pt) { overflow_menu_ = new BrowserActionOverflowMenuController( this, chevron_, browser_action_views_, VisibleBrowserActions()); overflow_menu_->set_observer(this); - overflow_menu_->RunMenu(GetWidget()->GetNativeWindow(), false); + overflow_menu_->RunMenu(GetWidget(), false); } } @@ -1025,7 +1025,7 @@ void BrowserActionsContainer::ShowDropFolder() { overflow_menu_ = new BrowserActionOverflowMenuController( this, chevron_, browser_action_views_, VisibleBrowserActions()); overflow_menu_->set_observer(this); - overflow_menu_->RunMenu(GetWidget()->GetNativeWindow(), true); + overflow_menu_->RunMenu(GetWidget(), true); } void BrowserActionsContainer::SetDropIndicator(int x_pos) { diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc index 0ed6a2f..621886d 100644 --- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc +++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc @@ -56,7 +56,7 @@ BrowserActionOverflowMenuController::~BrowserActionOverflowMenuController() { observer_->NotifyMenuDeleted(this); } -bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window, +bool BrowserActionOverflowMenuController::RunMenu(views::Widget* window, bool for_drop) { for_drop_ = for_drop; @@ -106,7 +106,7 @@ bool BrowserActionOverflowMenuController::ShowContextMenu( context_menu_model_adapter.BuildMenu(&context_menu); // This blocks until the user choses something or dismisses the menu. - context_menu.RunMenuAt(menu_button_->GetWidget()->GetNativeWindow(), + context_menu.RunMenuAt(menu_button_->GetWidget(), NULL, gfx::Rect(p, gfx::Size()), views::MenuItemView::TOPLEFT, true); // The user is done with the context menu, so we can close the underlying diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h index 79d69f9..d9c4e75 100644 --- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h +++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h @@ -16,6 +16,10 @@ class BrowserActionsContainer; class BrowserActionView; +namespace views { +class Widget; +} + // This class handles the overflow menu for browser actions (showing the menu, // drag and drop, etc). This class manages its own lifetime. class BrowserActionOverflowMenuController : public views::MenuDelegate { @@ -36,7 +40,7 @@ class BrowserActionOverflowMenuController : public views::MenuDelegate { void set_observer(Observer* observer) { observer_ = observer; } // Shows the overflow menu. - bool RunMenu(gfx::NativeWindow window, bool for_drop); + bool RunMenu(views::Widget* widget, bool for_drop); // Closes the overflow menu (and its context menu if open as well). void CancelMenu(); diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc index e08fffc..3ce1c3f 100644 --- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc @@ -178,6 +178,6 @@ void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) { views::MenuModelAdapter menu_model_adapter(menu_model); views::MenuItemView menu(&menu_model_adapter); menu_model_adapter.BuildMenu(&menu); - menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL, - gfx::Rect(pt, gfx::Size()), views::MenuItemView::TOPRIGHT, true); + menu.RunMenuAt(source->GetWidget(), NULL, gfx::Rect(pt, gfx::Size()), + views::MenuItemView::TOPRIGHT, true); } diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc index 1637922..b1f2909 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc @@ -199,6 +199,6 @@ void BeforeTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) { views::MenuModelAdapter menu_model_adapter(menu_model); views::MenuItemView menu(&menu_model_adapter); menu_model_adapter.BuildMenu(&menu); - menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL, - gfx::Rect(pt, gfx::Size()), views::MenuItemView::TOPRIGHT, true); + menu.RunMenuAt(source->GetWidget(), NULL, gfx::Rect(pt, gfx::Size()), + views::MenuItemView::TOPRIGHT, true); } diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index fcbb48e..4da0f4c 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -189,7 +189,7 @@ void ExtensionInfoBar::RunMenu(View* source, const gfx::Point& pt) { gfx::Point screen_point; views::View::ConvertPointToScreen(menu_, &screen_point); - options_menu.RunMenuAt(GetWidget()->GetNativeWindow(), menu_, + options_menu.RunMenuAt(GetWidget(), menu_, gfx::Rect(screen_point, menu_->size()), views::MenuItemView::TOPLEFT, true); } diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc index 3cbad31..f8168f4 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc @@ -159,8 +159,8 @@ void PageActionImageView::ShowContextMenu(const gfx::Point& p, gfx::Point screen_loc; views::View::ConvertPointToScreen(this, &screen_loc); - menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL, - gfx::Rect(screen_loc ,size()), views::MenuItemView::TOPLEFT, true); + menu.RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc ,size()), + views::MenuItemView::TOPLEFT, true); } void PageActionImageView::OnImageLoaded( diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc index 05bf1ea..d4c9a90 100644 --- a/chrome/browser/ui/views/menu_item_view_test.cc +++ b/chrome/browser/ui/views/menu_item_view_test.cc @@ -68,7 +68,7 @@ class MenuItemViewTestBase : public ViewEventTestBase, views::View::ConvertPointToScreen(source, &screen_location); gfx::Rect bounds(screen_location, source->size()); menu_->RunMenuAt( - source->GetWidget()->GetNativeWindow(), + source->GetWidget(), button_, bounds, views::MenuItemView::TOPLEFT, diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc index 9070005..41194b4 100644 --- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc +++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc @@ -16,6 +16,13 @@ #include "views/controls/menu/menu_model_adapter.h" #include "views/controls/menu/menu_runner.h" +#if defined(TOUCH_UI) +#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h" +#include "views/widget/widget.h" +#else +#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" +#endif + //////////////////////////////////////////////////////////////////////////////// // RenderViewContextMenuViews, public: @@ -30,9 +37,19 @@ RenderViewContextMenuViews::~RenderViewContextMenuViews() { } void RenderViewContextMenuViews::RunMenuAt(int x, int y) { - menu_runner_->RunMenuAt( - source_tab_contents_->view()->GetTopLevelNativeWindow(), - NULL, gfx::Rect(gfx::Point(x, y), gfx::Size()), +#if defined(TOUCH_UI) + // TODO(oshima): Eliminate this once TabContentsViewTouch is replaced + // with TabContentsViewViews. + TabContentsViewTouch* touch = + static_cast<TabContentsViewTouch*>(source_tab_contents_->view()); + views::Widget* parent = touch->GetWidget()->GetTopLevelWidget(); +#else + TabContentsViewViews* tab = + static_cast<TabContentsViewViews*>(source_tab_contents_->view()); + views::Widget* parent = tab->GetTopLevelWidget(); +#endif + menu_runner_->RunMenuAt(parent, NULL, + gfx::Rect(gfx::Point(x, y), gfx::Size()), views::MenuItemView::TOPLEFT, true); } diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index d6179f2..92b8414 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -64,8 +64,8 @@ class BrowserTabStripController::TabContextMenuContents } void RunMenuAt(const gfx::Point& point) { - menu_.RunMenuAt(tab_->GetWidget()->GetNativeWindow(), NULL, - gfx::Rect(point, gfx::Size()), views::MenuItemView::TOPLEFT, true); + menu_.RunMenuAt(tab_->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), + views::MenuItemView::TOPLEFT, true); // We could be gone now. Assume |this| is junk! } diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index 0da990d..386e8d5 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -592,7 +592,7 @@ void WrenchMenu::RunMenu(views::MenuButton* host) { views::View::ConvertPointToScreen(host, &screen_loc); gfx::Rect bounds(screen_loc, host->size()); UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu")); - root_->RunMenuAt(host->GetWidget()->GetNativeWindow(), host, bounds, + root_->RunMenuAt(host->GetWidget(), host, bounds, MenuItemView::TOPRIGHT, true); if (bookmark_menu_delegate_.get()) { BookmarkModel* model = browser_->profile()->GetBookmarkModel(); @@ -853,10 +853,14 @@ void WrenchMenu::CreateBookmarkMenu() { return; model->AddObserver(this); + + // TODO(oshima): Replace with views only API. + views::Widget* parent = views::Widget::GetWidgetForNativeWindow( + browser_->window()->GetNativeHandle()); bookmark_menu_delegate_.reset( new BookmarkMenuDelegate(browser_->profile(), NULL, - browser_->window()->GetNativeHandle(), + parent, first_bookmark_command_id_)); bookmark_menu_delegate_->Init( this, bookmark_menu_, model->bookmark_bar_node(), 0, |