| 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/bookmark_context_menu.h" | 5 #include "chrome/browser/views/bookmark_context_menu.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/common/notification_service.h" | |
| 11 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 12 #include "views/controls/menu/menu_item_view.h" | 11 #include "views/controls/menu/menu_item_view.h" |
| 13 | 12 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
| 15 // BookmarkContextMenu, public: | 14 // BookmarkContextMenu, public: |
| 16 | 15 |
| 17 BookmarkContextMenu::BookmarkContextMenu( | 16 BookmarkContextMenu::BookmarkContextMenu( |
| 18 gfx::NativeWindow parent_window, | 17 gfx::NativeWindow parent_window, |
| 19 Profile* profile, | 18 Profile* profile, |
| 20 PageNavigator* page_navigator, | 19 PageNavigator* page_navigator, |
| 21 const BookmarkNode* parent, | 20 const BookmarkNode* parent, |
| 22 const std::vector<const BookmarkNode*>& selection, | 21 const std::vector<const BookmarkNode*>& selection, |
| 23 BookmarkContextMenuControllerViews::ConfigurationType configuration) | 22 BookmarkContextMenuControllerViews::ConfigurationType configuration) |
| 24 : ALLOW_THIS_IN_INITIALIZER_LIST( | 23 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 25 controller_(new BookmarkContextMenuControllerViews(parent_window, this
, | 24 controller_(new BookmarkContextMenuControllerViews(parent_window, this
, |
| 26 profile, page_navigator, | 25 profile, page_navigator, |
| 27 parent, selection, | 26 parent, selection, |
| 28 configuration))), | 27 configuration))), |
| 29 parent_window_(parent_window), | 28 parent_window_(parent_window), |
| 30 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))), | 29 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))), |
| 31 observer_(NULL) { | 30 observer_(NULL) { |
| 32 controller_->BuildMenu(); | 31 controller_->BuildMenu(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 BookmarkContextMenu::~BookmarkContextMenu() { | 34 BookmarkContextMenu::~BookmarkContextMenu() { |
| 36 } | 35 } |
| 37 | 36 |
| 38 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { | 37 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { |
| 39 NotificationService::current()->Notify( | |
| 40 NotificationType::BOOKMARK_CONTEXT_MENU_SHOWN, | |
| 41 Source<BookmarkContextMenu>(this), | |
| 42 NotificationService::NoDetails()); | |
| 43 // width/height don't matter here. | 38 // width/height don't matter here. |
| 44 views::MenuItemView::AnchorPosition anchor = base::i18n::IsRTL() ? | 39 views::MenuItemView::AnchorPosition anchor = base::i18n::IsRTL() ? |
| 45 views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT; | 40 views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT; |
| 46 menu_->RunMenuAt(parent_window_, NULL, gfx::Rect(point.x(), point.y(), 0, 0), | 41 menu_->RunMenuAt(parent_window_, NULL, gfx::Rect(point.x(), point.y(), 0, 0), |
| 47 anchor, true); | 42 anchor, true); |
| 48 } | 43 } |
| 49 | 44 |
| 50 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
| 51 // BookmarkContextMenu, views::MenuDelegate implementation: | 46 // BookmarkContextMenu, views::MenuDelegate implementation: |
| 52 | 47 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void BookmarkContextMenu::WillRemoveBookmarks( | 89 void BookmarkContextMenu::WillRemoveBookmarks( |
| 95 const std::vector<const BookmarkNode*>& bookmarks) { | 90 const std::vector<const BookmarkNode*>& bookmarks) { |
| 96 if (observer_) | 91 if (observer_) |
| 97 observer_->WillRemoveBookmarks(bookmarks); | 92 observer_->WillRemoveBookmarks(bookmarks); |
| 98 } | 93 } |
| 99 | 94 |
| 100 void BookmarkContextMenu::DidRemoveBookmarks() { | 95 void BookmarkContextMenu::DidRemoveBookmarks() { |
| 101 if (observer_) | 96 if (observer_) |
| 102 observer_->DidRemoveBookmarks(); | 97 observer_->DidRemoveBookmarks(); |
| 103 } | 98 } |
| OLD | NEW |