diff options
author | kelvinp <kelvinp@chromium.org> | 2015-11-12 12:08:34 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-12 20:09:28 +0000 |
commit | c4f7330abe94c5b80ec82ae9c312ad7ae52318b0 (patch) | |
tree | fa8d068ce6ff4e2975312a025992e91b32ed7a77 /chrome | |
parent | f65f801a619ad7af7446dd33809be44bc30ceb51 (diff) | |
download | chromium_src-c4f7330abe94c5b80ec82ae9c312ad7ae52318b0.zip chromium_src-c4f7330abe94c5b80ec82ae9c312ad7ae52318b0.tar.gz chromium_src-c4f7330abe94c5b80ec82ae9c312ad7ae52318b0.tar.bz2 |
Revert of Enabling included files when reloading local NTP with --local-ntp-reload. (patchset #7 id:120001 of https://codereview.chromium.org/1376243005/ )
Reason for revert:
Break iOS Device ninja Build Bot
https://build.chromium.org/p/chromium.mac/builders/iOS_Device_%28ninja%29/builds/29414
Compilation failed as
In file included from ../../chrome/browser/search/local_files_ntp_source.cc:19:
../../third_party/re2/re2/re2.h:186:10: fatal error: 're2/stringpiece.h' file not found
#include "re2/stringpiece.h"
which is added in this CL.
Original issue's description:
> Enabling included files when reloading local NTP with --local-ntp-reload.
TBR=fserb@chromium.org,mathp@chromium.org,tmartino@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1442793002
Cr-Commit-Position: refs/heads/master@{#359364}
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/search/local_files_ntp_source.cc | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/chrome/browser/search/local_files_ntp_source.cc b/chrome/browser/search/local_files_ntp_source.cc index 16350a4..cb017d9 100644 --- a/chrome/browser/search/local_files_ntp_source.cc +++ b/chrome/browser/search/local_files_ntp_source.cc @@ -16,16 +16,11 @@ #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, const content::URLDataSource::GotDataCallback& callback, @@ -52,53 +47,6 @@ std::string ReadFileAndReturn(const base::FilePath& path) { 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) { @@ -112,12 +60,10 @@ void SendLocalFileResourceWithOrigin( 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 |