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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" | 8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" |
9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" | 9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" |
10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers.
h" | 10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers.
h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Will finish asynchronously. | 240 // Will finish asynchronously. |
241 return true; | 241 return true; |
242 } | 242 } |
243 | 243 |
244 void WebviewClearDataFunction::ClearDataDone() { | 244 void WebviewClearDataFunction::ClearDataDone() { |
245 Release(); // Balanced in RunImpl(). | 245 Release(); // Balanced in RunImpl(). |
246 SendResponse(true); | 246 SendResponse(true); |
247 } | 247 } |
248 | 248 |
249 WebviewExecuteCodeFunction::WebviewExecuteCodeFunction() | 249 WebviewExecuteCodeFunction::WebviewExecuteCodeFunction() |
250 : guest_instance_id_(0) { | 250 : guest_instance_id_(0), guest_src_(GURL::EmptyGURL()) {} |
251 } | |
252 | 251 |
253 WebviewExecuteCodeFunction::~WebviewExecuteCodeFunction() { | 252 WebviewExecuteCodeFunction::~WebviewExecuteCodeFunction() { |
254 } | 253 } |
255 | 254 |
256 bool WebviewExecuteCodeFunction::Init() { | 255 bool WebviewExecuteCodeFunction::Init() { |
257 if (details_.get()) | 256 if (details_.get()) |
258 return true; | 257 return true; |
259 | 258 |
260 if (!args_->GetInteger(0, &guest_instance_id_)) | 259 if (!args_->GetInteger(0, &guest_instance_id_)) |
261 return false; | 260 return false; |
262 | 261 |
263 if (!guest_instance_id_) | 262 if (!guest_instance_id_) |
264 return false; | 263 return false; |
265 | 264 |
| 265 std::string src; |
| 266 if (!args_->GetString(1, &src)) |
| 267 return false; |
| 268 |
| 269 guest_src_ = GURL(src); |
| 270 if (!guest_src_.is_valid()) |
| 271 return false; |
| 272 |
266 base::DictionaryValue* details_value = NULL; | 273 base::DictionaryValue* details_value = NULL; |
267 if (!args_->GetDictionary(1, &details_value)) | 274 if (!args_->GetDictionary(2, &details_value)) |
268 return false; | 275 return false; |
269 scoped_ptr<InjectDetails> details(new InjectDetails()); | 276 scoped_ptr<InjectDetails> details(new InjectDetails()); |
270 if (!InjectDetails::Populate(*details_value, details.get())) | 277 if (!InjectDetails::Populate(*details_value, details.get())) |
271 return false; | 278 return false; |
272 | 279 |
273 details_ = details.Pass(); | 280 details_ = details.Pass(); |
274 return true; | 281 return true; |
275 } | 282 } |
276 | 283 |
277 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { | 284 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { |
(...skipping 10 matching lines...) Expand all Loading... |
288 if (!guest) | 295 if (!guest) |
289 return NULL; | 296 return NULL; |
290 | 297 |
291 return guest->script_executor(); | 298 return guest->script_executor(); |
292 } | 299 } |
293 | 300 |
294 bool WebviewExecuteCodeFunction::IsWebView() const { | 301 bool WebviewExecuteCodeFunction::IsWebView() const { |
295 return true; | 302 return true; |
296 } | 303 } |
297 | 304 |
| 305 const GURL& WebviewExecuteCodeFunction::GetWebViewSrc() const { |
| 306 return guest_src_; |
| 307 } |
| 308 |
298 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { | 309 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { |
299 } | 310 } |
300 | 311 |
301 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( | 312 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( |
302 const std::string& error, | 313 const std::string& error, |
303 int32 on_page_id, | 314 int32 on_page_id, |
304 const GURL& on_url, | 315 const GURL& on_url, |
305 const base::ListValue& result) { | 316 const base::ListValue& result) { |
306 if (error.empty()) | 317 if (error.empty()) |
307 SetResult(result.DeepCopy()); | 318 SetResult(result.DeepCopy()); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 539 |
529 WebviewTerminateFunction::~WebviewTerminateFunction() { | 540 WebviewTerminateFunction::~WebviewTerminateFunction() { |
530 } | 541 } |
531 | 542 |
532 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) { | 543 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) { |
533 guest->Terminate(); | 544 guest->Terminate(); |
534 return true; | 545 return true; |
535 } | 546 } |
536 | 547 |
537 } // namespace extensions | 548 } // namespace extensions |
OLD | NEW |