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/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 CreateRenderViewNow(); | 223 CreateRenderViewNow(); |
224 } else { | 224 } else { |
225 ProcessCreationQueue::GetInstance()->CreateSoon(this); | 225 ProcessCreationQueue::GetInstance()->CreateSoon(this); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 void ExtensionHost::CreateRenderViewNow() { | 229 void ExtensionHost::CreateRenderViewNow() { |
230 LoadInitialURL(); | 230 LoadInitialURL(); |
231 if (is_background_page()) { | 231 if (is_background_page()) { |
232 DCHECK(IsRenderViewLive()); | 232 DCHECK(IsRenderViewLive()); |
233 profile_->GetExtensionService()->DidCreateRenderViewForBackgroundPage(this); | 233 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 234 DidCreateRenderViewForBackgroundPage(this); |
234 } | 235 } |
235 } | 236 } |
236 | 237 |
237 extensions::WindowController* | 238 extensions::WindowController* |
238 ExtensionHost::GetExtensionWindowController() const { | 239 ExtensionHost::GetExtensionWindowController() const { |
239 return view() && view()->browser() ? | 240 return view() && view()->browser() ? |
240 view()->browser()->extension_window_controller() : NULL; | 241 view()->browser()->extension_window_controller() : NULL; |
241 } | 242 } |
242 | 243 |
243 const GURL& ExtensionHost::GetURL() const { | 244 const GURL& ExtensionHost::GetURL() const { |
244 return host_contents()->GetURL(); | 245 return host_contents()->GetURL(); |
245 } | 246 } |
246 | 247 |
247 void ExtensionHost::LoadInitialURL() { | 248 void ExtensionHost::LoadInitialURL() { |
248 if (!is_background_page() && | 249 if (!is_background_page() && |
249 !profile_->GetExtensionService()->IsBackgroundPageReady(extension_)) { | 250 !extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 251 IsBackgroundPageReady(extension_)) { |
250 // Make sure the background page loads before any others. | 252 // Make sure the background page loads before any others. |
251 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 253 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
252 content::Source<Extension>(extension_)); | 254 content::Source<Extension>(extension_)); |
253 return; | 255 return; |
254 } | 256 } |
255 | 257 |
256 host_contents_->GetController().LoadURL( | 258 host_contents_->GetController().LoadURL( |
257 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, | 259 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, |
258 std::string()); | 260 std::string()); |
259 } | 261 } |
260 | 262 |
261 void ExtensionHost::Close() { | 263 void ExtensionHost::Close() { |
262 content::NotificationService::current()->Notify( | 264 content::NotificationService::current()->Notify( |
263 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 265 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
264 content::Source<Profile>(profile_), | 266 content::Source<Profile>(profile_), |
265 content::Details<ExtensionHost>(this)); | 267 content::Details<ExtensionHost>(this)); |
266 } | 268 } |
267 | 269 |
268 void ExtensionHost::Observe(int type, | 270 void ExtensionHost::Observe(int type, |
269 const content::NotificationSource& source, | 271 const content::NotificationSource& source, |
270 const content::NotificationDetails& details) { | 272 const content::NotificationDetails& details) { |
271 switch (type) { | 273 switch (type) { |
272 case chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY: | 274 case chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY: |
273 DCHECK(profile_->GetExtensionService()-> | 275 DCHECK(extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
274 IsBackgroundPageReady(extension_)); | 276 IsBackgroundPageReady(extension_)); |
275 LoadInitialURL(); | 277 LoadInitialURL(); |
276 break; | 278 break; |
277 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 279 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
278 // The extension object will be deleted after this notification has been | 280 // The extension object will be deleted after this notification has been |
279 // sent. NULL it out so that dirty pointer issues don't arise in cases | 281 // sent. NULL it out so that dirty pointer issues don't arise in cases |
280 // when multiple ExtensionHost objects pointing to the same Extension are | 282 // when multiple ExtensionHost objects pointing to the same Extension are |
281 // present. | 283 // present. |
282 if (extension_ == content::Details<UnloadedExtensionInfo>(details)-> | 284 if (extension_ == content::Details<UnloadedExtensionInfo>(details)-> |
283 extension) { | 285 extension) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 383 } |
382 | 384 |
383 void ExtensionHost::DocumentAvailableInMainFrame() { | 385 void ExtensionHost::DocumentAvailableInMainFrame() { |
384 // If the document has already been marked as available for this host, then | 386 // If the document has already been marked as available for this host, then |
385 // bail. No need for the redundant setup. http://crbug.com/31170 | 387 // bail. No need for the redundant setup. http://crbug.com/31170 |
386 if (document_element_available_) | 388 if (document_element_available_) |
387 return; | 389 return; |
388 | 390 |
389 document_element_available_ = true; | 391 document_element_available_ = true; |
390 if (is_background_page()) { | 392 if (is_background_page()) { |
391 profile_->GetExtensionService()->SetBackgroundPageReady(extension_); | 393 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 394 SetBackgroundPageReady(extension_); |
392 } else { | 395 } else { |
393 switch (extension_host_type_) { | 396 switch (extension_host_type_) { |
394 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: | 397 case chrome::VIEW_TYPE_EXTENSION_INFOBAR: |
395 InsertInfobarCSS(); | 398 InsertInfobarCSS(); |
396 break; | 399 break; |
397 default: | 400 default: |
398 break; // No style sheet for other types, at the moment. | 401 break; // No style sheet for other types, at the moment. |
399 } | 402 } |
400 } | 403 } |
401 } | 404 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 void ExtensionHost::RequestMediaAccessPermission( | 649 void ExtensionHost::RequestMediaAccessPermission( |
647 content::WebContents* web_contents, | 650 content::WebContents* web_contents, |
648 const content::MediaStreamRequest* request, | 651 const content::MediaStreamRequest* request, |
649 const content::MediaResponseCallback& callback) { | 652 const content::MediaResponseCallback& callback) { |
650 // For tab capture device, we require the tabCapture permission. | 653 // For tab capture device, we require the tabCapture permission. |
651 RequestMediaAccessPermissionHelper::AuthorizeRequest( | 654 RequestMediaAccessPermissionHelper::AuthorizeRequest( |
652 request, callback, extension(), false); | 655 request, callback, extension(), false); |
653 } | 656 } |
654 | 657 |
655 } // namespace extensions | 658 } // namespace extensions |
OLD | NEW |