| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/search/local_ntp_source.h" | 5 #include "chrome/browser/search/local_ntp_source.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 bool LocalNtpSource::AllowCaching() const { | 382 bool LocalNtpSource::AllowCaching() const { |
| 383 // Some resources served by LocalNtpSource, i.e. config.js, are dynamically | 383 // Some resources served by LocalNtpSource, i.e. config.js, are dynamically |
| 384 // generated and could differ on each access. To avoid using old cached | 384 // generated and could differ on each access. To avoid using old cached |
| 385 // content on reload, disallow caching here. Otherwise, it fails to reflect | 385 // content on reload, disallow caching here. Otherwise, it fails to reflect |
| 386 // newly revised user configurations in the page. | 386 // newly revised user configurations in the page. |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool LocalNtpSource::ShouldServiceRequest( | 390 bool LocalNtpSource::ShouldServiceRequest( |
| 391 const net::URLRequest* request) const { | 391 const GURL& url, |
| 392 content::ResourceContext* resource_context, |
| 393 int render_process_id) const { |
| 392 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 394 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 393 | 395 |
| 394 DCHECK(request->url().host_piece() == chrome::kChromeSearchLocalNtpHost); | 396 DCHECK(url.host_piece() == chrome::kChromeSearchLocalNtpHost); |
| 395 if (!InstantIOContext::ShouldServiceRequest(request)) | 397 if (!InstantIOContext::ShouldServiceRequest(url, resource_context, |
| 398 render_process_id)) { |
| 396 return false; | 399 return false; |
| 400 } |
| 397 | 401 |
| 398 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 402 if (url.SchemeIs(chrome::kChromeSearchScheme)) { |
| 399 std::string filename; | 403 std::string filename; |
| 400 webui::ParsePathAndScale(request->url(), &filename, nullptr); | 404 webui::ParsePathAndScale(url, &filename, nullptr); |
| 401 for (size_t i = 0; i < arraysize(kResources); ++i) { | 405 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 402 if (filename == kResources[i].filename) | 406 if (filename == kResources[i].filename) |
| 403 return true; | 407 return true; |
| 404 } | 408 } |
| 405 } | 409 } |
| 406 return false; | 410 return false; |
| 407 } | 411 } |
| 408 | 412 |
| 409 std::string LocalNtpSource::GetContentSecurityPolicyScriptSrc() const { | 413 std::string LocalNtpSource::GetContentSecurityPolicyScriptSrc() const { |
| 410 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 414 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 base::Bind(&LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread, | 491 base::Bind(&LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread, |
| 488 weak_ptr_factory_.GetWeakPtr(), is_google)); | 492 weak_ptr_factory_.GetWeakPtr(), is_google)); |
| 489 } | 493 } |
| 490 | 494 |
| 491 void LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread( | 495 void LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread( |
| 492 bool is_google) { | 496 bool is_google) { |
| 493 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 497 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 494 | 498 |
| 495 default_search_provider_is_google_io_thread_ = is_google; | 499 default_search_provider_is_google_io_thread_ = is_google; |
| 496 } | 500 } |
| OLD | NEW |