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/ash/launcher/chrome_launcher_app_menu_item_browser.h
" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" |
6 | 6 |
7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
15 | 16 |
16 ChromeLauncherAppMenuItemBrowser::ChromeLauncherAppMenuItemBrowser( | 17 ChromeLauncherAppMenuItemBrowser::ChromeLauncherAppMenuItemBrowser( |
17 const base::string16 title, | 18 const base::string16 title, |
18 const gfx::Image* icon, | 19 const gfx::Image* icon, |
(...skipping 16 matching lines...) Expand all Loading... |
35 bool ChromeLauncherAppMenuItemBrowser::IsEnabled() const { | 36 bool ChromeLauncherAppMenuItemBrowser::IsEnabled() const { |
36 return true; | 37 return true; |
37 } | 38 } |
38 | 39 |
39 void ChromeLauncherAppMenuItemBrowser::Execute(int event_flags) { | 40 void ChromeLauncherAppMenuItemBrowser::Execute(int event_flags) { |
40 if (browser_) { | 41 if (browser_) { |
41 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { | 42 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { |
42 TabStripModel* tab_strip = browser_->tab_strip_model(); | 43 TabStripModel* tab_strip = browser_->tab_strip_model(); |
43 tab_strip->CloseAllTabs(); | 44 tab_strip->CloseAllTabs(); |
44 } else { | 45 } else { |
| 46 // In ChromeOS multiprofile scenario we might need to teleport the window |
| 47 // back to the current user desktop. |
| 48 multi_user_util::MoveWindowToCurrentDesktop( |
| 49 browser_->window()->GetNativeWindow()); |
45 browser_->window()->Show(); | 50 browser_->window()->Show(); |
46 ash::wm::ActivateWindow(browser_->window()->GetNativeWindow()); | 51 ash::wm::ActivateWindow(browser_->window()->GetNativeWindow()); |
47 } | 52 } |
48 } | 53 } |
49 } | 54 } |
50 | 55 |
51 void ChromeLauncherAppMenuItemBrowser::Observe( | 56 void ChromeLauncherAppMenuItemBrowser::Observe( |
52 int type, | 57 int type, |
53 const content::NotificationSource& source, | 58 const content::NotificationSource& source, |
54 const content::NotificationDetails& details) { | 59 const content::NotificationDetails& details) { |
55 switch (type) { | 60 switch (type) { |
56 case chrome::NOTIFICATION_BROWSER_CLOSING: | 61 case chrome::NOTIFICATION_BROWSER_CLOSING: |
57 DCHECK_EQ(browser_, content::Source<Browser>(source).ptr()); | 62 DCHECK_EQ(browser_, content::Source<Browser>(source).ptr()); |
58 browser_ = NULL; | 63 browser_ = NULL; |
59 break; | 64 break; |
60 | 65 |
61 default: | 66 default: |
62 NOTREACHED(); | 67 NOTREACHED(); |
63 } | 68 } |
64 } | 69 } |
OLD | NEW |