Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 9360014: Create a content public browser API around the ChildProcessSecurityPolicy class. The implementati... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
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"
11 #include "base/metrics/stats_counters.h" 11 #include "base/metrics/stats_counters.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "content/browser/child_process_security_policy.h" 16 #include "content/browser/child_process_security_policy_impl.h"
17 #include "content/browser/debugger/devtools_manager_impl.h" 17 #include "content/browser/debugger/devtools_manager_impl.h"
18 #include "content/browser/download/download_stats.h" 18 #include "content/browser/download/download_stats.h"
19 #include "content/browser/download/save_package.h" 19 #include "content/browser/download/save_package.h"
20 #include "content/browser/gpu/gpu_data_manager.h" 20 #include "content/browser/gpu/gpu_data_manager.h"
21 #include "content/browser/gpu/gpu_process_host.h" 21 #include "content/browser/gpu/gpu_process_host.h"
22 #include "content/browser/host_zoom_map_impl.h" 22 #include "content/browser/host_zoom_map_impl.h"
23 #include "content/browser/in_process_webkit/session_storage_namespace.h" 23 #include "content/browser/in_process_webkit/session_storage_namespace.h"
24 #include "content/browser/intents/web_intents_dispatcher_impl.h" 24 #include "content/browser/intents/web_intents_dispatcher_impl.h"
25 #include "content/browser/load_from_memory_cache_details.h" 25 #include "content/browser/load_from_memory_cache_details.h"
26 #include "content/browser/load_notification_details.h" 26 #include "content/browser/load_notification_details.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 prefs.gl_multisampling_enabled = false; 416 prefs.gl_multisampling_enabled = false;
417 417
418 // Accelerated video and animation are slower than regular when using a 418 // Accelerated video and animation are slower than regular when using a
419 // software 3d rasterizer. 419 // software 3d rasterizer.
420 if (gpu_data_manager->software_rendering()) { 420 if (gpu_data_manager->software_rendering()) {
421 prefs.accelerated_video_enabled = false; 421 prefs.accelerated_video_enabled = false;
422 prefs.accelerated_animation_enabled = false; 422 prefs.accelerated_animation_enabled = false;
423 } 423 }
424 } 424 }
425 425
426 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( 426 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
427 rvh->process()->GetID())) { 427 rvh->process()->GetID())) {
428 prefs.loads_images_automatically = true; 428 prefs.loads_images_automatically = true;
429 prefs.javascript_enabled = true; 429 prefs.javascript_enabled = true;
430 } 430 }
431 431
432 prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 432 prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
433 433
434 // Force accelerated compositing and 2d canvas off for chrome:, about: and 434 // Force accelerated compositing and 2d canvas off for chrome:, about: and
435 // chrome-devtools: pages (unless it's specifically allowed). 435 // chrome-devtools: pages (unless it's specifically allowed).
436 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || 436 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) ||
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 new WebIntentsDispatcherImpl(this, intent, intent_id); 1336 new WebIntentsDispatcherImpl(this, intent, intent_id);
1337 delegate_->WebIntentDispatch(this, intents_dispatcher); 1337 delegate_->WebIntentDispatch(this, intents_dispatcher);
1338 } 1338 }
1339 1339
1340 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, 1340 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
1341 bool is_main_frame, 1341 bool is_main_frame,
1342 const GURL& opener_url, 1342 const GURL& opener_url,
1343 const GURL& url) { 1343 const GURL& url) {
1344 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); 1344 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL);
1345 GURL validated_url(url); 1345 GURL validated_url(url);
1346 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), 1346 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(),
1347 GetRenderProcessHost()->GetID(), &validated_url); 1347 GetRenderProcessHost()->GetID(), &validated_url);
1348 1348
1349 RenderViewHost* rvh = 1349 RenderViewHost* rvh =
1350 render_manager_.pending_render_view_host() ? 1350 render_manager_.pending_render_view_host() ?
1351 render_manager_.pending_render_view_host() : GetRenderViewHost(); 1351 render_manager_.pending_render_view_host() : GetRenderViewHost();
1352 // Notify observers about the start of the provisional load. 1352 // Notify observers about the start of the provisional load.
1353 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1353 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1354 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, 1354 DidStartProvisionalLoadForFrame(frame_id, is_main_frame,
1355 validated_url, is_error_page, rvh)); 1355 validated_url, is_error_page, rvh));
1356 1356
(...skipping 28 matching lines...) Expand all
1385 void TabContents::OnDidFailProvisionalLoadWithError( 1385 void TabContents::OnDidFailProvisionalLoadWithError(
1386 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { 1386 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) {
1387 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() 1387 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec()
1388 << ", error_code: " << params.error_code 1388 << ", error_code: " << params.error_code
1389 << ", error_description: " << params.error_description 1389 << ", error_description: " << params.error_description
1390 << ", is_main_frame: " << params.is_main_frame 1390 << ", is_main_frame: " << params.is_main_frame
1391 << ", showing_repost_interstitial: " << 1391 << ", showing_repost_interstitial: " <<
1392 params.showing_repost_interstitial 1392 params.showing_repost_interstitial
1393 << ", frame_id: " << params.frame_id; 1393 << ", frame_id: " << params.frame_id;
1394 GURL validated_url(params.url); 1394 GURL validated_url(params.url);
1395 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), 1395 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(),
1396 GetRenderProcessHost()->GetID(), &validated_url); 1396 GetRenderProcessHost()->GetID(), &validated_url);
1397 1397
1398 if (net::ERR_ABORTED == params.error_code) { 1398 if (net::ERR_ABORTED == params.error_code) {
1399 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. 1399 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials.
1400 // This means that the interstitial won't be torn down properly, which is 1400 // This means that the interstitial won't be torn down properly, which is
1401 // bad. But if we have an interstitial, go back to another tab type, and 1401 // bad. But if we have an interstitial, go back to another tab type, and
1402 // then load the same interstitial again, we could end up getting the first 1402 // then load the same interstitial again, we could end up getting the first
1403 // interstitial's "failed" message (as a result of the cancel) when we're on 1403 // interstitial's "failed" message (as a result of the cancel) when we're on
1404 // the second one. 1404 // the second one.
1405 // 1405 //
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 maximum_zoom_percent_ = maximum_percent; 1564 maximum_zoom_percent_ = maximum_percent;
1565 temporary_zoom_settings_ = !remember; 1565 temporary_zoom_settings_ = !remember;
1566 } 1566 }
1567 1567
1568 void TabContents::OnSaveURL(const GURL& url) { 1568 void TabContents::OnSaveURL(const GURL& url) {
1569 SaveURL(url, GetURL()); 1569 SaveURL(url, GetURL());
1570 } 1570 }
1571 1571
1572 void TabContents::OnEnumerateDirectory(int request_id, 1572 void TabContents::OnEnumerateDirectory(int request_id,
1573 const FilePath& path) { 1573 const FilePath& path) {
1574 delegate_->EnumerateDirectory(this, request_id, path); 1574 ChildProcessSecurityPolicyImpl* policy =
1575 ChildProcessSecurityPolicyImpl::GetInstance();
1576 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path))
1577 delegate_->EnumerateDirectory(this, request_id, path);
1575 } 1578 }
1576 1579
1577 void TabContents::OnJSOutOfMemory() { 1580 void TabContents::OnJSOutOfMemory() {
1578 delegate_->JSOutOfMemory(this); 1581 delegate_->JSOutOfMemory(this);
1579 } 1582 }
1580 1583
1581 void TabContents::OnRegisterProtocolHandler(const std::string& protocol, 1584 void TabContents::OnRegisterProtocolHandler(const std::string& protocol,
1582 const GURL& url, 1585 const GURL& url,
1583 const string16& title) { 1586 const string16& title) {
1587 ChildProcessSecurityPolicyImpl* policy =
1588 ChildProcessSecurityPolicyImpl::GetInstance();
1589 if (policy->IsPseudoScheme(protocol) || policy->IsDisabledScheme(protocol))
1590 return;
1584 delegate_->RegisterProtocolHandler(this, protocol, url, title); 1591 delegate_->RegisterProtocolHandler(this, protocol, url, title);
1585 } 1592 }
1586 1593
1587 void TabContents::OnFindReply(int request_id, 1594 void TabContents::OnFindReply(int request_id,
1588 int number_of_matches, 1595 int number_of_matches,
1589 const gfx::Rect& selection_rect, 1596 const gfx::Rect& selection_rect,
1590 int active_match_ordinal, 1597 int active_match_ordinal,
1591 bool final_update) { 1598 bool final_update) {
1592 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, 1599 delegate_->FindReply(this, request_id, number_of_matches, selection_rect,
1593 active_match_ordinal, final_update); 1600 active_match_ordinal, final_update);
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 save_info, 2444 save_info,
2438 this); 2445 this);
2439 } 2446 }
2440 2447
2441 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2448 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2442 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2449 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2443 // Can be NULL during tests. 2450 // Can be NULL during tests.
2444 if (rwh_view) 2451 if (rwh_view)
2445 rwh_view->SetSize(GetView()->GetContainerSize()); 2452 rwh_view->SetSize(GetView()->GetContainerSize());
2446 } 2453 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_controller_impl.cc ('k') | content/browser/webui/web_ui_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698