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

Side by Side Diff: chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tabs/browser_tab_strip_controller.h" 5 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 virtual ~TabContextMenuContents() { 89 virtual ~TabContextMenuContents() {
90 if (controller_) 90 if (controller_)
91 controller_->tabstrip_->StopAllHighlighting(); 91 controller_->tabstrip_->StopAllHighlighting();
92 } 92 }
93 93
94 void Cancel() { 94 void Cancel() {
95 controller_ = NULL; 95 controller_ = NULL;
96 } 96 }
97 97
98 void RunMenuAt(const gfx::Point& point) { 98 void RunMenuAt(const gfx::Point& point, ui::MenuSourceType source_type) {
99 if (menu_runner_->RunMenuAt( 99 if (menu_runner_->RunMenuAt(
100 tab_->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 100 tab_->GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
101 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS | 101 views::MenuItemView::TOPLEFT, source_type,
102 views::MenuRunner::HAS_MNEMONICS |
102 views::MenuRunner::CONTEXT_MENU) == 103 views::MenuRunner::CONTEXT_MENU) ==
103 views::MenuRunner::MENU_DELETED) 104 views::MenuRunner::MENU_DELETED)
104 return; 105 return;
105 } 106 }
106 107
107 // Overridden from ui::SimpleMenuModel::Delegate: 108 // Overridden from ui::SimpleMenuModel::Delegate:
108 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { 109 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE {
109 return false; 110 return false;
110 } 111 }
111 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { 112 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 CloseTabSource source) { 273 CloseTabSource source) {
273 // Cancel any pending tab transition. 274 // Cancel any pending tab transition.
274 hover_tab_selector_.CancelTabTransition(); 275 hover_tab_selector_.CancelTabTransition();
275 276
276 tabstrip_->PrepareForCloseAt(model_index, source); 277 tabstrip_->PrepareForCloseAt(model_index, source);
277 model_->CloseWebContentsAt(model_index, 278 model_->CloseWebContentsAt(model_index,
278 TabStripModel::CLOSE_USER_GESTURE | 279 TabStripModel::CLOSE_USER_GESTURE |
279 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); 280 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
280 } 281 }
281 282
282 void BrowserTabStripController::ShowContextMenuForTab(Tab* tab, 283 void BrowserTabStripController::ShowContextMenuForTab(
283 const gfx::Point& p) { 284 Tab* tab,
285 const gfx::Point& p,
286 ui::MenuSourceType source_type) {
284 context_menu_contents_.reset(new TabContextMenuContents(tab, this)); 287 context_menu_contents_.reset(new TabContextMenuContents(tab, this));
285 context_menu_contents_->RunMenuAt(p); 288 context_menu_contents_->RunMenuAt(p, source_type);
286 } 289 }
287 290
288 void BrowserTabStripController::UpdateLoadingAnimations() { 291 void BrowserTabStripController::UpdateLoadingAnimations() {
289 // Don't use the model count here as it's possible for this to be invoked 292 // Don't use the model count here as it's possible for this to be invoked
290 // before we've applied an update from the model (Browser::TabInsertedAt may 293 // before we've applied an update from the model (Browser::TabInsertedAt may
291 // be processed before us and invokes this). 294 // be processed before us and invokes this).
292 for (int i = 0, tab_count = tabstrip_->tab_count(); i < tab_count; ++i) { 295 for (int i = 0, tab_count = tabstrip_->tab_count(); i < tab_count; ++i) {
293 if (model_->ContainsIndex(i)) { 296 if (model_->ContainsIndex(i)) {
294 Tab* tab = tabstrip_->tab_at(i); 297 Tab* tab = tabstrip_->tab_at(i);
295 WebContents* contents = model_->GetWebContentsAt(i); 298 WebContents* contents = model_->GetWebContentsAt(i);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); 524 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB);
522 tabstrip_->AddTabAt(index, data, is_active); 525 tabstrip_->AddTabAt(index, data, is_active);
523 } 526 }
524 527
525 void BrowserTabStripController::UpdateLayoutType() { 528 void BrowserTabStripController::UpdateLayoutType() {
526 bool adjust_layout = false; 529 bool adjust_layout = false;
527 TabStripLayoutType layout_type = 530 TabStripLayoutType layout_type =
528 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); 531 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout);
529 tabstrip_->SetLayoutType(layout_type, adjust_layout); 532 tabstrip_->SetLayoutType(layout_type, adjust_layout);
530 } 533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698