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

Unified Diff: extensions/browser/api/web_view/web_view_internal_api.cc

Issue 610643003: Adds new webview.loadDataWithBaseUrl API to allow data URLs to be loaded with a specified base URL … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment. Created 6 years, 3 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: extensions/browser/api/web_view/web_view_internal_api.cc
diff --git a/extensions/browser/api/web_view/web_view_internal_api.cc b/extensions/browser/api/web_view/web_view_internal_api.cc
index cbacf7e59d82c1ac7b827e5dd61c0d065416c5de..c6ed1ce79feac19142725755c0f7cf87516b0eda 100644
--- a/extensions/browser/api/web_view/web_view_internal_api.cc
+++ b/extensions/browser/api/web_view/web_view_internal_api.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/api/web_view/web_view_internal_api.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -300,6 +301,31 @@ bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) {
return true;
}
+WebViewInternalLoadDataWithBaseUrlFunction::
+ WebViewInternalLoadDataWithBaseUrlFunction() {
+}
+
+WebViewInternalLoadDataWithBaseUrlFunction::
+ ~WebViewInternalLoadDataWithBaseUrlFunction() {
+}
+
+bool WebViewInternalLoadDataWithBaseUrlFunction::RunAsyncSafe(
+ WebViewGuest* guest) {
+ scoped_ptr<webview::LoadDataWithBaseUrl::Params> params(
+ webview::LoadDataWithBaseUrl::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ // If a virtual URL was provided, use it. Otherwise, the user will be shown
+ // the data URL.
+ std::string virtual_url =
+ params->virtual_url ? *params->virtual_url : params->data_url;
+
+ bool successful = guest->LoadDataWithBaseURL(
+ params->data_url, params->base_url, virtual_url, &error_);
+ SendResponse(successful);
+ return successful;
+}
+
WebViewInternalGoFunction::WebViewInternalGoFunction() {
}
« no previous file with comments | « extensions/browser/api/web_view/web_view_internal_api.h ('k') | extensions/browser/extension_function_histogram_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698