| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/webview/webview_api.h" | 5 #include "chrome/browser/extensions/api/webview/webview_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
| 8 #include "chrome/browser/webview/webview_guest.h" | 8 #include "chrome/browser/webview/webview_guest.h" |
| 9 #include "chrome/common/extensions/api/webview.h" | 9 #include "chrome/common/extensions/api/webview.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (!guest) | 57 if (!guest) |
| 58 return NULL; | 58 return NULL; |
| 59 | 59 |
| 60 return guest->script_executor(); | 60 return guest->script_executor(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool WebviewExecuteCodeFunction::IsWebView() const { | 63 bool WebviewExecuteCodeFunction::IsWebView() const { |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 | 66 |
| 67 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { |
| 68 } |
| 69 |
| 67 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( | 70 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( |
| 68 const std::string& error, | 71 const std::string& error, |
| 69 int32 on_page_id, | 72 int32 on_page_id, |
| 70 const GURL& on_url, | 73 const GURL& on_url, |
| 71 const base::ListValue& result) { | 74 const base::ListValue& result) { |
| 72 content::RecordAction(content::UserMetricsAction("WebView.ExecuteScript")); | 75 content::RecordAction(content::UserMetricsAction("WebView.ExecuteScript")); |
| 73 if (error.empty()) | 76 if (error.empty()) |
| 74 SetResult(result.DeepCopy()); | 77 SetResult(result.DeepCopy()); |
| 75 WebviewExecuteCodeFunction::OnExecuteCodeFinished(error, on_page_id, on_url, | 78 WebviewExecuteCodeFunction::OnExecuteCodeFinished(error, on_page_id, on_url, |
| 76 result); | 79 result); |
| 77 } | 80 } |
| 78 | 81 |
| 82 WebviewInsertCSSFunction::WebviewInsertCSSFunction() { |
| 83 } |
| 84 |
| 79 bool WebviewInsertCSSFunction::ShouldInsertCSS() const { | 85 bool WebviewInsertCSSFunction::ShouldInsertCSS() const { |
| 80 return true; | 86 return true; |
| 81 } | 87 } |
| 82 | 88 |
| 89 WebviewGoFunction::WebviewGoFunction() { |
| 90 } |
| 91 |
| 92 WebviewGoFunction::~WebviewGoFunction() { |
| 93 } |
| 94 |
| 95 bool WebviewGoFunction::RunImpl() { |
| 96 int instance_id = 0; |
| 97 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); |
| 98 |
| 99 int relative_index = 0; |
| 100 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &relative_index)); |
| 101 |
| 102 WebViewGuest* guest = WebViewGuest::From( |
| 103 render_view_host()->GetProcess()->GetID(), instance_id); |
| 104 if (!guest) |
| 105 return false; |
| 106 |
| 107 guest->Go(relative_index); |
| 108 return true; |
| 109 } |
| OLD | NEW |