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 "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 9 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return; | 129 return; |
130 | 130 |
131 DCHECK(min_size.width() <= max_size.width()); | 131 DCHECK(min_size.width() <= max_size.width()); |
132 DCHECK(min_size.height() <= max_size.height()); | 132 DCHECK(min_size.height() <= max_size.height()); |
133 min_size_ = min_size; | 133 min_size_ = min_size; |
134 max_size_ = max_size; | 134 max_size_ = max_size; |
135 | 135 |
136 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 136 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
137 } | 137 } |
138 | 138 |
139 void Panel::ClampSize(gfx::Size* size) const { | 139 gfx::Size Panel::ClampSize(const gfx::Size& size) const { |
140 | 140 |
141 // The panel width: | 141 // The panel width: |
142 // * cannot grow or shrink to go beyond [min_width, max_width] | 142 // * cannot grow or shrink to go beyond [min_width, max_width] |
143 int new_width = size->width(); | 143 int new_width = size.width(); |
144 if (new_width > max_size_.width()) | 144 if (new_width > max_size_.width()) |
145 new_width = max_size_.width(); | 145 new_width = max_size_.width(); |
146 if (new_width < min_size_.width()) | 146 if (new_width < min_size_.width()) |
147 new_width = min_size_.width(); | 147 new_width = min_size_.width(); |
148 | 148 |
149 // The panel height: | 149 // The panel height: |
150 // * cannot grow or shrink to go beyond [min_height, max_height] | 150 // * cannot grow or shrink to go beyond [min_height, max_height] |
151 int new_height = size->height(); | 151 int new_height = size.height(); |
152 if (new_height > max_size_.height()) | 152 if (new_height > max_size_.height()) |
153 new_height = max_size_.height(); | 153 new_height = max_size_.height(); |
154 if (new_height < min_size_.height()) | 154 if (new_height < min_size_.height()) |
155 new_height = min_size_.height(); | 155 new_height = min_size_.height(); |
156 | 156 |
157 size->SetSize(new_width, new_height); | 157 return gfx::Size(new_width, new_height); |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 void Panel::SetAppIconVisibility(bool visible) { | 161 void Panel::SetAppIconVisibility(bool visible) { |
162 native_panel_->SetPanelAppIconVisibility(visible); | 162 native_panel_->SetPanelAppIconVisibility(visible); |
163 } | 163 } |
164 | 164 |
165 void Panel::SetAlwaysOnTop(bool on_top) { | 165 void Panel::SetAlwaysOnTop(bool on_top) { |
166 if (always_on_top_ == on_top) | 166 if (always_on_top_ == on_top) |
167 return; | 167 return; |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 763 |
764 if (modifier == panel::APPLY_TO_ALL) | 764 if (modifier == panel::APPLY_TO_ALL) |
765 panel_strip_->RestoreAll(); | 765 panel_strip_->RestoreAll(); |
766 else | 766 else |
767 Restore(); | 767 Restore(); |
768 } | 768 } |
769 | 769 |
770 void Panel::DestroyBrowser() { | 770 void Panel::DestroyBrowser() { |
771 native_panel_->DestroyPanelBrowser(); | 771 native_panel_->DestroyPanelBrowser(); |
772 } | 772 } |
OLD | NEW |