| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/test_runner/test_runner_for_specific_view.h" | 5 #include "components/test_runner/test_runner_for_specific_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void TestRunnerForSpecificView::SetBluetoothManualChooser(bool enable) { | 359 void TestRunnerForSpecificView::SetBluetoothManualChooser(bool enable) { |
| 360 delegate()->SetBluetoothManualChooser(enable); | 360 delegate()->SetBluetoothManualChooser(enable); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void TestRunnerForSpecificView::SendBluetoothManualChooserEvent( | 363 void TestRunnerForSpecificView::SendBluetoothManualChooserEvent( |
| 364 const std::string& event, | 364 const std::string& event, |
| 365 const std::string& argument) { | 365 const std::string& argument) { |
| 366 delegate()->SendBluetoothManualChooserEvent(event, argument); | 366 delegate()->SendBluetoothManualChooserEvent(event, argument); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void TestRunnerForSpecificView::GetAllPaymentAppIDs( |
| 370 v8::Local<v8::Function> callback) { |
| 371 delegate()->GetAllPaymentAppIDs( |
| 372 base::Bind(&TestRunnerForSpecificView::GetAllPaymentAppIDsCallback, |
| 373 weak_factory_.GetWeakPtr(), |
| 374 base::Passed(v8::UniquePersistent<v8::Function>( |
| 375 blink::mainThreadIsolate(), callback)))); |
| 376 } |
| 377 |
| 378 void TestRunnerForSpecificView::GetAllPaymentAppIDsCallback( |
| 379 v8::UniquePersistent<v8::Function> callback, |
| 380 const std::vector<int64_t>& ids) { |
| 381 // Build the V8 context. |
| 382 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 383 v8::HandleScope handle_scope(isolate); |
| 384 v8::Local<v8::Context> context = |
| 385 web_view()->mainFrame()->mainWorldScriptContext(); |
| 386 if (context.IsEmpty()) |
| 387 return; |
| 388 v8::Context::Scope context_scope(context); |
| 389 |
| 390 // Convert the argument. |
| 391 v8::Local<v8::Value> arg; |
| 392 if (!gin::TryConvertToV8(isolate, ids, &arg)) |
| 393 return; |
| 394 |
| 395 // Call the callback. |
| 396 PostV8CallbackWithArgs(std::move(callback), 1, &arg); |
| 397 } |
| 398 |
| 399 void TestRunnerForSpecificView::InvokePaymentApp(int64_t registration_id) { |
| 400 delegate()->InvokePaymentApp(registration_id); |
| 401 } |
| 402 |
| 369 void TestRunnerForSpecificView::SetBackingScaleFactor( | 403 void TestRunnerForSpecificView::SetBackingScaleFactor( |
| 370 double value, | 404 double value, |
| 371 v8::Local<v8::Function> callback) { | 405 v8::Local<v8::Function> callback) { |
| 372 delegate()->SetDeviceScaleFactor(value); | 406 delegate()->SetDeviceScaleFactor(value); |
| 373 | 407 |
| 374 // TODO(oshima): remove this callback argument when all platforms are migrated | 408 // TODO(oshima): remove this callback argument when all platforms are migrated |
| 375 // to use-zoom-for-dsf by default | 409 // to use-zoom-for-dsf by default |
| 376 v8::UniquePersistent<v8::Function> global_callback(blink::mainThreadIsolate(), | 410 v8::UniquePersistent<v8::Function> global_callback(blink::mainThreadIsolate(), |
| 377 callback); | 411 callback); |
| 378 v8::Local<v8::Value> arg = v8::Boolean::New( | 412 v8::Local<v8::Value> arg = v8::Boolean::New( |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 725 |
| 692 blink::WebView* TestRunnerForSpecificView::web_view() { | 726 blink::WebView* TestRunnerForSpecificView::web_view() { |
| 693 return web_view_test_proxy_base_->web_view(); | 727 return web_view_test_proxy_base_->web_view(); |
| 694 } | 728 } |
| 695 | 729 |
| 696 WebTestDelegate* TestRunnerForSpecificView::delegate() { | 730 WebTestDelegate* TestRunnerForSpecificView::delegate() { |
| 697 return web_view_test_proxy_base_->delegate(); | 731 return web_view_test_proxy_base_->delegate(); |
| 698 } | 732 } |
| 699 | 733 |
| 700 } // namespace test_runner | 734 } // namespace test_runner |
| OLD | NEW |