| 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/bookmarks/bookmark_context_menu.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 11 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 12 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 13 #include "ui/views/controls/menu/menu_item_view.h" | 15 #include "ui/views/controls/menu/menu_item_view.h" |
| 14 #include "ui/views/controls/menu/menu_model_adapter.h" | 16 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 15 #include "ui/views/controls/menu/menu_runner.h" | 17 #include "ui/views/controls/menu/menu_runner.h" |
| 16 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 17 | 19 |
| 18 using bookmarks::BookmarkNode; | 20 using bookmarks::BookmarkNode; |
| 19 using content::PageNavigator; | 21 using content::PageNavigator; |
| 20 | 22 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 views::MenuModelAdapter::AppendMenuItemFromModel( | 57 views::MenuModelAdapter::AppendMenuItemFromModel( |
| 56 menu_model, i, menu_, menu_model->GetCommandIdAt(i)); | 58 menu_model, i, menu_, menu_model->GetCommandIdAt(i)); |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 | 61 |
| 60 BookmarkContextMenu::~BookmarkContextMenu() { | 62 BookmarkContextMenu::~BookmarkContextMenu() { |
| 61 } | 63 } |
| 62 | 64 |
| 63 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point, | 65 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point, |
| 64 ui::MenuSourceType source_type) { | 66 ui::MenuSourceType source_type) { |
| 67 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
| 68 return; |
| 69 |
| 65 content::NotificationService::current()->Notify( | 70 content::NotificationService::current()->Notify( |
| 66 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, | 71 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, |
| 67 content::Source<BookmarkContextMenu>(this), | 72 content::Source<BookmarkContextMenu>(this), |
| 68 content::NotificationService::NoDetails()); | 73 content::NotificationService::NoDetails()); |
| 69 // width/height don't matter here. | 74 // width/height don't matter here. |
| 70 if (menu_runner_->RunMenuAt(parent_widget_, | 75 if (menu_runner_->RunMenuAt(parent_widget_, |
| 71 NULL, | 76 NULL, |
| 72 gfx::Rect(point.x(), point.y(), 0, 0), | 77 gfx::Rect(point.x(), point.y(), 0, 0), |
| 73 views::MENU_ANCHOR_TOPLEFT, | 78 views::MENU_ANCHOR_TOPLEFT, |
| 74 source_type) == views::MenuRunner::MENU_DELETED) { | 79 source_type) == views::MenuRunner::MENU_DELETED) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int command_id, | 120 int command_id, |
| 116 const std::vector<const BookmarkNode*>& bookmarks) { | 121 const std::vector<const BookmarkNode*>& bookmarks) { |
| 117 if (observer_ && IsRemoveBookmarksCommand(command_id)) | 122 if (observer_ && IsRemoveBookmarksCommand(command_id)) |
| 118 observer_->WillRemoveBookmarks(bookmarks); | 123 observer_->WillRemoveBookmarks(bookmarks); |
| 119 } | 124 } |
| 120 | 125 |
| 121 void BookmarkContextMenu::DidExecuteCommand(int command_id) { | 126 void BookmarkContextMenu::DidExecuteCommand(int command_id) { |
| 122 if (observer_ && IsRemoveBookmarksCommand(command_id)) | 127 if (observer_ && IsRemoveBookmarksCommand(command_id)) |
| 123 observer_->DidRemoveBookmarks(); | 128 observer_->DidRemoveBookmarks(); |
| 124 } | 129 } |
| OLD | NEW |