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

Unified Diff: chrome/browser/search/local_files_ntp_source.cc

Issue 1450533002: Revert of Enabling included files when reloading local NTP with --local-ntp-reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/local_files_ntp_source.h ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/local_files_ntp_source.cc
diff --git a/chrome/browser/search/local_files_ntp_source.cc b/chrome/browser/search/local_files_ntp_source.cc
index e126a1cfbb1d0b8ff651290a2096e56272ab24b8..cb017d975a5e618650ac27595448b077d998f7c5 100644
--- a/chrome/browser/search/local_files_ntp_source.cc
+++ b/chrome/browser/search/local_files_ntp_source.cc
@@ -1,8 +1,6 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-#if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
#include "chrome/browser/search/local_files_ntp_source.h"
@@ -18,15 +16,10 @@
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/url_data_source.h"
-#include "third_party/re2/re2/re2.h"
-#include "third_party/re2/re2/stringpiece.h"
namespace {
const char kBasePath[] = "chrome/browser/resources/local_ntp";
-
-// Matches lines of form '<include src="foo">' and captures 'foo'.
-const char kInlineResourceRegex[] = "<include.*?src\\=[\"'](.+?)[\"'].*?>";
void CallbackWithLoadedResource(
const std::string& origin,
@@ -54,53 +47,6 @@
namespace local_ntp {
-void FlattenLocalInclude(
- const content::URLDataSource::GotDataCallback& callback,
- std::string topLevelResource,
- base::RefCountedMemory* inlineResource);
-
-// Helper method invoked by both CheckLocalIncludes and FlattenLocalInclude.
-// Checks for any <include> directives; if any are found, loads the associated
-// file and calls FlattenLocalInclude with the result. Otherwise, processing
-// is done, and so the original callback is invoked.
-void CheckLocalIncludesHelper(
- const content::URLDataSource::GotDataCallback& callback,
- std::string& resource) {
- std::string filename;
- re2::StringPiece resourceWrapper(resource);
- if (re2::RE2::FindAndConsume(&resourceWrapper, kInlineResourceRegex,
- &filename)) {
- content::URLDataSource::GotDataCallback wrapper =
- base::Bind(&FlattenLocalInclude, callback, resource);
- SendLocalFileResource(filename, wrapper);
- } else {
- callback.Run(base::RefCountedString::TakeString(&resource));
- }
-}
-
-// Wrapper around the above helper function for use as a callback. Processes
-// local files to inline any files indicated by an <include> directive.
-void CheckLocalIncludes(
- const content::URLDataSource::GotDataCallback& callback,
- base::RefCountedMemory* resource) {
- std::string resourceAsStr(resource->front_as<char>(), resource->size());
- CheckLocalIncludesHelper(callback, resourceAsStr);
-}
-
-// Replaces the first <include> directive found with the given file contents.
-// Afterwards, re-invokes CheckLocalIncludesHelper to handle any subsequent
-// <include>s, including those which may have been added by the newly-inlined
-// resource.
-void FlattenLocalInclude(
- const content::URLDataSource::GotDataCallback& callback,
- std::string topLevelResource,
- base::RefCountedMemory* inlineResource) {
- std::string inlineAsStr(inlineResource->front_as<char>(),
- inlineResource->size());
- re2::RE2::Replace(&topLevelResource, kInlineResourceRegex, inlineAsStr);
- CheckLocalIncludesHelper(callback, topLevelResource);
-}
-
void SendLocalFileResource(
const std::string& path,
const content::URLDataSource::GotDataCallback& callback) {
@@ -114,14 +60,10 @@
base::FilePath fullpath;
PathService::Get(base::DIR_SOURCE_ROOT, &fullpath);
fullpath = fullpath.AppendASCII(kBasePath).AppendASCII(path);
- content::URLDataSource::GotDataCallback wrapper =
- base::Bind(&CheckLocalIncludes, callback);
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(), FROM_HERE,
base::Bind(&ReadFileAndReturn, fullpath),
- base::Bind(&CallbackWithLoadedResource, origin, wrapper));
+ base::Bind(&CallbackWithLoadedResource, origin, callback));
}
} // namespace local_ntp
-
-#endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
« no previous file with comments | « chrome/browser/search/local_files_ntp_source.h ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698