| 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/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX; | 467 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX; |
| 468 } | 468 } |
| 469 | 469 |
| 470 void WebViewGuest::GuestDestroyed() { | 470 void WebViewGuest::GuestDestroyed() { |
| 471 RemoveWebViewStateFromIOThread(web_contents()); | 471 RemoveWebViewStateFromIOThread(web_contents()); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void WebViewGuest::GuestReady() { | 474 void WebViewGuest::GuestReady() { |
| 475 // The guest RenderView should always live in an isolated guest process. | 475 // The guest RenderView should always live in an isolated guest process. |
| 476 CHECK(web_contents()->GetRenderProcessHost()->IsForGuestsOnly()); | 476 CHECK(web_contents()->GetRenderProcessHost()->IsForGuestsOnly()); |
| 477 Send(new ExtensionMsg_SetFrameName(web_contents()->GetRoutingID(), name_)); | 477 Send(new ExtensionMsg_SetFrameName( |
| 478 web_contents()->GetRenderViewHost()->GetRoutingID(), name_)); |
| 478 | 479 |
| 479 // We don't want to accidentally set the opacity of an interstitial page. | 480 // We don't want to accidentally set the opacity of an interstitial page. |
| 480 // WebContents::GetRenderWidgetHostView will return the RWHV of an | 481 // WebContents::GetRenderWidgetHostView will return the RWHV of an |
| 481 // interstitial page if one is showing at this time. We only want opacity | 482 // interstitial page if one is showing at this time. We only want opacity |
| 482 // to apply to web pages. | 483 // to apply to web pages. |
| 483 if (allow_transparency_) { | 484 if (allow_transparency_) { |
| 484 web_contents() | 485 web_contents() |
| 485 ->GetRenderViewHost() | 486 ->GetRenderViewHost() |
| 486 ->GetWidget() | 487 ->GetWidget() |
| 487 ->GetView() | 488 ->GetView() |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 web_view_info.rules_registry_id = rules_registry_id_; | 947 web_view_info.rules_registry_id = rules_registry_id_; |
| 947 | 948 |
| 948 // Get content scripts IDs added by the guest. | 949 // Get content scripts IDs added by the guest. |
| 949 WebViewContentScriptManager* manager = | 950 WebViewContentScriptManager* manager = |
| 950 WebViewContentScriptManager::Get(browser_context()); | 951 WebViewContentScriptManager::Get(browser_context()); |
| 951 DCHECK(manager); | 952 DCHECK(manager); |
| 952 web_view_info.content_script_ids = manager->GetContentScriptIDSet( | 953 web_view_info.content_script_ids = manager->GetContentScriptIDSet( |
| 953 web_view_info.embedder_process_id, web_view_info.instance_id); | 954 web_view_info.embedder_process_id, web_view_info.instance_id); |
| 954 | 955 |
| 955 content::BrowserThread::PostTask( | 956 content::BrowserThread::PostTask( |
| 956 content::BrowserThread::IO, | 957 content::BrowserThread::IO, FROM_HERE, |
| 957 FROM_HERE, | |
| 958 base::Bind(&WebViewRendererState::AddGuest, | 958 base::Bind(&WebViewRendererState::AddGuest, |
| 959 base::Unretained(WebViewRendererState::GetInstance()), | 959 base::Unretained(WebViewRendererState::GetInstance()), |
| 960 web_contents()->GetRenderProcessHost()->GetID(), | 960 web_contents()->GetRenderProcessHost()->GetID(), |
| 961 web_contents()->GetRoutingID(), | 961 web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 962 web_view_info)); | 962 web_view_info)); |
| 963 } | 963 } |
| 964 | 964 |
| 965 // static | 965 // static |
| 966 void WebViewGuest::RemoveWebViewStateFromIOThread( | 966 void WebViewGuest::RemoveWebViewStateFromIOThread( |
| 967 WebContents* web_contents) { | 967 WebContents* web_contents) { |
| 968 content::BrowserThread::PostTask( | 968 content::BrowserThread::PostTask( |
| 969 content::BrowserThread::IO, FROM_HERE, | 969 content::BrowserThread::IO, FROM_HERE, |
| 970 base::Bind( | 970 base::Bind(&WebViewRendererState::RemoveGuest, |
| 971 &WebViewRendererState::RemoveGuest, | 971 base::Unretained(WebViewRendererState::GetInstance()), |
| 972 base::Unretained(WebViewRendererState::GetInstance()), | 972 web_contents->GetRenderProcessHost()->GetID(), |
| 973 web_contents->GetRenderProcessHost()->GetID(), | 973 web_contents->GetRenderViewHost()->GetRoutingID())); |
| 974 web_contents->GetRoutingID())); | |
| 975 } | 974 } |
| 976 | 975 |
| 977 void WebViewGuest::RequestMediaAccessPermission( | 976 void WebViewGuest::RequestMediaAccessPermission( |
| 978 WebContents* source, | 977 WebContents* source, |
| 979 const content::MediaStreamRequest& request, | 978 const content::MediaStreamRequest& request, |
| 980 const content::MediaResponseCallback& callback) { | 979 const content::MediaResponseCallback& callback) { |
| 981 web_view_permission_helper_->RequestMediaAccessPermission(source, | 980 web_view_permission_helper_->RequestMediaAccessPermission(source, |
| 982 request, | 981 request, |
| 983 callback); | 982 callback); |
| 984 } | 983 } |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1517 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 1519 DispatchEventToView(base::MakeUnique<GuestViewEvent>( | 1518 DispatchEventToView(base::MakeUnique<GuestViewEvent>( |
| 1520 webview::kEventExitFullscreen, std::move(args))); | 1519 webview::kEventExitFullscreen, std::move(args))); |
| 1521 } | 1520 } |
| 1522 // Since we changed fullscreen state, sending a Resize message ensures that | 1521 // Since we changed fullscreen state, sending a Resize message ensures that |
| 1523 // renderer/ sees the change. | 1522 // renderer/ sees the change. |
| 1524 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); | 1523 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); |
| 1525 } | 1524 } |
| 1526 | 1525 |
| 1527 } // namespace extensions | 1526 } // namespace extensions |
| OLD | NEW |