| 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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 WebVector<WebString> names(total_size); | 232 WebVector<WebString> names(total_size); |
| 233 WebVector<WebString> values(total_size); | 233 WebVector<WebString> values(total_size); |
| 234 | 234 |
| 235 for (size_t i = 0; i < existing_size; ++i) { | 235 for (size_t i = 0; i < existing_size; ++i) { |
| 236 names[i] = (*existing_names)[i]; | 236 names[i] = (*existing_names)[i]; |
| 237 values[i] = (*existing_values)[i]; | 237 values[i] = (*existing_values)[i]; |
| 238 } | 238 } |
| 239 | 239 |
| 240 for (size_t i = 0; i < additional_names.size(); ++i) { | 240 for (size_t i = 0; i < additional_names.size(); ++i) { |
| 241 names[existing_size + i] = additional_names[i]; | 241 names[existing_size + i] = WebString::fromUTF16(additional_names[i]); |
| 242 values[existing_size + i] = additional_values[i]; | 242 values[existing_size + i] = WebString::fromUTF16(additional_values[i]); |
| 243 } | 243 } |
| 244 | 244 |
| 245 existing_names->swap(names); | 245 existing_names->swap(names); |
| 246 existing_values->swap(values); | 246 existing_values->swap(values); |
| 247 } | 247 } |
| 248 #endif // BUILDFLAG(ENABLE_PLUGINS) | 248 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 249 | 249 |
| 250 #if BUILDFLAG(ENABLE_SPELLCHECK) | 250 #if BUILDFLAG(ENABLE_SPELLCHECK) |
| 251 class SpellCheckReplacer : public content::RenderViewVisitor { | 251 class SpellCheckReplacer : public content::RenderViewVisitor { |
| 252 public: | 252 public: |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (command_line->HasSwitch(switches::kEnableBenchmarking)) | 421 if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| 422 thread->RegisterExtension(extensions_v8::BenchmarkingExtension::Get()); | 422 thread->RegisterExtension(extensions_v8::BenchmarkingExtension::Get()); |
| 423 if (command_line->HasSwitch(switches::kEnableNetBenchmarking)) | 423 if (command_line->HasSwitch(switches::kEnableNetBenchmarking)) |
| 424 thread->RegisterExtension(extensions_v8::NetBenchmarkingExtension::Get()); | 424 thread->RegisterExtension(extensions_v8::NetBenchmarkingExtension::Get()); |
| 425 if (command_line->HasSwitch(switches::kInstantProcess)) | 425 if (command_line->HasSwitch(switches::kInstantProcess)) |
| 426 thread->RegisterExtension(extensions_v8::SearchBoxExtension::Get()); | 426 thread->RegisterExtension(extensions_v8::SearchBoxExtension::Get()); |
| 427 | 427 |
| 428 // chrome-search: and chrome-distiller: pages should not be accessible by | 428 // chrome-search: and chrome-distiller: pages should not be accessible by |
| 429 // normal content, and should also be unable to script anything but themselves | 429 // normal content, and should also be unable to script anything but themselves |
| 430 // (to help limit the damage that a corrupt page could cause). | 430 // (to help limit the damage that a corrupt page could cause). |
| 431 WebString chrome_search_scheme(ASCIIToUTF16(chrome::kChromeSearchScheme)); | 431 WebString chrome_search_scheme( |
| 432 WebString::fromASCII(chrome::kChromeSearchScheme)); |
| 432 | 433 |
| 433 // The Instant process can only display the content but not read it. Other | 434 // The Instant process can only display the content but not read it. Other |
| 434 // processes can't display it or read it. | 435 // processes can't display it or read it. |
| 435 if (!command_line->HasSwitch(switches::kInstantProcess)) | 436 if (!command_line->HasSwitch(switches::kInstantProcess)) |
| 436 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(chrome_search_scheme); | 437 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(chrome_search_scheme); |
| 437 | 438 |
| 438 WebString dom_distiller_scheme( | 439 WebString dom_distiller_scheme( |
| 439 ASCIIToUTF16(dom_distiller::kDomDistillerScheme)); | 440 WebString::fromASCII(dom_distiller::kDomDistillerScheme)); |
| 440 // TODO(nyquist): Add test to ensure this happens when the flag is set. | 441 // TODO(nyquist): Add test to ensure this happens when the flag is set. |
| 441 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(dom_distiller_scheme); | 442 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(dom_distiller_scheme); |
| 442 | 443 |
| 443 #if defined(OS_ANDROID) | 444 #if defined(OS_ANDROID) |
| 444 WebSecurityPolicy::registerURLSchemeAsAllowedForReferrer( | 445 WebSecurityPolicy::registerURLSchemeAsAllowedForReferrer( |
| 445 WebString::fromUTF8(chrome::kAndroidAppScheme)); | 446 WebString::fromUTF8(chrome::kAndroidAppScheme)); |
| 446 #endif | 447 #endif |
| 447 | 448 |
| 448 // chrome-search: pages should not be accessible by bookmarklets | 449 // chrome-search: pages should not be accessible by bookmarklets |
| 449 // or javascript: URLs typed in the omnibox. | 450 // or javascript: URLs typed in the omnibox. |
| 450 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs( | 451 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs( |
| 451 chrome_search_scheme); | 452 chrome_search_scheme); |
| 452 | 453 |
| 453 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 454 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 454 pdf_print_client_.reset(new ChromePDFPrintClient()); | 455 pdf_print_client_.reset(new ChromePDFPrintClient()); |
| 455 pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get()); | 456 pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get()); |
| 456 #endif | 457 #endif |
| 457 | 458 |
| 458 for (auto& origin : GetSecureOriginWhitelist()) { | 459 for (auto& origin : GetSecureOriginWhitelist()) { |
| 459 WebSecurityPolicy::addOriginTrustworthyWhiteList( | 460 WebSecurityPolicy::addOriginTrustworthyWhiteList( |
| 460 WebSecurityOrigin::create(origin)); | 461 WebSecurityOrigin::create(origin)); |
| 461 } | 462 } |
| 462 | 463 |
| 463 for (auto& scheme : GetSchemesBypassingSecureContextCheckWhitelist()) { | 464 for (auto& scheme : GetSchemesBypassingSecureContextCheckWhitelist()) { |
| 464 WebSecurityPolicy::addSchemeToBypassSecureContextWhitelist( | 465 WebSecurityPolicy::addSchemeToBypassSecureContextWhitelist( |
| 465 WebString::fromUTF8(scheme)); | 466 WebString::fromASCII(scheme)); |
| 466 } | 467 } |
| 467 | 468 |
| 468 #if defined(OS_CHROMEOS) | 469 #if defined(OS_CHROMEOS) |
| 469 leak_detector_remote_client_.reset(new LeakDetectorRemoteClient()); | 470 leak_detector_remote_client_.reset(new LeakDetectorRemoteClient()); |
| 470 thread->AddObserver(leak_detector_remote_client_.get()); | 471 thread->AddObserver(leak_detector_remote_client_.get()); |
| 471 #endif | 472 #endif |
| 472 } | 473 } |
| 473 | 474 |
| 474 void ChromeContentRendererClient::RenderFrameCreated( | 475 void ChromeContentRendererClient::RenderFrameCreated( |
| 475 content::RenderFrame* render_frame) { | 476 content::RenderFrame* render_frame) { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 void ChromeContentRendererClient::GetNavigationErrorStrings( | 1041 void ChromeContentRendererClient::GetNavigationErrorStrings( |
| 1041 content::RenderFrame* render_frame, | 1042 content::RenderFrame* render_frame, |
| 1042 const WebURLRequest& failed_request, | 1043 const WebURLRequest& failed_request, |
| 1043 const WebURLError& error, | 1044 const WebURLError& error, |
| 1044 std::string* error_html, | 1045 std::string* error_html, |
| 1045 base::string16* error_description) { | 1046 base::string16* error_description) { |
| 1046 const GURL failed_url = error.unreachableURL; | 1047 const GURL failed_url = error.unreachableURL; |
| 1047 | 1048 |
| 1048 bool is_post = base::EqualsASCII( | 1049 bool is_post = failed_request.httpMethod().ascii() == "POST"; |
| 1049 base::StringPiece16(failed_request.httpMethod()), "POST"); | |
| 1050 bool is_ignoring_cache = | 1050 bool is_ignoring_cache = |
| 1051 failed_request.getCachePolicy() == WebCachePolicy::BypassingCache; | 1051 failed_request.getCachePolicy() == WebCachePolicy::BypassingCache; |
| 1052 if (error_html) { | 1052 if (error_html) { |
| 1053 NetErrorHelper::Get(render_frame) | 1053 NetErrorHelper::Get(render_frame) |
| 1054 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); | 1054 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 if (error_description) { | 1057 if (error_description) { |
| 1058 *error_description = error_page::LocalizedError::GetErrorDetails( | 1058 *error_description = error_page::LocalizedError::GetErrorDetails( |
| 1059 error.domain.utf8(), error.reason, is_post); | 1059 error.domain.utf8(), error.reason, is_post); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 const GURL& url) { | 1368 const GURL& url) { |
| 1369 if (!rappor_recorder_) | 1369 if (!rappor_recorder_) |
| 1370 RenderThread::Get()->GetRemoteInterfaces()->GetInterface(&rappor_recorder_); | 1370 RenderThread::Get()->GetRemoteInterfaces()->GetInterface(&rappor_recorder_); |
| 1371 rappor_recorder_->RecordRapporURL(metric, url); | 1371 rappor_recorder_->RecordRapporURL(metric, url); |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 void ChromeContentRendererClient::AddImageContextMenuProperties( | 1374 void ChromeContentRendererClient::AddImageContextMenuProperties( |
| 1375 const WebURLResponse& response, | 1375 const WebURLResponse& response, |
| 1376 std::map<std::string, std::string>* properties) { | 1376 std::map<std::string, std::string>* properties) { |
| 1377 DCHECK(properties); | 1377 DCHECK(properties); |
| 1378 WebString header_key(ASCIIToUTF16( | 1378 WebString header_key(WebString::fromASCII( |
| 1379 data_reduction_proxy::chrome_proxy_content_transform_header())); | 1379 data_reduction_proxy::chrome_proxy_content_transform_header())); |
| 1380 if (!response.httpHeaderField(header_key).isNull() && | 1380 if (!response.httpHeaderField(header_key).isNull() && |
| 1381 data_reduction_proxy::IsEmptyImagePreview( | 1381 data_reduction_proxy::IsEmptyImagePreview( |
| 1382 response.httpHeaderField(header_key).utf8())) { | 1382 response.httpHeaderField(header_key).utf8())) { |
| 1383 (*properties)[ | 1383 (*properties)[ |
| 1384 data_reduction_proxy::chrome_proxy_content_transform_header()] = | 1384 data_reduction_proxy::chrome_proxy_content_transform_header()] = |
| 1385 data_reduction_proxy::empty_image_directive(); | 1385 data_reduction_proxy::empty_image_directive(); |
| 1386 } | 1386 } |
| 1387 } | 1387 } |
| 1388 | 1388 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 std::vector<base::SchedulerWorkerPoolParams>* params_vector, | 1510 std::vector<base::SchedulerWorkerPoolParams>* params_vector, |
| 1511 base::TaskScheduler::WorkerPoolIndexForTraitsCallback* | 1511 base::TaskScheduler::WorkerPoolIndexForTraitsCallback* |
| 1512 index_to_traits_callback) { | 1512 index_to_traits_callback) { |
| 1513 DCHECK(params_vector); | 1513 DCHECK(params_vector); |
| 1514 DCHECK(index_to_traits_callback); | 1514 DCHECK(index_to_traits_callback); |
| 1515 // If this call fails, content will fall back to the default params. | 1515 // If this call fails, content will fall back to the default params. |
| 1516 *params_vector = task_scheduler_util::GetRendererWorkerPoolParams(); | 1516 *params_vector = task_scheduler_util::GetRendererWorkerPoolParams(); |
| 1517 *index_to_traits_callback = | 1517 *index_to_traits_callback = |
| 1518 base::Bind(&task_scheduler_util::RendererWorkerPoolIndexForTraits); | 1518 base::Bind(&task_scheduler_util::RendererWorkerPoolIndexForTraits); |
| 1519 } | 1519 } |
| OLD | NEW |