| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 restored_height_(bounds.height()) { | 40 restored_height_(bounds.height()) { |
| 41 native_panel_ = CreateNativePanel(browser, this, bounds); | 41 native_panel_ = CreateNativePanel(browser, this, bounds); |
| 42 | 42 |
| 43 registrar_.Add(this, | 43 registrar_.Add(this, |
| 44 content::NOTIFICATION_TAB_ADDED, | 44 content::NOTIFICATION_TAB_ADDED, |
| 45 content::Source<TabContentsDelegate>(browser)); | 45 content::Source<TabContentsDelegate>(browser)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 Panel::~Panel() { | 48 Panel::~Panel() { |
| 49 // Invoked by native panel so do not access native_panel_ here. | 49 // Invoked by native panel so do not access native_panel_ here. |
| 50 content::NotificationService::current()->Notify( |
| 51 chrome::NOTIFICATION_PANEL_DELETED, |
| 52 content::Source<Panel>(this), |
| 53 content::NotificationService::NoDetails()); |
| 50 } | 54 } |
| 51 | 55 |
| 52 PanelManager* Panel::manager() const { | 56 PanelManager* Panel::manager() const { |
| 53 return PanelManager::GetInstance(); | 57 return PanelManager::GetInstance(); |
| 54 } | 58 } |
| 55 | 59 |
| 56 | 60 |
| 57 const Extension* Panel::GetExtension() const { | 61 const Extension* Panel::GetExtension() const { |
| 58 return GetExtensionFromBrowser(browser()); | 62 return GetExtensionFromBrowser(browser()); |
| 59 } | 63 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 170 |
| 167 void Panel::SetBounds(const gfx::Rect& bounds) { | 171 void Panel::SetBounds(const gfx::Rect& bounds) { |
| 168 // Ignore any SetBounds requests since the bounds are completely controlled | 172 // Ignore any SetBounds requests since the bounds are completely controlled |
| 169 // by panel manager. | 173 // by panel manager. |
| 170 } | 174 } |
| 171 | 175 |
| 172 // Close() may be called multiple times if the browser window is not ready to | 176 // Close() may be called multiple times if the browser window is not ready to |
| 173 // close on the first attempt. | 177 // close on the first attempt. |
| 174 void Panel::Close() { | 178 void Panel::Close() { |
| 175 native_panel_->ClosePanel(); | 179 native_panel_->ClosePanel(); |
| 176 | |
| 177 // TODO(dimich): Only implemented fully async on Mac. Need to update other | |
| 178 // platforms. The panel should be removed from PanelManager when and if it | |
| 179 // was actually closed. The closing can be cancelled because of onbeforeunload | |
| 180 // handler on the web page. http://crbug.com/102720 | |
| 181 #if !defined(OS_MACOSX) | |
| 182 manager()->Remove(this); | |
| 183 #endif | |
| 184 } | 180 } |
| 185 | 181 |
| 186 void Panel::Activate() { | 182 void Panel::Activate() { |
| 187 // Make sure the panel is expanded when activated programmatically, | 183 // Make sure the panel is expanded when activated programmatically, |
| 188 // so the user input does not go into collapsed window. | 184 // so the user input does not go into collapsed window. |
| 189 SetExpansionState(Panel::EXPANDED); | 185 SetExpansionState(Panel::EXPANDED); |
| 190 native_panel_->ActivatePanel(); | 186 native_panel_->ActivatePanel(); |
| 191 } | 187 } |
| 192 | 188 |
| 193 void Panel::Deactivate() { | 189 void Panel::Deactivate() { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 RequestRenderViewHostToDisableScrollbars(GetRenderViewHost()); | 594 RequestRenderViewHostToDisableScrollbars(GetRenderViewHost()); |
| 599 } | 595 } |
| 600 | 596 |
| 601 Browser* Panel::browser() const { | 597 Browser* Panel::browser() const { |
| 602 return native_panel_->GetPanelBrowser(); | 598 return native_panel_->GetPanelBrowser(); |
| 603 } | 599 } |
| 604 | 600 |
| 605 void Panel::DestroyBrowser() { | 601 void Panel::DestroyBrowser() { |
| 606 native_panel_->DestroyPanelBrowser(); | 602 native_panel_->DestroyPanelBrowser(); |
| 607 } | 603 } |
| OLD | NEW |