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 21 matching lines...) Expand all Loading... |
32 } | 32 } |
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, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 42 registrar_.Add(this, |
| 43 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
43 content::Source<BrowserContext>(host->browser_context())); | 44 content::Source<BrowserContext>(host->browser_context())); |
44 // Listen for the containing view calling window.close(); | 45 // Listen for the containing view calling window.close(); |
45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 46 registrar_.Add(this, |
| 47 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
46 content::Source<BrowserContext>(host->browser_context())); | 48 content::Source<BrowserContext>(host->browser_context())); |
47 // Listen for a crash or other termination of the extension process. | 49 // Listen for a crash or other termination of the extension process. |
48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 50 registrar_.Add(this, |
| 51 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
49 content::Source<BrowserContext>(host->browser_context())); | 52 content::Source<BrowserContext>(host->browser_context())); |
50 } | 53 } |
51 | 54 |
52 ExtensionDialog::~ExtensionDialog() { | 55 ExtensionDialog::~ExtensionDialog() { |
53 } | 56 } |
54 | 57 |
55 // static | 58 // static |
56 ExtensionDialog* ExtensionDialog::Show( | 59 ExtensionDialog* ExtensionDialog::Show( |
57 const GURL& url, | 60 const GURL& url, |
58 aura::Window* parent_window, | 61 aura::Window* parent_window, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return false; | 190 return false; |
188 } | 191 } |
189 | 192 |
190 ///////////////////////////////////////////////////////////////////////////// | 193 ///////////////////////////////////////////////////////////////////////////// |
191 // content::NotificationObserver overrides. | 194 // content::NotificationObserver overrides. |
192 | 195 |
193 void ExtensionDialog::Observe(int type, | 196 void ExtensionDialog::Observe(int type, |
194 const content::NotificationSource& source, | 197 const content::NotificationSource& source, |
195 const content::NotificationDetails& details) { | 198 const content::NotificationDetails& details) { |
196 switch (type) { | 199 switch (type) { |
197 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: | 200 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
198 // Avoid potential overdraw by removing the temporary background after | 201 // Avoid potential overdraw by removing the temporary background after |
199 // the extension finishes loading. | 202 // the extension finishes loading. |
200 GetExtensionView(host_.get())->set_background(NULL); | 203 GetExtensionView(host_.get())->set_background(NULL); |
201 // The render view is created during the LoadURL(), so we should | 204 // The render view is created during the LoadURL(), so we should |
202 // set the focus to the view if nobody else takes the focus. | 205 // set the focus to the view if nobody else takes the focus. |
203 if (content::Details<extensions::ExtensionHost>(host()) == details) | 206 if (content::Details<extensions::ExtensionHost>(host()) == details) |
204 MaybeFocusRenderView(); | 207 MaybeFocusRenderView(); |
205 break; | 208 break; |
206 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: | 209 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: |
207 // If we aren't the host of the popup, then disregard the notification. | 210 // If we aren't the host of the popup, then disregard the notification. |
208 if (content::Details<extensions::ExtensionHost>(host()) != details) | 211 if (content::Details<extensions::ExtensionHost>(host()) != details) |
209 return; | 212 return; |
210 GetWidget()->Close(); | 213 GetWidget()->Close(); |
211 break; | 214 break; |
212 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: | 215 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: |
213 if (content::Details<extensions::ExtensionHost>(host()) != details) | 216 if (content::Details<extensions::ExtensionHost>(host()) != details) |
214 return; | 217 return; |
215 if (observer_) | 218 if (observer_) |
216 observer_->ExtensionTerminated(this); | 219 observer_->ExtensionTerminated(this); |
217 break; | 220 break; |
218 default: | 221 default: |
219 NOTREACHED() << L"Received unexpected notification"; | 222 NOTREACHED() << L"Received unexpected notification"; |
220 break; | 223 break; |
221 } | 224 } |
222 } | 225 } |
OLD | NEW |