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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
26 #include "chrome/common/extensions/extension_messages.h" | 26 #include "chrome/common/extensions/extension_messages.h" |
27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
30 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
31 #include "content/public/browser/native_web_keyboard_event.h" | 31 #include "content/public/browser/native_web_keyboard_event.h" |
32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_source.h" | |
34 #include "content/public/browser/notification_types.h" | |
33 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/render_view_host.h" | 36 #include "content/public/browser/render_view_host.h" |
35 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
36 #include "content/public/browser/site_instance.h" | 38 #include "content/public/browser/site_instance.h" |
37 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
38 #include "extensions/browser/event_router.h" | 40 #include "extensions/browser/event_router.h" |
39 #include "extensions/browser/extension_error.h" | 41 #include "extensions/browser/extension_error.h" |
40 #include "extensions/browser/extensions_browser_client.h" | 42 #include "extensions/browser/extensions_browser_client.h" |
41 #include "extensions/browser/process_manager.h" | 43 #include "extensions/browser/process_manager.h" |
42 #include "extensions/browser/view_type_utils.h" | 44 #include "extensions/browser/view_type_utils.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 // synchronously. The process creation is the real meaty part that we want | 186 // synchronously. The process creation is the real meaty part that we want |
185 // to defer. | 187 // to defer. |
186 CreateRenderViewNow(); | 188 CreateRenderViewNow(); |
187 } else { | 189 } else { |
188 ProcessCreationQueue::GetInstance()->CreateSoon(this); | 190 ProcessCreationQueue::GetInstance()->CreateSoon(this); |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 void ExtensionHost::CreateRenderViewNow() { | 194 void ExtensionHost::CreateRenderViewNow() { |
193 LoadInitialURL(); | 195 LoadInitialURL(); |
194 if (IsBackgroundPage()) { | 196 if (!IsBackgroundPage()) { |
kirr
2014/03/07 12:23:40
Is it a misprint in condition? Seems like DidCreat
James Cook
2014/03/07 17:14:47
Yeah, that looks wrong. I'm taking a closer look a
| |
195 DCHECK(IsRenderViewLive()); | 197 DCHECK(IsRenderViewLive()); |
196 ExtensionSystem::GetForBrowserContext(browser_context_)-> | 198 ExtensionService* service = GetExtensionService(); |
197 extension_service()->DidCreateRenderViewForBackgroundPage(this); | 199 if (service) |
200 service->DidCreateRenderViewForBackgroundPage(this); | |
198 } | 201 } |
199 } | 202 } |
200 | 203 |
204 ExtensionService* ExtensionHost::GetExtensionService() { | |
205 return ExtensionSystem::GetForBrowserContext(browser_context_) | |
206 ->extension_service(); | |
207 } | |
208 | |
201 const GURL& ExtensionHost::GetURL() const { | 209 const GURL& ExtensionHost::GetURL() const { |
202 return host_contents()->GetURL(); | 210 return host_contents()->GetURL(); |
203 } | 211 } |
204 | 212 |
205 void ExtensionHost::LoadInitialURL() { | 213 void ExtensionHost::LoadInitialURL() { |
206 host_contents_->GetController().LoadURL( | 214 host_contents_->GetController().LoadURL( |
207 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, | 215 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, |
208 std::string()); | 216 std::string()); |
209 } | 217 } |
210 | 218 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 // If the document has already been marked as available for this host, then | 316 // If the document has already been marked as available for this host, then |
309 // bail. No need for the redundant setup. http://crbug.com/31170 | 317 // bail. No need for the redundant setup. http://crbug.com/31170 |
310 if (document_element_available_) | 318 if (document_element_available_) |
311 return; | 319 return; |
312 document_element_available_ = true; | 320 document_element_available_ = true; |
313 OnDocumentAvailable(); | 321 OnDocumentAvailable(); |
314 } | 322 } |
315 | 323 |
316 void ExtensionHost::OnDocumentAvailable() { | 324 void ExtensionHost::OnDocumentAvailable() { |
317 DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 325 DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
318 ExtensionSystem::GetForBrowserContext(browser_context_)-> | 326 ExtensionService* service = GetExtensionService(); |
319 extension_service()->SetBackgroundPageReady(extension_); | 327 if (service) |
328 service->SetBackgroundPageReady(extension_); | |
329 content::NotificationService::current()->Notify( | |
330 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | |
331 content::Source<const Extension>(extension_), | |
332 content::NotificationService::NoDetails()); | |
320 } | 333 } |
321 | 334 |
322 void ExtensionHost::CloseContents(WebContents* contents) { | 335 void ExtensionHost::CloseContents(WebContents* contents) { |
323 Close(); | 336 Close(); |
324 } | 337 } |
325 | 338 |
326 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { | 339 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { |
327 bool handled = true; | 340 bool handled = true; |
328 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) | 341 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) |
329 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 342 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 | 470 |
458 void ExtensionHost::RequestMediaAccessPermission( | 471 void ExtensionHost::RequestMediaAccessPermission( |
459 content::WebContents* web_contents, | 472 content::WebContents* web_contents, |
460 const content::MediaStreamRequest& request, | 473 const content::MediaStreamRequest& request, |
461 const content::MediaResponseCallback& callback) { | 474 const content::MediaResponseCallback& callback) { |
462 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( | 475 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |
463 web_contents, request, callback, extension()); | 476 web_contents, request, callback, extension()); |
464 } | 477 } |
465 | 478 |
466 } // namespace extensions | 479 } // namespace extensions |
OLD | NEW |