| 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" | |
| 9 #include "chrome/browser/extensions/extension_service.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
| 12 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/panels/native_panel.h" | 11 #include "chrome/browser/ui/panels/native_panel.h" |
| 14 #include "chrome/browser/ui/panels/panel_manager.h" | 12 #include "chrome/browser/ui/panels/panel_manager.h" |
| 15 #include "chrome/browser/ui/panels/panel_strip.h" | 13 #include "chrome/browser/ui/panels/panel_strip.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/browser/ui/window_sizer.h" | 15 #include "chrome/browser/ui/window_sizer.h" |
| 18 #include "chrome/browser/web_applications/web_app.h" | |
| 19 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/extension.h" | |
| 21 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 23 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 26 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 27 | 23 |
| 28 #if defined(USE_AURA) | 24 #if defined(USE_AURA) |
| 29 #include "chrome/browser/ui/panels/panel_browser_view.h" | 25 #include "chrome/browser/ui/panels/panel_browser_view.h" |
| 30 #endif | 26 #endif |
| 31 | 27 |
| 32 using content::RenderViewHost; | 28 using content::RenderViewHost; |
| 33 using content::SSLStatus; | 29 using content::SSLStatus; |
| 34 using content::WebContents; | 30 using content::WebContents; |
| 35 | 31 |
| 36 // static | |
| 37 const Extension* Panel::GetExtensionFromBrowser(Browser* browser) { | |
| 38 // Find the extension. When we create a panel from an extension, the extension | |
| 39 // ID is passed as the app name to the Browser. | |
| 40 ExtensionService* extension_service = | |
| 41 browser->GetProfile()->GetExtensionService(); | |
| 42 return extension_service->GetExtensionById( | |
| 43 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false); | |
| 44 } | |
| 45 | |
| 46 Panel::Panel(Browser* browser, const gfx::Size& requested_size) | 32 Panel::Panel(Browser* browser, const gfx::Size& requested_size) |
| 47 : browser_(browser), | 33 : browser_(browser), |
| 48 panel_strip_(NULL), | 34 panel_strip_(NULL), |
| 49 initialized_(false), | 35 initialized_(false), |
| 50 has_temporary_layout_(false), | 36 has_temporary_layout_(false), |
| 51 restored_size_(requested_size), | 37 restored_size_(requested_size), |
| 52 auto_resizable_(false), | 38 auto_resizable_(false), |
| 53 always_on_top_(false), | 39 always_on_top_(false), |
| 54 in_preview_mode_(false), | 40 in_preview_mode_(false), |
| 55 native_panel_(NULL), | 41 native_panel_(NULL), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 return panel_strip_ && panel_strip_->CanDragPanel(this); | 71 return panel_strip_ && panel_strip_->CanDragPanel(this); |
| 86 } | 72 } |
| 87 | 73 |
| 88 panel::Resizability Panel::CanResizeByMouse() const { | 74 panel::Resizability Panel::CanResizeByMouse() const { |
| 89 if (!panel_strip_) | 75 if (!panel_strip_) |
| 90 return panel::NOT_RESIZABLE; | 76 return panel::NOT_RESIZABLE; |
| 91 | 77 |
| 92 return panel_strip_->GetPanelResizability(this); | 78 return panel_strip_->GetPanelResizability(this); |
| 93 } | 79 } |
| 94 | 80 |
| 95 const Extension* Panel::GetExtension() const { | |
| 96 return GetExtensionFromBrowser(browser()); | |
| 97 } | |
| 98 | |
| 99 // TODO(jennb): do not update restored_size here as there's no knowledge | 81 // TODO(jennb): do not update restored_size here as there's no knowledge |
| 100 // at this point whether the bounds change is due to the content window | 82 // at this point whether the bounds change is due to the content window |
| 101 // being resized vs a change in current display bounds, e.g. from overflow | 83 // being resized vs a change in current display bounds, e.g. from overflow |
| 102 // size change. Change this when refactoring panel resize logic. | 84 // size change. Change this when refactoring panel resize logic. |
| 103 void Panel::SetPanelBounds(const gfx::Rect& bounds) { | 85 void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
| 104 if (panel_strip_ && panel_strip_->type() == PanelStrip::DOCKED && | 86 if (panel_strip_ && panel_strip_->type() == PanelStrip::DOCKED && |
| 105 expansion_state_ == Panel::EXPANDED) | 87 expansion_state_ == Panel::EXPANDED) |
| 106 restored_size_ = bounds.size(); | 88 restored_size_ = bounds.size(); |
| 107 | 89 |
| 108 native_panel_->SetPanelBounds(bounds); | 90 native_panel_->SetPanelBounds(bounds); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 731 } |
| 750 | 732 |
| 751 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { | 733 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { |
| 752 if (panel_strip_) | 734 if (panel_strip_) |
| 753 panel_strip_->OnPanelTitlebarClicked(this, modifier); | 735 panel_strip_->OnPanelTitlebarClicked(this, modifier); |
| 754 } | 736 } |
| 755 | 737 |
| 756 void Panel::DestroyBrowser() { | 738 void Panel::DestroyBrowser() { |
| 757 native_panel_->DestroyPanelBrowser(); | 739 native_panel_->DestroyPanelBrowser(); |
| 758 } | 740 } |
| OLD | NEW |