Index: chrome/browser/ui/panels/panel.cc |
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc |
index ed3cca0caf6c3ced9b9b3d28217a608c968b1d5b..b1bfafaf9e284b05beed6ef685968e94180e2642 100644 |
--- a/chrome/browser/ui/panels/panel.cc |
+++ b/chrome/browser/ui/panels/panel.cc |
@@ -48,8 +48,8 @@ Panel::Panel(Browser* browser, const gfx::Size& requested_size) |
restored_size_(requested_size), |
auto_resizable_(false), |
draggable_(true), |
+ layout_state_(DOCKED), |
expansion_state_(EXPANDED), |
- old_expansion_state_(EXPANDED), |
app_icon_visible_(true) { |
} |
@@ -79,7 +79,7 @@ const Extension* Panel::GetExtension() const { |
} |
void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
- if (expansion_state_ == Panel::EXPANDED) |
+ if (layout_state_ != IN_OVERFLOW && expansion_state_ == EXPANDED) |
restored_size_ = bounds.size(); |
native_panel_->SetPanelBounds(bounds); |
@@ -91,7 +91,7 @@ void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
} |
void Panel::SetPanelBoundsInstantly(const gfx::Rect& bounds) { |
- if (expansion_state_ == Panel::EXPANDED) |
+ if (layout_state_ != IN_OVERFLOW && expansion_state_ == EXPANDED) |
restored_size_ = bounds.size(); |
native_panel_->SetPanelBoundsInstantly(bounds); |
@@ -137,16 +137,32 @@ void Panel::SetAppIconVisibility(bool visible) { |
native_panel_->SetPanelAppIconVisibility(visible); |
} |
+void Panel::SetLayoutState(LayoutState new_state) { |
+ if (layout_state_ == new_state) |
+ return; |
+ LayoutState old_state = layout_state_; |
+ layout_state_ = new_state; |
+ |
+ manager()->OnPanelLayoutStateChanged(this, old_state); |
+ |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_STATE, |
+ content::Source<Panel>(this), |
+ content::NotificationService::NoDetails()); |
+} |
+ |
void Panel::SetExpansionState(ExpansionState new_state) { |
+ DCHECK_EQ(DOCKED, layout_state_); |
+ |
if (expansion_state_ == new_state) |
return; |
- old_expansion_state_ = expansion_state_; |
+ ExpansionState old_state = expansion_state_; |
expansion_state_ = new_state; |
- manager()->OnPanelExpansionStateChanged(this); |
+ manager()->OnPanelExpansionStateChanged(this, old_state); |
// The minimized panel should not get the focus. |
- if (expansion_state_ == MINIMIZED) |
+ if (expansion_state_ == MINIMIZED && layout_state_ == DOCKED) |
Deactivate(); |
content::NotificationService::current()->Notify( |
@@ -165,7 +181,7 @@ void Panel::FullScreenModeChanged(bool is_full_screen) { |
void Panel::Show() { |
// Don't show panel as active if it is in overflow state. |
- if (expansion_state_ == IN_OVERFLOW) |
+ if (layout_state_ == IN_OVERFLOW) |
ShowInactive(); |
else |
native_panel_->ShowPanel(); |
@@ -189,6 +205,7 @@ void Panel::Close() { |
void Panel::Activate() { |
// Make sure the panel is expanded when activated programmatically, |
// so the user input does not go into collapsed window. |
+ SetLayoutState(Panel::DOCKED); |
SetExpansionState(Panel::EXPANDED); |
native_panel_->ActivatePanel(); |
} |