Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5273)

Unified Diff: chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc

Issue 37553002: [MediaGalleries] Add context menu for forgetting galleries. [views] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dlgfix
Patch Set: Inline menu text command Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/extensions/media_galleries_dialog_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc
diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc
index dcc82613242a658c60acecc681520be7c5f6d43a..c2689811ce276aa5aa381ed6f23782376543809d 100644
--- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc
+++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc
@@ -20,6 +20,7 @@
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
+#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/layout/box_layout.h"
@@ -235,8 +236,12 @@ bool MediaGalleriesDialogViews::AddOrUpdateGallery(
views::Checkbox* checkbox = new views::Checkbox(label);
checkbox->set_listener(this);
+ if (gallery.pref_id != kInvalidMediaGalleryPrefId)
+ checkbox->set_context_menu_controller(this);
checkbox->SetTooltipText(tooltip_text);
views::Label* secondary_text = new views::Label(details);
+ if (gallery.pref_id != kInvalidMediaGalleryPrefId)
+ secondary_text->set_context_menu_controller(this);
secondary_text->SetTooltipText(tooltip_text);
secondary_text->SetEnabledColor(kDeemphasizedTextColor);
secondary_text->SetTooltipText(tooltip_text);
@@ -247,6 +252,8 @@ bool MediaGalleriesDialogViews::AddOrUpdateGallery(
views::kRelatedControlSmallHorizontalSpacing));
views::View* checkbox_view = new views::View();
+ if (gallery.pref_id != kInvalidMediaGalleryPrefId)
+ checkbox_view->set_context_menu_controller(this);
checkbox_view->set_border(views::Border::CreateEmptyBorder(
0,
views::kPanelHorizMargin,
@@ -365,6 +372,34 @@ void MediaGalleriesDialogViews::ButtonPressed(views::Button* sender,
}
}
+void MediaGalleriesDialogViews::ShowContextMenuForView(
+ views::View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
+ for (CheckboxMap::const_iterator iter = checkbox_map_.begin();
+ iter != checkbox_map_.end(); ++iter) {
+ if (iter->second->parent()->Contains(source)) {
+ ShowContextMenu(point, source_type, iter->first);
+ return;
+ }
+ }
+}
+
+void MediaGalleriesDialogViews::ShowContextMenu(const gfx::Point& point,
+ ui::MenuSourceType source_type,
+ MediaGalleryPrefId id) {
+ context_menu_runner_.reset(new views::MenuRunner(
+ controller_->GetContextMenuModel(id)));
+
+ if (context_menu_runner_->RunMenuAt(
+ GetWidget(), NULL, gfx::Rect(point.x(), point.y(), 0, 0),
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
+ views::MenuRunner::MENU_DELETED) {
+ return;
+ }
+}
+
// MediaGalleriesDialogViewsController -----------------------------------------
// static
« no previous file with comments | « chrome/browser/ui/views/extensions/media_galleries_dialog_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698