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

Unified Diff: chrome/browser/ui/webui/test_files_request_filter.cc

Issue 1536553002: Remove InlineLoginHandlerChromeOS and exclude InlineLoginUI from CrOS build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge conflicts resolved. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/test_files_request_filter.cc
diff --git a/chrome/browser/ui/webui/test_files_request_filter.cc b/chrome/browser/ui/webui/test_files_request_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a57b48124af0c8ef2ee258664101970079066dd
--- /dev/null
+++ b/chrome/browser/ui/webui/test_files_request_filter.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 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.
+
+#include "chrome/browser/ui/webui/test_files_request_filter.h"
+
+#include "base/bind.h"
+#include "base/files/file_util.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/path_service.h"
+#include "base/strings/string_split.h"
+#include "chrome/common/chrome_paths.h"
+
+namespace {
+
+bool HandleTestFileRequestCallback(
+ const std::string& path,
+ const content::WebUIDataSource::GotDataCallback& callback) {
+ std::vector<std::string> url_substr =
+ base::SplitString(path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ if (url_substr.size() != 2 || url_substr[0] != "test")
+ return false;
+
+ std::string contents;
+ base::FilePath test_data_dir;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ if (!base::ReadFileToString(
+ test_data_dir.AppendASCII("webui").AppendASCII(url_substr[1]),
+ &contents, std::string::npos))
+ return false;
+
+ base::RefCountedString* ref_contents = new base::RefCountedString();
+ ref_contents->data() = contents;
+ callback.Run(ref_contents);
+ return true;
+}
+
+} // namespace
+
+namespace test {
+
+content::WebUIDataSource::HandleRequestCallback GetTestFilesRequestFilter() {
+ return base::Bind(&HandleTestFileRequestCallback);
+}
+
+} // namespace test
« no previous file with comments | « chrome/browser/ui/webui/test_files_request_filter.h ('k') | chrome/browser/ui/webui/webui_webview_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698