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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.cc

Issue 2671923002: mash: Cleanup ash shelf application menu code. (Closed)
Patch Set: Fix tests; cleanup. Created 3 years, 10 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
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/ash/launcher/chrome_launcher_app_menu_item_tab.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
6 6
7 #include "ash/wm/window_util.h" 7 #include "ash/wm/window_util.h"
8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
14 14
15 ChromeLauncherAppMenuItemTab::ChromeLauncherAppMenuItemTab( 15 ChromeLauncherAppMenuItemTab::ChromeLauncherAppMenuItemTab(
16 const base::string16 title, 16 const base::string16 title,
17 const gfx::Image* icon, 17 const gfx::Image* icon,
18 content::WebContents* content, 18 content::WebContents* content)
19 bool has_leading_separator) 19 : ash::ShelfApplicationMenuItem(title, icon),
20 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator), 20 content::WebContentsObserver(content) {}
21 content::WebContentsObserver(content) {
22 }
23
24 bool ChromeLauncherAppMenuItemTab::IsEnabled() const {
25 return true;
26 }
27 21
28 void ChromeLauncherAppMenuItemTab::Execute(int event_flags) { 22 void ChromeLauncherAppMenuItemTab::Execute(int event_flags) {
29 if (!web_contents()) 23 if (!web_contents())
30 return; 24 return;
31 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 25 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
32 if (!browser) 26 if (!browser)
33 return; 27 return;
34 TabStripModel* tab_strip = browser->tab_strip_model(); 28 TabStripModel* tab_strip = browser->tab_strip_model();
35 int index = tab_strip->GetIndexOfWebContents(web_contents()); 29 int index = tab_strip->GetIndexOfWebContents(web_contents());
36 DCHECK_NE(index, TabStripModel::kNoTab); 30 DCHECK_NE(index, TabStripModel::kNoTab);
37 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { 31 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) {
38 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_USER_GESTURE); 32 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_USER_GESTURE);
39 } else { 33 } else {
40 // In ChromeOS multiprofile scenario we might need to teleport the window 34 // In ChromeOS multiprofile scenario we might need to teleport the window
41 // back to the current user desktop. 35 // back to the current user desktop.
42 multi_user_util::MoveWindowToCurrentDesktop( 36 multi_user_util::MoveWindowToCurrentDesktop(
43 browser->window()->GetNativeWindow()); 37 browser->window()->GetNativeWindow());
44 tab_strip->ActivateTabAt(index, false); 38 tab_strip->ActivateTabAt(index, false);
45 browser->window()->Show(); 39 browser->window()->Show();
46 // Need this check to prevent unit tests from crashing. 40 // Need this check to prevent unit tests from crashing.
47 if (browser->window()->GetNativeWindow()) 41 if (browser->window()->GetNativeWindow())
48 ash::wm::ActivateWindow(browser->window()->GetNativeWindow()); 42 ash::wm::ActivateWindow(browser->window()->GetNativeWindow());
49 } 43 }
50 } 44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698