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

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

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

Powered by Google App Engine
This is Rietveld 408576698