| 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/views/extensions/extension_dialog.h" | 5 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_view_host.h" | 8 #include "chrome/browser/extensions/extension_view_host.h" |
| 9 #include "chrome/browser/extensions/extension_view_host_factory.h" | 9 #include "chrome/browser/extensions/extension_view_host_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 ExtensionDialog::ExtensionDialog(extensions::ExtensionViewHost* host, | 36 ExtensionDialog::ExtensionDialog(extensions::ExtensionViewHost* host, |
| 37 ExtensionDialogObserver* observer) | 37 ExtensionDialogObserver* observer) |
| 38 : host_(host), | 38 : host_(host), |
| 39 observer_(observer) { | 39 observer_(observer) { |
| 40 AddRef(); // Balanced in DeleteDelegate(); | 40 AddRef(); // Balanced in DeleteDelegate(); |
| 41 | 41 |
| 42 registrar_.Add(this, | 42 registrar_.Add(this, |
| 43 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 43 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
| 44 content::Source<BrowserContext>(host->browser_context())); | 44 content::Source<BrowserContext>(host->browser_context())); |
| 45 // Listen for the containing view calling window.close(); | 45 // Listen for the containing view calling window.close(); |
| 46 registrar_.Add(this, | 46 registrar_.Add(this, |
| 47 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 47 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 48 content::Source<BrowserContext>(host->browser_context())); | 48 content::Source<BrowserContext>(host->browser_context())); |
| 49 // Listen for a crash or other termination of the extension process. | 49 // Listen for a crash or other termination of the extension process. |
| 50 registrar_.Add(this, | 50 registrar_.Add(this, |
| 51 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 51 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 52 content::Source<BrowserContext>(host->browser_context())); | 52 content::Source<BrowserContext>(host->browser_context())); |
| 53 } | 53 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 ///////////////////////////////////////////////////////////////////////////// | 197 ///////////////////////////////////////////////////////////////////////////// |
| 198 // content::NotificationObserver overrides. | 198 // content::NotificationObserver overrides. |
| 199 | 199 |
| 200 void ExtensionDialog::Observe(int type, | 200 void ExtensionDialog::Observe(int type, |
| 201 const content::NotificationSource& source, | 201 const content::NotificationSource& source, |
| 202 const content::NotificationDetails& details) { | 202 const content::NotificationDetails& details) { |
| 203 switch (type) { | 203 switch (type) { |
| 204 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: | 204 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD: |
| 205 // Avoid potential overdraw by removing the temporary background after | 205 // Avoid potential overdraw by removing the temporary background after |
| 206 // the extension finishes loading. | 206 // the extension finishes loading. |
| 207 GetExtensionView(host_.get())->set_background(NULL); | 207 GetExtensionView(host_.get())->set_background(NULL); |
| 208 // The render view is created during the LoadURL(), so we should | 208 // The render view is created during the LoadURL(), so we should |
| 209 // set the focus to the view if nobody else takes the focus. | 209 // set the focus to the view if nobody else takes the focus. |
| 210 if (content::Details<extensions::ExtensionHost>(host()) == details) | 210 if (content::Details<extensions::ExtensionHost>(host()) == details) |
| 211 MaybeFocusRenderView(); | 211 MaybeFocusRenderView(); |
| 212 break; | 212 break; |
| 213 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: | 213 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: |
| 214 // If we aren't the host of the popup, then disregard the notification. | 214 // If we aren't the host of the popup, then disregard the notification. |
| 215 if (content::Details<extensions::ExtensionHost>(host()) != details) | 215 if (content::Details<extensions::ExtensionHost>(host()) != details) |
| 216 return; | 216 return; |
| 217 GetWidget()->Close(); | 217 GetWidget()->Close(); |
| 218 break; | 218 break; |
| 219 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: | 219 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: |
| 220 if (content::Details<extensions::ExtensionHost>(host()) != details) | 220 if (content::Details<extensions::ExtensionHost>(host()) != details) |
| 221 return; | 221 return; |
| 222 if (observer_) | 222 if (observer_) |
| 223 observer_->ExtensionTerminated(this); | 223 observer_->ExtensionTerminated(this); |
| 224 break; | 224 break; |
| 225 default: | 225 default: |
| 226 NOTREACHED() << L"Received unexpected notification"; | 226 NOTREACHED() << L"Received unexpected notification"; |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 } | 229 } |
| OLD | NEW |