| 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 int routing_id, | 387 int routing_id, |
| 388 const WebContentsImpl* base_web_contents, | 388 const WebContentsImpl* base_web_contents, |
| 389 WebContentsImpl* opener) { | 389 WebContentsImpl* opener) { |
| 390 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener); | 390 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener); |
| 391 | 391 |
| 392 new_contents->Init(browser_context, site_instance, routing_id, | 392 new_contents->Init(browser_context, site_instance, routing_id, |
| 393 static_cast<const WebContentsImpl*>(base_web_contents)); | 393 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 394 return new_contents; | 394 return new_contents; |
| 395 } | 395 } |
| 396 | 396 |
| 397 WebContentsImpl* WebContentsImpl::CreateGuest(BrowserContext* browser_context, | 397 WebContentsImpl* WebContentsImpl::CreateGuest( |
| 398 const std::string& host_url, | 398 BrowserContext* browser_context, |
| 399 int guest_instance_id, | 399 const std::string& host_url, |
| 400 bool focused, | 400 int guest_instance_id, |
| 401 bool visible) { | 401 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
| 402 // The SiteInstance of a given guest is based on the fact that it's a guest | 402 // The SiteInstance of a given guest is based on the fact that it's a guest |
| 403 // in addition to which platform application the guest belongs to, rather | 403 // in addition to which platform application the guest belongs to, rather |
| 404 // than the URL that the guest is being navigated to. | 404 // than the URL that the guest is being navigated to. |
| 405 GURL guest_site( | 405 GURL guest_site( |
| 406 base::StringPrintf("%s://%s", chrome::kGuestScheme, host_url.c_str())); | 406 base::StringPrintf("%s://%s", chrome::kGuestScheme, host_url.c_str())); |
| 407 SiteInstance* guest_site_instance = | 407 SiteInstance* guest_site_instance = |
| 408 SiteInstance::CreateForURL(browser_context, guest_site); | 408 SiteInstance::CreateForURL(browser_context, guest_site); |
| 409 WebContentsImpl* new_contents = WebContentsImpl::Create( | 409 WebContentsImpl* new_contents = WebContentsImpl::Create( |
| 410 browser_context, | 410 browser_context, |
| 411 guest_site_instance, | 411 guest_site_instance, |
| 412 MSG_ROUTING_NONE, | 412 MSG_ROUTING_NONE, |
| 413 NULL); // base WebContents | 413 NULL); // base WebContents |
| 414 WebContentsImpl* new_contents_impl = | 414 WebContentsImpl* new_contents_impl = |
| 415 static_cast<WebContentsImpl*>(new_contents); | 415 static_cast<WebContentsImpl*>(new_contents); |
| 416 | 416 |
| 417 // This makes |new_contents| act as a guest. | 417 // This makes |new_contents| act as a guest. |
| 418 // For more info, see comment above class BrowserPluginGuest. | 418 // For more info, see comment above class BrowserPluginGuest. |
| 419 new_contents_impl->browser_plugin_guest_.reset( | 419 new_contents_impl->browser_plugin_guest_.reset( |
| 420 BrowserPluginGuest::Create( | 420 BrowserPluginGuest::Create( |
| 421 guest_instance_id, | 421 guest_instance_id, |
| 422 new_contents_impl, | 422 new_contents_impl, |
| 423 new_contents_impl->GetRenderViewHost(), | 423 new_contents_impl->GetRenderViewHost(), |
| 424 focused, | 424 params)); |
| 425 visible)); | |
| 426 return new_contents; | 425 return new_contents; |
| 427 } | 426 } |
| 428 | 427 |
| 429 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, | 428 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, |
| 430 const GURL& url) { | 429 const GURL& url) { |
| 431 WebPreferences prefs; | 430 WebPreferences prefs; |
| 432 | 431 |
| 433 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 432 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 434 | 433 |
| 435 prefs.developer_extras_enabled = true; | 434 prefs.developer_extras_enabled = true; |
| (...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, | 2315 void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id, |
| 2317 bool result) { | 2316 bool result) { |
| 2318 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); | 2317 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
| 2319 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), | 2318 rvh->Send(new ViewMsg_PpapiBrokerPermissionResult(rvh->GetRoutingID(), |
| 2320 request_id, | 2319 request_id, |
| 2321 result)); | 2320 result)); |
| 2322 } | 2321 } |
| 2323 | 2322 |
| 2324 void WebContentsImpl::OnBrowserPluginCreateGuest( | 2323 void WebContentsImpl::OnBrowserPluginCreateGuest( |
| 2325 int instance_id, | 2324 int instance_id, |
| 2326 const std::string& storage_partition_id, | 2325 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
| 2327 bool persist_storage, | |
| 2328 bool focused, | |
| 2329 bool visible) { | |
| 2330 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin | 2326 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin |
| 2331 // specific messages for this WebContents (through its | 2327 // specific messages for this WebContents (through its |
| 2332 // BrowserPluginEmbedderHelper). This means that any message from browser | 2328 // BrowserPluginEmbedderHelper). This means that any message from browser |
| 2333 // plugin renderer prior to CreateGuest will be ignored. | 2329 // plugin renderer prior to CreateGuest will be ignored. |
| 2334 // For more info, see comment above classes BrowserPluginEmbedder and | 2330 // For more info, see comment above classes BrowserPluginEmbedder and |
| 2335 // BrowserPluginGuest. | 2331 // BrowserPluginGuest. |
| 2336 // The first BrowserPluginHostMsg_CreateGuest message from this WebContents' | 2332 // The first BrowserPluginHostMsg_CreateGuest message from this WebContents' |
| 2337 // embedder render process is handled here. Once BrowserPluginEmbedder is | 2333 // embedder render process is handled here. Once BrowserPluginEmbedder is |
| 2338 // created, all subsequent BrowserPluginHostMsg_CreateGuest messages are | 2334 // created, all subsequent BrowserPluginHostMsg_CreateGuest messages are |
| 2339 // intercepted by the BrowserPluginEmbedderHelper and handled by the | 2335 // intercepted by the BrowserPluginEmbedderHelper and handled by the |
| 2340 // BrowserPluginEmbedder. Thus, this code will not be executed if a | 2336 // BrowserPluginEmbedder. Thus, this code will not be executed if a |
| 2341 // BrowserPluginEmbedder exists for this WebContents. | 2337 // BrowserPluginEmbedder exists for this WebContents. |
| 2342 CHECK(!browser_plugin_embedder_.get()); | 2338 CHECK(!browser_plugin_embedder_.get()); |
| 2343 browser_plugin_embedder_.reset( | 2339 browser_plugin_embedder_.reset( |
| 2344 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); | 2340 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
| 2345 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), | 2341 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), |
| 2346 instance_id, | 2342 instance_id, |
| 2347 storage_partition_id, | 2343 params); |
| 2348 persist_storage, | |
| 2349 focused, | |
| 2350 visible); | |
| 2351 } | 2344 } |
| 2352 | 2345 |
| 2353 // Notifies the RenderWidgetHost instance about the fact that the page is | 2346 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 2354 // loading, or done loading and calls the base implementation. | 2347 // loading, or done loading and calls the base implementation. |
| 2355 void WebContentsImpl::SetIsLoading(bool is_loading, | 2348 void WebContentsImpl::SetIsLoading(bool is_loading, |
| 2356 LoadNotificationDetails* details) { | 2349 LoadNotificationDetails* details) { |
| 2357 if (is_loading == is_loading_) | 2350 if (is_loading == is_loading_) |
| 2358 return; | 2351 return; |
| 2359 | 2352 |
| 2360 if (!is_loading) { | 2353 if (!is_loading) { |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3336 | 3329 |
| 3337 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3330 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3338 return browser_plugin_guest_.get(); | 3331 return browser_plugin_guest_.get(); |
| 3339 } | 3332 } |
| 3340 | 3333 |
| 3341 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3334 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3342 return browser_plugin_embedder_.get(); | 3335 return browser_plugin_embedder_.get(); |
| 3343 } | 3336 } |
| 3344 | 3337 |
| 3345 } // namespace content | 3338 } // namespace content |
| OLD | NEW |