| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/fullscreen.h" | 10 #include "chrome/browser/fullscreen.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 13 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 13 #include "chrome/browser/ui/panels/panel_overflow_strip.h" | 14 #include "chrome/browser/ui/panels/panel_overflow_strip.h" |
| 14 #include "chrome/browser/ui/panels/panel_strip.h" | 15 #include "chrome/browser/ui/panels/panel_strip.h" |
| 15 #include "chrome/browser/ui/window_sizer.h" | 16 #include "chrome/browser/ui/window_sizer.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/chrome_version_info.h" |
| 17 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 const int kOverflowStripThickness = 24; | 24 const int kOverflowStripThickness = 24; |
| 22 | 25 |
| 23 // Width of spacing around panel strip and the left/right edges of the screen. | 26 // Width of spacing around panel strip and the left/right edges of the screen. |
| 24 const int kPanelStripLeftMargin = kOverflowStripThickness + 6; | 27 const int kPanelStripLeftMargin = kOverflowStripThickness + 6; |
| 25 const int kPanelStripRightMargin = 24; | 28 const int kPanelStripRightMargin = 24; |
| 26 | 29 |
| 27 // Height of panel strip is based on the factor of the working area. | 30 // Height of panel strip is based on the factor of the working area. |
| 28 const double kPanelStripHeightFactor = 0.5; | 31 const double kPanelStripHeightFactor = 0.5; |
| 29 | 32 |
| 30 static const int kFullScreenModeCheckIntervalMs = 1000; | 33 static const int kFullScreenModeCheckIntervalMs = 1000; |
| 31 | 34 |
| 32 } // namespace | 35 } // namespace |
| 33 | 36 |
| 34 // static | 37 // static |
| 35 PanelManager* PanelManager::GetInstance() { | 38 PanelManager* PanelManager::GetInstance() { |
| 36 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; | 39 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; |
| 37 return instance.Pointer(); | 40 return instance.Pointer(); |
| 38 } | 41 } |
| 39 | 42 |
| 43 // static |
| 44 bool PanelManager::ShouldUsePanels(const std::string& id) { |
| 45 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 46 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 47 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 48 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 49 switches::kEnablePanels) || |
| 50 id == std::string("nckgahadagoaajjgafhacjanaoiihapd") || |
| 51 id == std::string("ljclpkphhpbpinifbeabbhlfddcpfdde") || |
| 52 id == std::string("ppleadejekpmccmnpjdimmlfljlkdfej") || |
| 53 id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj"); |
| 54 } |
| 55 |
| 56 return true; |
| 57 } |
| 58 |
| 40 PanelManager::PanelManager() | 59 PanelManager::PanelManager() |
| 41 : panel_mouse_watcher_(PanelMouseWatcher::Create()), | 60 : panel_mouse_watcher_(PanelMouseWatcher::Create()), |
| 42 auto_sizing_enabled_(true), | 61 auto_sizing_enabled_(true), |
| 43 is_full_screen_(false) { | 62 is_full_screen_(false) { |
| 44 panel_strip_.reset(new PanelStrip(this)); | 63 panel_strip_.reset(new PanelStrip(this)); |
| 45 panel_overflow_strip_.reset(new PanelOverflowStrip(this)); | 64 panel_overflow_strip_.reset(new PanelOverflowStrip(this)); |
| 46 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); | 65 auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); |
| 47 OnDisplayChanged(); | 66 OnDisplayChanged(); |
| 48 } | 67 } |
| 49 | 68 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return panel_strip_->num_panels() + panel_overflow_strip_->num_panels(); | 244 return panel_strip_->num_panels() + panel_overflow_strip_->num_panels(); |
| 226 } | 245 } |
| 227 | 246 |
| 228 bool PanelManager::is_dragging_panel() const { | 247 bool PanelManager::is_dragging_panel() const { |
| 229 return panel_strip_->is_dragging_panel(); | 248 return panel_strip_->is_dragging_panel(); |
| 230 } | 249 } |
| 231 | 250 |
| 232 const PanelManager::Panels& PanelManager::panels() const { | 251 const PanelManager::Panels& PanelManager::panels() const { |
| 233 return panel_strip_->panels(); | 252 return panel_strip_->panels(); |
| 234 } | 253 } |
| OLD | NEW |