Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_manager.cc |
| diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc |
| index f41baf98dd22032a2041a4068f3604b23737efe7..9bce3bab35ca84630a7582e6f90708e6a4bed0df 100644 |
| --- a/chrome/browser/ui/panels/panel_manager.cc |
| +++ b/chrome/browser/ui/panels/panel_manager.cc |
| @@ -8,7 +8,6 @@ |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "chrome/browser/fullscreen.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/panels/detached_panel_strip.h" |
| @@ -36,9 +35,6 @@ const int kPanelStripRightMargin = 24; |
| // Height of panel strip is based on the factor of the working area. |
| const double kPanelStripHeightFactor = 0.5; |
| - |
| -static const int kFullScreenModeCheckIntervalMs = 1000; |
| - |
| } // namespace |
| // static |
| @@ -81,12 +77,12 @@ bool PanelManager::ShouldUsePanels(const std::string& extension_id) { |
| PanelManager::PanelManager() |
| : panel_mouse_watcher_(PanelMouseWatcher::Create()), |
| auto_sizing_enabled_(true), |
| - is_full_screen_(false), |
| is_processing_overflow_(false) { |
| // DisplaySettingsProvider should be created before the creation of strips |
| // since some strip might depend on it. |
| display_settings_provider_.reset(DisplaySettingsProvider::Create()); |
| - display_settings_provider_->set_display_area_observer(this); |
| + display_settings_provider_->AddObserver( |
| + static_cast<DisplaySettingsProvider::DisplayAreaObserver*>(this)); |
| detached_strip_.reset(new DetachedPanelStrip(this)); |
| docked_strip_.reset(new DockedPanelStrip(this)); |
| @@ -96,6 +92,8 @@ PanelManager::PanelManager() |
| } |
| PanelManager::~PanelManager() { |
| + display_settings_provider_->RemoveObserver( |
| + static_cast<DisplaySettingsProvider::DisplayAreaObserver*>(this)); |
| } |
| void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) { |
| @@ -114,6 +112,11 @@ void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) { |
| overflow_strip_->SetDisplayArea(overflow_area); |
| } |
| +void PanelManager::OnFullScreenModeChanged(bool is_full_screen) { |
| + docked_strip_->OnFullScreenModeChanged(is_full_screen); |
| + overflow_strip_->OnFullScreenModeChanged(is_full_screen); |
| +} |
| + |
| Panel* PanelManager::CreatePanel(Browser* browser) { |
| // Need to sync the display area if no panel is present. This is because: |
| // 1) Display area is not initialized until first panel is created. |
| @@ -135,26 +138,18 @@ Panel* PanelManager::CreatePanel(Browser* browser) { |
| content::NotificationService::NoDetails()); |
| if (num_panels() == 1) { |
| - full_screen_mode_timer_.Start(FROM_HERE, |
| - base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs), |
| - this, &PanelManager::CheckFullScreenMode); |
| + display_settings_provider_->AddObserver( |
| + static_cast<DisplaySettingsProvider::FullScreenObserver*>(this)); |
|
Dmitry Titov
2012/04/12 00:08:51
These casts will also go away if observers are not
jianli
2012/04/12 00:45:17
Done.
|
| } |
| return panel; |
| } |
| -void PanelManager::CheckFullScreenMode() { |
| - bool is_full_screen_new = IsFullScreenMode(); |
| - if (is_full_screen_ == is_full_screen_new) |
| - return; |
| - is_full_screen_ = is_full_screen_new; |
| - docked_strip_->OnFullScreenModeChanged(is_full_screen_); |
| - overflow_strip_->OnFullScreenModeChanged(is_full_screen_); |
| -} |
| - |
| void PanelManager::OnPanelClosed(Panel* panel) { |
| - if (num_panels() == 1) |
| - full_screen_mode_timer_.Stop(); |
| + if (num_panels() == 1) { |
| + display_settings_provider_->RemoveObserver( |
| + static_cast<DisplaySettingsProvider::FullScreenObserver*>(this)); |
| + } |
| drag_controller_->OnPanelClosed(panel); |
| resize_controller_->OnPanelClosed(panel); |