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/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 "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
14 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
15 | 15 |
16 #if defined(OS_CHROMEOS) | |
17 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
18 #endif | |
19 | |
16 ChromeLauncherAppMenuItemBrowser::ChromeLauncherAppMenuItemBrowser( | 20 ChromeLauncherAppMenuItemBrowser::ChromeLauncherAppMenuItemBrowser( |
17 const base::string16 title, | 21 const base::string16 title, |
18 const gfx::Image* icon, | 22 const gfx::Image* icon, |
19 Browser* browser, | 23 Browser* browser, |
20 bool has_leading_separator) | 24 bool has_leading_separator) |
21 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator), | 25 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator), |
22 browser_(browser) { | 26 browser_(browser) { |
23 DCHECK(browser); | 27 DCHECK(browser); |
24 registrar_.Add(this, | 28 registrar_.Add(this, |
25 chrome::NOTIFICATION_BROWSER_CLOSING, | 29 chrome::NOTIFICATION_BROWSER_CLOSING, |
26 content::Source<Browser>(browser)); | 30 content::Source<Browser>(browser)); |
27 } | 31 } |
28 ChromeLauncherAppMenuItemBrowser::~ChromeLauncherAppMenuItemBrowser() { | 32 ChromeLauncherAppMenuItemBrowser::~ChromeLauncherAppMenuItemBrowser() { |
29 } | 33 } |
30 | 34 |
31 bool ChromeLauncherAppMenuItemBrowser::IsActive() const { | 35 bool ChromeLauncherAppMenuItemBrowser::IsActive() const { |
32 return browser_ == chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); | 36 return browser_ == chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()); |
33 } | 37 } |
34 | 38 |
35 bool ChromeLauncherAppMenuItemBrowser::IsEnabled() const { | 39 bool ChromeLauncherAppMenuItemBrowser::IsEnabled() const { |
36 return true; | 40 return true; |
37 } | 41 } |
38 | 42 |
39 void ChromeLauncherAppMenuItemBrowser::Execute(int event_flags) { | 43 void ChromeLauncherAppMenuItemBrowser::Execute(int event_flags) { |
40 if (browser_) { | 44 if (browser_) { |
41 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { | 45 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { |
42 TabStripModel* tab_strip = browser_->tab_strip_model(); | 46 TabStripModel* tab_strip = browser_->tab_strip_model(); |
43 tab_strip->CloseAllTabs(); | 47 tab_strip->CloseAllTabs(); |
44 } else { | 48 } else { |
49 #if defined(OS_CHROMEOS) | |
50 // In ChromeOS multiprofile scenario we might need to teleport the window | |
51 // back to the current user desktop. | |
52 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | |
53 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | |
Mr4D (OOO till 08-26)
2015/05/03 19:53:44
Since this is the same code as in the other cc mod
xdai1
2015/05/04 16:54:56
Found an existing function... Used it instead.
| |
54 aura::Window* window = browser_->window()->GetNativeWindow(); | |
55 chrome::MultiUserWindowManager* window_manager = | |
56 chrome::MultiUserWindowManager::GetInstance(); | |
57 if (!window_manager->IsWindowOnDesktopOfUser( | |
58 window, window_manager->GetWindowOwner(window))) | |
Mr4D (OOO till 08-26)
2015/05/03 19:53:44
same here
| |
59 window_manager->ShowWindowForUser( | |
60 window, window_manager->GetWindowOwner(window)); | |
61 } | |
62 #endif | |
45 browser_->window()->Show(); | 63 browser_->window()->Show(); |
46 ash::wm::ActivateWindow(browser_->window()->GetNativeWindow()); | 64 ash::wm::ActivateWindow(browser_->window()->GetNativeWindow()); |
47 } | 65 } |
48 } | 66 } |
49 } | 67 } |
50 | 68 |
51 void ChromeLauncherAppMenuItemBrowser::Observe( | 69 void ChromeLauncherAppMenuItemBrowser::Observe( |
52 int type, | 70 int type, |
53 const content::NotificationSource& source, | 71 const content::NotificationSource& source, |
54 const content::NotificationDetails& details) { | 72 const content::NotificationDetails& details) { |
55 switch (type) { | 73 switch (type) { |
56 case chrome::NOTIFICATION_BROWSER_CLOSING: | 74 case chrome::NOTIFICATION_BROWSER_CLOSING: |
57 DCHECK_EQ(browser_, content::Source<Browser>(source).ptr()); | 75 DCHECK_EQ(browser_, content::Source<Browser>(source).ptr()); |
58 browser_ = NULL; | 76 browser_ = NULL; |
59 break; | 77 break; |
60 | 78 |
61 default: | 79 default: |
62 NOTREACHED(); | 80 NOTREACHED(); |
63 } | 81 } |
64 } | 82 } |
OLD | NEW |