OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "app/keyboard_codes.h" | 9 #include "app/keyboard_codes.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // This method is only called by some APIs, so we still need to protect | 231 // This method is only called by some APIs, so we still need to protect |
232 // DidNavigate below (location = ""). | 232 // DidNavigate below (location = ""). |
233 if (url.SchemeIs(chrome::kExtensionScheme) && | 233 if (url.SchemeIs(chrome::kExtensionScheme) && |
234 url.host() != extension_->id()) { | 234 url.host() != extension_->id()) { |
235 // TODO(erikkay) communicate this back to the caller? | 235 // TODO(erikkay) communicate this back to the caller? |
236 return; | 236 return; |
237 } | 237 } |
238 | 238 |
239 url_ = url; | 239 url_ = url; |
240 | 240 |
241 if (!is_background_page() && !extension_->GetBackgroundPageReady()) { | 241 if (!is_background_page() && |
| 242 profile_->GetExtensionsService()->IsBackgroundPageReady(extension_)) { |
242 // Make sure the background page loads before any others. | 243 // Make sure the background page loads before any others. |
243 registrar_.Add(this, NotificationType::EXTENSION_BACKGROUND_PAGE_READY, | 244 registrar_.Add(this, NotificationType::EXTENSION_BACKGROUND_PAGE_READY, |
244 Source<Extension>(extension_)); | 245 Source<Extension>(extension_)); |
245 return; | 246 return; |
246 } | 247 } |
247 | 248 |
248 render_view_host_->NavigateToURL(url_); | 249 render_view_host_->NavigateToURL(url_); |
249 } | 250 } |
250 | 251 |
251 void ExtensionHost::Observe(NotificationType type, | 252 void ExtensionHost::Observe(NotificationType type, |
252 const NotificationSource& source, | 253 const NotificationSource& source, |
253 const NotificationDetails& details) { | 254 const NotificationDetails& details) { |
254 switch (type.value) { | 255 switch (type.value) { |
255 case NotificationType::EXTENSION_BACKGROUND_PAGE_READY: | 256 case NotificationType::EXTENSION_BACKGROUND_PAGE_READY: |
256 DCHECK(extension_->GetBackgroundPageReady()); | 257 DCHECK(profile_->GetExtensionsService()-> |
| 258 IsBackgroundPageReady(extension_)); |
257 NavigateToURL(url_); | 259 NavigateToURL(url_); |
258 break; | 260 break; |
259 case NotificationType::RENDERER_PROCESS_CREATED: | 261 case NotificationType::RENDERER_PROCESS_CREATED: |
260 NotificationService::current()->Notify( | 262 NotificationService::current()->Notify( |
261 NotificationType::EXTENSION_PROCESS_CREATED, | 263 NotificationType::EXTENSION_PROCESS_CREATED, |
262 Source<Profile>(profile_), | 264 Source<Profile>(profile_), |
263 Details<ExtensionHost>(this)); | 265 Details<ExtensionHost>(this)); |
264 break; | 266 break; |
265 case NotificationType::EXTENSION_UNLOADED: | 267 case NotificationType::EXTENSION_UNLOADED: |
266 // The extension object will be deleted after this notification has been | 268 // The extension object will be deleted after this notification has been |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 392 } |
391 | 393 |
392 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { | 394 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { |
393 // If the document has already been marked as available for this host, then | 395 // If the document has already been marked as available for this host, then |
394 // bail. No need for the redundant setup. http://crbug.com/31170 | 396 // bail. No need for the redundant setup. http://crbug.com/31170 |
395 if (document_element_available_) | 397 if (document_element_available_) |
396 return; | 398 return; |
397 | 399 |
398 document_element_available_ = true; | 400 document_element_available_ = true; |
399 if (is_background_page()) { | 401 if (is_background_page()) { |
400 extension_->SetBackgroundPageReady(); | 402 profile_->GetExtensionsService()->SetBackgroundPageReady(extension_); |
401 } else { | 403 } else { |
402 switch (extension_host_type_) { | 404 switch (extension_host_type_) { |
403 case ViewType::EXTENSION_INFOBAR: | 405 case ViewType::EXTENSION_INFOBAR: |
404 InsertInfobarCSS(); | 406 InsertInfobarCSS(); |
405 break; | 407 break; |
406 default: | 408 default: |
407 break; // No style sheet for other types, at the moment. | 409 break; // No style sheet for other types, at the moment. |
408 } | 410 } |
409 } | 411 } |
410 } | 412 } |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 // Extensions hosted in ExternalTabContainer objects may not have | 776 // Extensions hosted in ExternalTabContainer objects may not have |
775 // an associated browser. | 777 // an associated browser. |
776 Browser* browser = GetBrowser(); | 778 Browser* browser = GetBrowser(); |
777 if (browser) | 779 if (browser) |
778 window_id = ExtensionTabUtil::GetWindowId(browser); | 780 window_id = ExtensionTabUtil::GetWindowId(browser); |
779 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { | 781 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { |
780 NOTREACHED(); | 782 NOTREACHED(); |
781 } | 783 } |
782 return window_id; | 784 return window_id; |
783 } | 785 } |
OLD | NEW |