Chromium Code Reviews| 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/panels/panel_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/ui/panels/detached_panel_collection.h" | 13 #include "chrome/browser/ui/panels/detached_panel_collection.h" |
| 14 #include "chrome/browser/ui/panels/docked_panel_collection.h" | 14 #include "chrome/browser/ui/panels/docked_panel_collection.h" |
| 15 #include "chrome/browser/ui/panels/panel_drag_controller.h" | 15 #include "chrome/browser/ui/panels/panel_drag_controller.h" |
| 16 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 16 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 17 #include "chrome/browser/ui/panels/panel_resize_controller.h" | 17 #include "chrome/browser/ui/panels/panel_resize_controller.h" |
| 18 #include "chrome/browser/ui/panels/stacked_panel_collection.h" | 18 #include "chrome/browser/ui/panels/stacked_panel_collection.h" |
| 19 #include "chrome/common/channel_info.h" | 19 #include "chrome/common/channel_info.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "components/version_info/version_info.h" | 21 #include "components/version_info/version_info.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
| 24 #include "extensions/common/constants.h" | |
| 24 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
| 25 | 26 |
| 26 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 27 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 27 #include "base/environment.h" | 28 #include "base/environment.h" |
| 28 #include "base/nix/xdg_util.h" | 29 #include "base/nix/xdg_util.h" |
| 29 #include "ui/base/x/x11_util.h" | 30 #include "ui/base/x/x11_util.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 // Maxmium width of a panel is based on a factor of the working area. | 34 // Maxmium width of a panel is based on a factor of the working area. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 } | 98 } |
| 98 | 99 |
| 99 // static | 100 // static |
| 100 void PanelManager::SetDisplaySettingsProviderForTesting( | 101 void PanelManager::SetDisplaySettingsProviderForTesting( |
| 101 DisplaySettingsProvider* provider) { | 102 DisplaySettingsProvider* provider) { |
| 102 display_settings_provider_for_testing = provider; | 103 display_settings_provider_for_testing = provider; |
| 103 } | 104 } |
| 104 | 105 |
| 105 // static | 106 // static |
| 106 bool PanelManager::ShouldUsePanels(const std::string& extension_id) { | 107 bool PanelManager::ShouldUsePanels(const std::string& extension_id) { |
| 107 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 108 // If --enable-panels is on, always use panels. |
| 108 // If --enable-panels is on, always use panels on Linux. | |
| 109 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 109 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 110 switches::kEnablePanels)) | 110 switches::kEnablePanels)) |
| 111 return true; | 111 return true; |
| 112 | 112 |
| 113 // Otherwise, panels are only supported on tested window managers. | 113 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 114 // On Linux, panels are only supported on tested window managers. | |
| 114 ui::WindowManagerName wm_type = ui::GuessWindowManager(); | 115 ui::WindowManagerName wm_type = ui::GuessWindowManager(); |
| 115 if (wm_type != ui::WM_COMPIZ && | 116 if (wm_type != ui::WM_COMPIZ && |
| 116 wm_type != ui::WM_ICE_WM && | 117 wm_type != ui::WM_ICE_WM && |
| 117 wm_type != ui::WM_KWIN && | 118 wm_type != ui::WM_KWIN && |
| 118 wm_type != ui::WM_METACITY && | 119 wm_type != ui::WM_METACITY && |
| 119 wm_type != ui::WM_MUFFIN && | 120 wm_type != ui::WM_MUFFIN && |
| 120 wm_type != ui::WM_MUTTER && | 121 wm_type != ui::WM_MUTTER && |
| 121 wm_type != ui::WM_XFWM4) { | 122 wm_type != ui::WM_XFWM4) { |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 #endif // USE_X11 && !OS_CHROMEOS | 125 #endif // USE_X11 && !OS_CHROMEOS |
| 125 | 126 |
| 126 version_info::Channel channel = chrome::GetChannel(); | 127 // Without --enable-panels, only support Hangouts. |
| 127 if (channel == version_info::Channel::STABLE || | 128 for (const char* id : extension_misc::kHangoutsExtensionIds) { |
| 128 channel == version_info::Channel::BETA) { | 129 if (extension_id == id) |
| 129 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 130 return true; |
|
tapted
2015/09/07 05:30:27
To keep things simple, this would now return true
| |
| 130 switches::kEnablePanels) || | |
| 131 extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd") || | |
| 132 extension_id == std::string("ljclpkphhpbpinifbeabbhlfddcpfdde") || | |
| 133 extension_id == std::string("ppleadejekpmccmnpjdimmlfljlkdfej") || | |
| 134 extension_id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj"); | |
| 135 } | 131 } |
| 136 | 132 |
| 137 return true; | 133 return false; |
| 138 } | 134 } |
| 139 | 135 |
| 140 // static | 136 // static |
| 141 bool PanelManager::IsPanelStackingEnabled() { | 137 bool PanelManager::IsPanelStackingEnabled() { |
| 142 // Stacked panel mode is not supported in linux-aura. | 138 // Stacked panel mode is not supported in linux-aura. |
| 143 #if defined(OS_LINUX) | 139 #if defined(OS_LINUX) |
| 144 return false; | 140 return false; |
| 145 #else | 141 #else |
| 146 return true; | 142 return true; |
| 147 #endif | 143 #endif |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { | 560 void PanelManager::SetMouseWatcher(PanelMouseWatcher* watcher) { |
| 565 panel_mouse_watcher_.reset(watcher); | 561 panel_mouse_watcher_.reset(watcher); |
| 566 } | 562 } |
| 567 | 563 |
| 568 void PanelManager::OnPanelAnimationEnded(Panel* panel) { | 564 void PanelManager::OnPanelAnimationEnded(Panel* panel) { |
| 569 content::NotificationService::current()->Notify( | 565 content::NotificationService::current()->Notify( |
| 570 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 566 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 571 content::Source<Panel>(panel), | 567 content::Source<Panel>(panel), |
| 572 content::NotificationService::NoDetails()); | 568 content::NotificationService::NoDetails()); |
| 573 } | 569 } |
| OLD | NEW |