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 d7e2260fb5bbad400fe654284008384e5dd4c8d0..c33bc00f6dfdbf0de6fe68d739d1cdc9aa8afe95 100644 |
--- a/chrome/browser/ui/panels/panel_manager.cc |
+++ b/chrome/browser/ui/panels/panel_manager.cc |
@@ -10,7 +10,6 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop.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" |
@@ -39,8 +38,6 @@ const int kPanelStripRightMargin = 24; |
// Height of panel strip is based on the factor of the working area. |
const double kPanelStripHeightFactor = 0.5; |
-const int kFullScreenModeCheckIntervalMs = 1000; |
- |
// New panels that cannot fit in the panel strip are moved to overflow |
// after a brief delay. |
const int kMoveNewPanelToOverflowDelayMs = 1500; // arbitrary |
@@ -86,12 +83,11 @@ 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_->AddDisplayAreaObserver(this); |
detached_strip_.reset(new DetachedPanelStrip(this)); |
docked_strip_.reset(new DockedPanelStrip(this)); |
@@ -101,6 +97,12 @@ PanelManager::PanelManager() |
} |
PanelManager::~PanelManager() { |
+ display_settings_provider_->RemoveDisplayAreaObserver(this); |
+ |
+ // Docked strip should be disposed explicitly before DisplaySettingsProvider |
+ // is gone since docked strip needs to remove the observer from |
+ // DisplaySettingsProvider. |
+ docked_strip_.reset(); |
} |
void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) { |
@@ -119,6 +121,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. |
@@ -140,26 +147,16 @@ 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_->AddFullScreenObserver(this); |
} |
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_->RemoveFullScreenObserver(this); |
+ } |
drag_controller_->OnPanelClosed(panel); |
resize_controller_->OnPanelClosed(panel); |