summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorloyso <loyso@chromium.org>2015-11-13 14:01:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-13 22:02:22 +0000
commit374a357e8eca60427a1d3907027614781af02db1 (patch)
tree4989872864f8af5eefac5309f65250524a323851
parent34c412ca66485c3d57bdc925526f5666d677d430 (diff)
downloadchromium_src-374a357e8eca60427a1d3907027614781af02db1.zip
chromium_src-374a357e8eca60427a1d3907027614781af02db1.tar.gz
chromium_src-374a357e8eca60427a1d3907027614781af02db1.tar.bz2
Revert of Enabling included files when reloading local NTP with --local-ntp-reload. (patchset #9 id:160001 of https://codereview.chromium.org/1376243005/ )
Reason for revert: Fails iOS build. ../third_party/re2/re2/re2.h:186:10: fatal error: 're2/stringpiece.h' file not found #include "re2/stringpiece.h" ^ 1 error generated. Original issue's description: > Enabling included files when reloading local NTP with --local-ntp-reload. > > Committed: https://crrev.com/5788cd432cc28372aa85a57cd7a66e6b6699db74 > Cr-Commit-Position: refs/heads/master@{#359357} > > Committed: https://crrev.com/9eafb7d4f9b985163c30354e1c7e34a9b447c275 > Cr-Commit-Position: refs/heads/master@{#359650} TBR=fserb@chromium.org,mathp@chromium.org,tmartino@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1450533002 Cr-Commit-Position: refs/heads/master@{#359653}
-rw-r--r--chrome/browser/search/local_files_ntp_source.cc60
-rw-r--r--chrome/browser/search/local_files_ntp_source.h3
-rw-r--r--chrome/browser/search/local_ntp_source.cc4
3 files changed, 3 insertions, 64 deletions
diff --git a/chrome/browser/search/local_files_ntp_source.cc b/chrome/browser/search/local_files_ntp_source.cc
index e126a1c..cb017d9 100644
--- a/chrome/browser/search/local_files_ntp_source.cc
+++ b/chrome/browser/search/local_files_ntp_source.cc
@@ -2,8 +2,6 @@
// 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"
#include "base/bind.h"
@@ -18,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,
@@ -54,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) {
@@ -114,14 +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
-
-#endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
diff --git a/chrome/browser/search/local_files_ntp_source.h b/chrome/browser/search/local_files_ntp_source.h
index c71041b..aef34a3 100644
--- a/chrome/browser/search/local_files_ntp_source.h
+++ b/chrome/browser/search/local_files_ntp_source.h
@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_SEARCH_LOCAL_FILES_NTP_SOURCE_H_
#define CHROME_BROWSER_SEARCH_LOCAL_FILES_NTP_SOURCE_H_
-#if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
-
#include <string>
#include "content/public/browser/url_data_source.h"
@@ -28,5 +26,4 @@ void SendLocalFileResourceWithOrigin(
} // namespace local_ntp
-#endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
#endif // CHROME_BROWSER_SEARCH_LOCAL_FILES_NTP_SOURCE_H_
diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc
index 260ae785..95b1c0e 100644
--- a/chrome/browser/search/local_ntp_source.cc
+++ b/chrome/browser/search/local_ntp_source.cc
@@ -208,7 +208,7 @@ void LocalNtpSource::StartDataRequest(
return;
}
-#if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
+#if !defined(GOOGLE_CHROME_BUILD)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kLocalNtpReload)) {
if (stripped_path == "local-ntp.html" || stripped_path == "local-ntp.js" ||
@@ -218,7 +218,7 @@ void LocalNtpSource::StartDataRequest(
return;
}
}
-#endif // !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS)
+#endif
float scale = 1.0f;
std::string filename;