OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_host.h" | 5 #include "extensions/browser/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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 pm->IncrementLazyKeepaliveCount(extension()); | 355 pm->IncrementLazyKeepaliveCount(extension()); |
356 } | 356 } |
357 | 357 |
358 void ExtensionHost::OnDecrementLazyKeepaliveCount() { | 358 void ExtensionHost::OnDecrementLazyKeepaliveCount() { |
359 ProcessManager* pm = ExtensionSystem::Get( | 359 ProcessManager* pm = ExtensionSystem::Get( |
360 browser_context_)->process_manager(); | 360 browser_context_)->process_manager(); |
361 if (pm) | 361 if (pm) |
362 pm->DecrementLazyKeepaliveCount(extension()); | 362 pm->DecrementLazyKeepaliveCount(extension()); |
363 } | 363 } |
364 | 364 |
| 365 // ExtensionFunctionDispatcher::Delegate |
| 366 |
| 367 content::WebContents* ExtensionHost::GetAssociatedWebContents() const { |
| 368 return host_contents(); |
| 369 } |
| 370 |
365 // content::WebContentsObserver | 371 // content::WebContentsObserver |
366 | 372 |
367 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 373 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
368 render_view_host_ = render_view_host; | 374 render_view_host_ = render_view_host; |
369 } | 375 } |
370 | 376 |
371 void ExtensionHost::RenderViewDeleted(RenderViewHost* render_view_host) { | 377 void ExtensionHost::RenderViewDeleted(RenderViewHost* render_view_host) { |
372 // If our RenderViewHost is deleted, fall back to the host_contents' current | 378 // If our RenderViewHost is deleted, fall back to the host_contents' current |
373 // RVH. There is sometimes a small gap between the pending RVH being deleted | 379 // RVH. There is sometimes a small gap between the pending RVH being deleted |
374 // and RenderViewCreated being called, so we update it here. | 380 // and RenderViewCreated being called, so we update it here. |
(...skipping 10 matching lines...) Expand all Loading... |
385 WindowOpenDisposition disposition, | 391 WindowOpenDisposition disposition, |
386 const gfx::Rect& initial_pos, | 392 const gfx::Rect& initial_pos, |
387 bool user_gesture, | 393 bool user_gesture, |
388 bool* was_blocked) { | 394 bool* was_blocked) { |
389 // First, if the creating extension view was associated with a tab contents, | 395 // First, if the creating extension view was associated with a tab contents, |
390 // use that tab content's delegate. We must be careful here that the | 396 // use that tab content's delegate. We must be careful here that the |
391 // associated tab contents has the same profile as the new tab contents. In | 397 // associated tab contents has the same profile as the new tab contents. In |
392 // the case of extensions in 'spanning' incognito mode, they can mismatch. | 398 // the case of extensions in 'spanning' incognito mode, they can mismatch. |
393 // We don't want to end up putting a normal tab into an incognito window, or | 399 // We don't want to end up putting a normal tab into an incognito window, or |
394 // vice versa. | 400 // vice versa. |
| 401 // |
395 // Note that we don't do this for popup windows, because we need to associate | 402 // Note that we don't do this for popup windows, because we need to associate |
396 // those with their extension_app_id. | 403 // those with their extension_app_id. |
397 if (disposition != NEW_POPUP) { | 404 if (disposition != NEW_POPUP) { |
398 WebContents* associated_contents = GetAssociatedWebContents(); | 405 WebContents* visible_contents = GetVisibleWebContents(); |
399 if (associated_contents && | 406 if (visible_contents && |
400 associated_contents->GetBrowserContext() == | 407 visible_contents->GetBrowserContext() == |
401 new_contents->GetBrowserContext()) { | 408 new_contents->GetBrowserContext()) { |
402 WebContentsDelegate* delegate = associated_contents->GetDelegate(); | 409 WebContentsDelegate* delegate = visible_contents->GetDelegate(); |
403 if (delegate) { | 410 if (delegate) { |
404 delegate->AddNewContents( | 411 delegate->AddNewContents(visible_contents, |
405 associated_contents, new_contents, disposition, initial_pos, | 412 new_contents, |
406 user_gesture, was_blocked); | 413 disposition, |
| 414 initial_pos, |
| 415 user_gesture, |
| 416 was_blocked); |
407 return; | 417 return; |
408 } | 418 } |
409 } | 419 } |
410 } | 420 } |
411 | 421 |
412 delegate_->CreateTab( | 422 delegate_->CreateTab( |
413 new_contents, extension_id_, disposition, initial_pos, user_gesture); | 423 new_contents, extension_id_, disposition, initial_pos, user_gesture); |
414 } | 424 } |
415 | 425 |
416 void ExtensionHost::RenderViewReady() { | 426 void ExtensionHost::RenderViewReady() { |
(...skipping 10 matching lines...) Expand all Loading... |
427 delegate_->ProcessMediaAccessRequest( | 437 delegate_->ProcessMediaAccessRequest( |
428 web_contents, request, callback, extension()); | 438 web_contents, request, callback, extension()); |
429 } | 439 } |
430 | 440 |
431 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { | 441 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { |
432 ViewType view_type = extensions::GetViewType(web_contents); | 442 ViewType view_type = extensions::GetViewType(web_contents); |
433 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; | 443 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; |
434 } | 444 } |
435 | 445 |
436 } // namespace extensions | 446 } // namespace extensions |
OLD | NEW |