Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / api / web_view / web_view_internal_api.cc
index cbacf7e..8238940 100644 (file)
@@ -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"
@@ -64,7 +65,7 @@ bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) {
       webview::Navigate::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
   std::string src = params->src;
-  guest->NavigateGuest(src);
+  guest->NavigateGuest(src, true /* force_navigation */);
   return true;
 }
 
@@ -114,6 +115,8 @@ bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() {
 
 extensions::ScriptExecutor*
 WebViewInternalExecuteCodeFunction::GetScriptExecutor() {
+  if (!render_view_host() || !render_view_host()->GetProcess())
+    return NULL;
   WebViewGuest* guest = WebViewGuest::From(
       render_view_host()->GetProcess()->GetID(), guest_instance_id_);
   if (!guest)
@@ -150,30 +153,6 @@ bool WebViewInternalInsertCSSFunction::ShouldInsertCSS() const {
   return true;
 }
 
-WebViewInternalCaptureVisibleRegionFunction::
-    WebViewInternalCaptureVisibleRegionFunction() {
-}
-
-WebViewInternalCaptureVisibleRegionFunction::
-    ~WebViewInternalCaptureVisibleRegionFunction() {
-}
-
-bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() {
-  return true;
-}
-
-WebContents* WebViewInternalCaptureVisibleRegionFunction::GetWebContentsForID(
-    int instance_id) {
-  WebViewGuest* guest = WebViewGuest::From(
-      render_view_host()->GetProcess()->GetID(), instance_id);
-  return guest ? guest->web_contents() : NULL;
-}
-
-void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure(
-    FailureReason reason) {
-  SendResponse(false);
-}
-
 WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() {
 }
 
@@ -265,7 +244,7 @@ bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) {
         params->options->match_case ? *params->options->match_case : false;
   }
 
-  guest->Find(search_text, options, this);
+  guest->StartFinding(search_text, options, this);
   return true;
 }
 
@@ -300,6 +279,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() {
 }
 
@@ -310,7 +314,9 @@ bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) {
   scoped_ptr<webview::Go::Params> params(webview::Go::Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params.get());
 
-  guest->Go(params->relative_index);
+  bool successful = guest->Go(params->relative_index);
+  SetResult(new base::FundamentalValue(successful));
+  SendResponse(true);
   return true;
 }