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

Side by Side Diff: chrome/browser/search/local_ntp_source.cc

Issue 2856093004: Generalize content::URLDataSource so that it can be used by the network service. (Closed)
Patch Set: review comments Created 3 years, 7 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
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698