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.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 void Panel::Initialize(const gfx::Rect& bounds) { | 61 void Panel::Initialize(const gfx::Rect& bounds) { |
62 DCHECK(!initialized_); | 62 DCHECK(!initialized_); |
63 DCHECK(!bounds.IsEmpty()); | 63 DCHECK(!bounds.IsEmpty()); |
64 initialized_ = true; | 64 initialized_ = true; |
65 native_panel_ = CreateNativePanel(browser_, this, bounds); | 65 native_panel_ = CreateNativePanel(browser_, this, bounds); |
66 } | 66 } |
67 | 67 |
68 void Panel::OnNativePanelClosed() { | 68 void Panel::OnNativePanelClosed() { |
69 if (auto_resizable_) | 69 if (auto_resizable_) |
70 native_panel_->GetPanelBrowser()->tabstrip_model()->RemoveObserver(this); | 70 native_panel_->GetPanelBrowser()->tabstrip_model()->RemoveObserver(this); |
71 panel_strip_->RemovePanel(this); | |
72 manager()->OnPanelClosed(this); | 71 manager()->OnPanelClosed(this); |
73 } | 72 } |
74 | 73 |
75 PanelManager* Panel::manager() const { | 74 PanelManager* Panel::manager() const { |
76 return PanelManager::GetInstance(); | 75 return PanelManager::GetInstance(); |
77 } | 76 } |
78 | 77 |
79 bool Panel::draggable() const { | 78 bool Panel::draggable() const { |
80 return panel_strip()->CanDragPanel(this); | 79 return panel_strip_->CanDragPanel(this); |
81 } | 80 } |
82 | 81 |
83 const Extension* Panel::GetExtension() const { | 82 const Extension* Panel::GetExtension() const { |
84 return GetExtensionFromBrowser(browser()); | 83 return GetExtensionFromBrowser(browser()); |
85 } | 84 } |
86 | 85 |
87 // TODO(jennb): do not update restored_size here as there's no knowledge | 86 // TODO(jennb): do not update restored_size here as there's no knowledge |
88 // at this point whether the bounds change is due to the content window | 87 // at this point whether the bounds change is due to the content window |
89 // being resized vs a change in current display bounds, e.g. from overflow | 88 // being resized vs a change in current display bounds, e.g. from overflow |
90 // size change. Change this when refactoring panel resize logic. | 89 // size change. Change this when refactoring panel resize logic. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 141 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
143 } | 142 } |
144 | 143 |
145 void Panel::SetAppIconVisibility(bool visible) { | 144 void Panel::SetAppIconVisibility(bool visible) { |
146 if (app_icon_visible_ == visible) | 145 if (app_icon_visible_ == visible) |
147 return; | 146 return; |
148 app_icon_visible_ = visible; | 147 app_icon_visible_ = visible; |
149 native_panel_->SetPanelAppIconVisibility(visible); | 148 native_panel_->SetPanelAppIconVisibility(visible); |
150 } | 149 } |
151 | 150 |
152 void Panel::MoveToStrip(PanelStrip* new_strip) { | 151 void Panel::SetPanelStrip(PanelStrip* new_strip) { |
Andrei
2012/03/01 00:08:50
Yes!!!
| |
153 DCHECK_NE(panel_strip_, new_strip); | |
154 if (panel_strip_) | |
155 panel_strip_->RemovePanel(this); | |
156 | |
157 panel_strip_ = new_strip; | 152 panel_strip_ = new_strip; |
158 panel_strip_->AddPanel(this); | |
159 | |
160 content::NotificationService::current()->Notify( | |
161 chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE, | |
162 content::Source<Panel>(this), | |
163 content::NotificationService::NoDetails()); | |
164 } | 153 } |
165 | 154 |
166 void Panel::SetExpansionState(ExpansionState new_state) { | 155 void Panel::SetExpansionState(ExpansionState new_state) { |
167 if (expansion_state_ == new_state) | 156 if (expansion_state_ == new_state) |
168 return; | 157 return; |
169 old_expansion_state_ = expansion_state_; | 158 old_expansion_state_ = expansion_state_; |
170 expansion_state_ = new_state; | 159 expansion_state_ = new_state; |
171 | 160 |
172 manager()->OnPanelExpansionStateChanged(this); | 161 manager()->OnPanelExpansionStateChanged(this); |
173 | 162 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 native_panel_->ContentSizeFromWindowSize(max_size_)); | 674 native_panel_->ContentSizeFromWindowSize(max_size_)); |
686 } | 675 } |
687 | 676 |
688 void Panel::OnWindowSizeAvailable() { | 677 void Panel::OnWindowSizeAvailable() { |
689 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 678 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
690 } | 679 } |
691 | 680 |
692 void Panel::DestroyBrowser() { | 681 void Panel::DestroyBrowser() { |
693 native_panel_->DestroyPanelBrowser(); | 682 native_panel_->DestroyPanelBrowser(); |
694 } | 683 } |
OLD | NEW |