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" |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 11 #include "chrome/browser/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/panels/native_panel.h" | 13 #include "chrome/browser/ui/panels/native_panel.h" |
14 #include "chrome/browser/ui/panels/panel_drag_controller.h" | |
14 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
15 #include "chrome/browser/ui/panels/panel_strip.h" | 16 #include "chrome/browser/ui/panels/panel_strip.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/browser/ui/window_sizer.h" | 18 #include "chrome/browser/ui/window_sizer.h" |
18 #include "chrome/browser/web_applications/web_app.h" | 19 #include "chrome/browser/web_applications/web_app.h" |
19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
21 #include "content/browser/renderer_host/render_view_host.h" | 22 #include "content/browser/renderer_host/render_view_host.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
42 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false); | 43 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false); |
43 } | 44 } |
44 | 45 |
45 Panel::Panel(Browser* browser, const gfx::Size& requested_size) | 46 Panel::Panel(Browser* browser, const gfx::Size& requested_size) |
46 : browser_(browser), | 47 : browser_(browser), |
47 panel_strip_(NULL), | 48 panel_strip_(NULL), |
48 initialized_(false), | 49 initialized_(false), |
49 has_temporary_layout_(false), | 50 has_temporary_layout_(false), |
50 restored_size_(requested_size), | 51 restored_size_(requested_size), |
51 auto_resizable_(false), | 52 auto_resizable_(false), |
52 draggable_(true), | |
53 expansion_state_(EXPANDED), | 53 expansion_state_(EXPANDED), |
54 old_expansion_state_(EXPANDED), | 54 old_expansion_state_(EXPANDED), |
55 app_icon_visible_(true) { | 55 app_icon_visible_(true) { |
56 } | 56 } |
57 | 57 |
58 Panel::~Panel() { | 58 Panel::~Panel() { |
59 // Invoked by native panel destructor. Do not access native_panel_ here. | 59 // Invoked by native panel destructor. Do not access native_panel_ here. |
60 } | 60 } |
61 | 61 |
62 void Panel::Initialize(const gfx::Rect& bounds) { | 62 void Panel::Initialize(const gfx::Rect& bounds) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 } | 198 } |
199 | 199 |
200 void Panel::SetBounds(const gfx::Rect& bounds) { | 200 void Panel::SetBounds(const gfx::Rect& bounds) { |
201 // Ignore bounds position as the panel manager controls all positioning. | 201 // Ignore bounds position as the panel manager controls all positioning. |
202 manager()->ResizePanel(this, bounds.size()); | 202 manager()->ResizePanel(this, bounds.size()); |
203 } | 203 } |
204 | 204 |
205 // Close() may be called multiple times if the browser window is not ready to | 205 // Close() may be called multiple times if the browser window is not ready to |
206 // close on the first attempt. | 206 // close on the first attempt. |
207 void Panel::Close() { | 207 void Panel::Close() { |
208 native_panel_->ClosePanel(); | 208 if (manager()->drag_controller()->CanRemovePanel(this)) |
jennb
2012/02/17 21:28:45
Continue as normal with close here. When panelmang
jianli
2012/02/17 23:52:56
Per discussion, removed.
| |
209 native_panel_->ClosePanel(); | |
209 } | 210 } |
210 | 211 |
211 void Panel::Activate() { | 212 void Panel::Activate() { |
212 panel_strip_->ActivatePanel(this); | 213 panel_strip_->ActivatePanel(this); |
213 native_panel_->ActivatePanel(); | 214 native_panel_->ActivatePanel(); |
214 } | 215 } |
215 | 216 |
216 void Panel::Deactivate() { | 217 void Panel::Deactivate() { |
217 native_panel_->DeactivatePanel(); | 218 native_panel_->DeactivatePanel(); |
218 } | 219 } |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 native_panel_->ContentSizeFromWindowSize(max_size_)); | 678 native_panel_->ContentSizeFromWindowSize(max_size_)); |
678 } | 679 } |
679 | 680 |
680 void Panel::OnWindowSizeAvailable() { | 681 void Panel::OnWindowSizeAvailable() { |
681 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 682 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
682 } | 683 } |
683 | 684 |
684 void Panel::DestroyBrowser() { | 685 void Panel::DestroyBrowser() { |
685 native_panel_->DestroyPanelBrowser(); | 686 native_panel_->DestroyPanelBrowser(); |
686 } | 687 } |
OLD | NEW |