Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.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_manager.h" | 14 #include "chrome/browser/ui/panels/panel_manager.h" |
| 15 #include "chrome/browser/ui/window_sizer.h" | 15 #include "chrome/browser/ui/window_sizer.h" |
| 16 #include "chrome/browser/web_applications/web_app.h" | 16 #include "chrome/browser/web_applications/web_app.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
| 20 #include "content/public/browser/notification_service.h" | |
| 20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 const Extension* Panel::GetExtensionFromBrowser(Browser* browser) { | 26 const Extension* Panel::GetExtensionFromBrowser(Browser* browser) { |
| 26 // Find the extension. When we create a panel from an extension, the extension | 27 // Find the extension. When we create a panel from an extension, the extension |
| 27 // ID is passed as the app name to the Browser. | 28 // ID is passed as the app name to the Browser. |
| 28 ExtensionService* extension_service = | 29 ExtensionService* extension_service = |
| 29 browser->GetProfile()->GetExtensionService(); | 30 browser->GetProfile()->GetExtensionService(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 gfx::Rect bounds = native_panel_->GetPanelBounds(); | 105 gfx::Rect bounds = native_panel_->GetPanelBounds(); |
| 105 bounds.set_y(bottom - height); | 106 bounds.set_y(bottom - height); |
| 106 bounds.set_height(height); | 107 bounds.set_height(height); |
| 107 SetPanelBounds(bounds); | 108 SetPanelBounds(bounds); |
| 108 | 109 |
| 109 manager()->OnPanelExpansionStateChanged(old_state, new_state); | 110 manager()->OnPanelExpansionStateChanged(old_state, new_state); |
| 110 | 111 |
| 111 // The minimized panel should not get the focus. | 112 // The minimized panel should not get the focus. |
| 112 if (expansion_state_ == MINIMIZED) | 113 if (expansion_state_ == MINIMIZED) |
| 113 Deactivate(); | 114 Deactivate(); |
| 115 | |
| 116 content::NotificationService::current()->Notify( | |
|
jianli
2011/10/28 21:31:33
Probably we do not need this notification since Ru
Dmitry Titov
2011/10/29 00:04:56
Discussed offline. Decided to go with regualr patt
| |
| 117 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | |
| 118 content::Source<Panel>(this), | |
| 119 content::NotificationService::NoDetails()); | |
| 114 } | 120 } |
| 115 | 121 |
| 116 bool Panel::ShouldBringUpTitlebar(int mouse_x, int mouse_y) const { | 122 bool Panel::ShouldBringUpTitlebar(int mouse_x, int mouse_y) const { |
| 117 // Skip the expanded panel. | 123 // Skip the expanded panel. |
| 118 if (expansion_state_ == EXPANDED) | 124 if (expansion_state_ == EXPANDED) |
| 119 return false; | 125 return false; |
| 120 | 126 |
| 121 // If the panel is showing titlebar only, we want to keep it up when it is | 127 // If the panel is showing titlebar only, we want to keep it up when it is |
| 122 // being dragged. | 128 // being dragged. |
| 123 if (expansion_state_ == TITLE_ONLY && manager()->is_dragging_panel()) | 129 if (expansion_state_ == TITLE_ONLY && manager()->is_dragging_panel()) |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 RequestRenderViewHostToDisableScrollbars(GetRenderViewHost()); | 594 RequestRenderViewHostToDisableScrollbars(GetRenderViewHost()); |
| 589 } | 595 } |
| 590 | 596 |
| 591 Browser* Panel::browser() const { | 597 Browser* Panel::browser() const { |
| 592 return native_panel_->GetPanelBrowser(); | 598 return native_panel_->GetPanelBrowser(); |
| 593 } | 599 } |
| 594 | 600 |
| 595 void Panel::DestroyBrowser() { | 601 void Panel::DestroyBrowser() { |
| 596 native_panel_->DestroyPanelBrowser(); | 602 native_panel_->DestroyPanelBrowser(); |
| 597 } | 603 } |
| OLD | NEW |