| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "components/test_runner/test_runner.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 |  | 
| 9 #include <limits> | 8 #include <limits> | 
|  | 9 #include <utility> | 
| 10 | 10 | 
| 11 #include "base/logging.h" | 11 #include "base/logging.h" | 
| 12 #include "base/macros.h" | 12 #include "base/macros.h" | 
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" | 
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" | 
| 15 #include "components/test_runner/mock_credential_manager_client.h" | 15 #include "components/test_runner/mock_credential_manager_client.h" | 
| 16 #include "components/test_runner/mock_web_speech_recognizer.h" | 16 #include "components/test_runner/mock_web_speech_recognizer.h" | 
| 17 #include "components/test_runner/test_interfaces.h" | 17 #include "components/test_runner/test_interfaces.h" | 
| 18 #include "components/test_runner/test_preferences.h" | 18 #include "components/test_runner/test_preferences.h" | 
| 19 #include "components/test_runner/web_content_settings.h" | 19 #include "components/test_runner/web_content_settings.h" | 
| (...skipping 3017 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3037       new InvokeCallbackTask(this, callback)); | 3037       new InvokeCallbackTask(this, callback)); | 
| 3038   proxy_->CopyImageAtAndCapturePixels( | 3038   proxy_->CopyImageAtAndCapturePixels( | 
| 3039       x, y, base::Bind(&TestRunner::CapturePixelsCallback, | 3039       x, y, base::Bind(&TestRunner::CapturePixelsCallback, | 
| 3040                        weak_factory_.GetWeakPtr(), | 3040                        weak_factory_.GetWeakPtr(), | 
| 3041                        base::Passed(&task))); | 3041                        base::Passed(&task))); | 
| 3042 } | 3042 } | 
| 3043 | 3043 | 
| 3044 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task, | 3044 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task, | 
| 3045                                      const blink::WebURLResponse& response, | 3045                                      const blink::WebURLResponse& response, | 
| 3046                                      const std::string& data) { | 3046                                      const std::string& data) { | 
| 3047   InvokeCallback(task.Pass()); | 3047   InvokeCallback(std::move(task)); | 
| 3048 } | 3048 } | 
| 3049 | 3049 | 
| 3050 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, | 3050 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, | 
| 3051                                        const SkBitmap& snapshot) { | 3051                                        const SkBitmap& snapshot) { | 
| 3052   v8::Isolate* isolate = blink::mainThreadIsolate(); | 3052   v8::Isolate* isolate = blink::mainThreadIsolate(); | 
| 3053   v8::HandleScope handle_scope(isolate); | 3053   v8::HandleScope handle_scope(isolate); | 
| 3054 | 3054 | 
| 3055   v8::Local<v8::Context> context = | 3055   v8::Local<v8::Context> context = | 
| 3056       web_view_->mainFrame()->mainWorldScriptContext(); | 3056       web_view_->mainFrame()->mainWorldScriptContext(); | 
| 3057   if (context.IsEmpty()) | 3057   if (context.IsEmpty()) | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 3081     for (unsigned i = 0; i < len; i += 4) { | 3081     for (unsigned i = 0; i < len; i += 4) { | 
| 3082       std::swap(pixels[i], pixels[i + 2]); | 3082       std::swap(pixels[i], pixels[i + 2]); | 
| 3083     } | 3083     } | 
| 3084   } | 3084   } | 
| 3085 #endif | 3085 #endif | 
| 3086 | 3086 | 
| 3087   argv[2] = blink::WebArrayBufferConverter::toV8Value( | 3087   argv[2] = blink::WebArrayBufferConverter::toV8Value( | 
| 3088       &buffer, context->Global(), isolate); | 3088       &buffer, context->Global(), isolate); | 
| 3089 | 3089 | 
| 3090   task->SetArguments(3, argv); | 3090   task->SetArguments(3, argv); | 
| 3091   InvokeCallback(task.Pass()); | 3091   InvokeCallback(std::move(task)); | 
| 3092 } | 3092 } | 
| 3093 | 3093 | 
| 3094 void TestRunner::DispatchBeforeInstallPromptCallback( | 3094 void TestRunner::DispatchBeforeInstallPromptCallback( | 
| 3095     scoped_ptr<InvokeCallbackTask> task, | 3095     scoped_ptr<InvokeCallbackTask> task, | 
| 3096     bool canceled) { | 3096     bool canceled) { | 
| 3097   v8::Isolate* isolate = blink::mainThreadIsolate(); | 3097   v8::Isolate* isolate = blink::mainThreadIsolate(); | 
| 3098   v8::HandleScope handle_scope(isolate); | 3098   v8::HandleScope handle_scope(isolate); | 
| 3099 | 3099 | 
| 3100   v8::Local<v8::Context> context = | 3100   v8::Local<v8::Context> context = | 
| 3101       web_view_->mainFrame()->mainWorldScriptContext(); | 3101       web_view_->mainFrame()->mainWorldScriptContext(); | 
| 3102   if (context.IsEmpty()) | 3102   if (context.IsEmpty()) | 
| 3103     return; | 3103     return; | 
| 3104 | 3104 | 
| 3105   v8::Context::Scope context_scope(context); | 3105   v8::Context::Scope context_scope(context); | 
| 3106   v8::Local<v8::Value> argv[1]; | 3106   v8::Local<v8::Value> argv[1]; | 
| 3107   argv[0] = v8::Boolean::New(isolate, canceled); | 3107   argv[0] = v8::Boolean::New(isolate, canceled); | 
| 3108 | 3108 | 
| 3109   task->SetArguments(1, argv); | 3109   task->SetArguments(1, argv); | 
| 3110   InvokeCallback(task.Pass()); | 3110   InvokeCallback(std::move(task)); | 
| 3111 } | 3111 } | 
| 3112 | 3112 | 
| 3113 void TestRunner::GetBluetoothManualChooserEventsCallback( | 3113 void TestRunner::GetBluetoothManualChooserEventsCallback( | 
| 3114     scoped_ptr<InvokeCallbackTask> task, | 3114     scoped_ptr<InvokeCallbackTask> task, | 
| 3115     const std::vector<std::string>& events) { | 3115     const std::vector<std::string>& events) { | 
| 3116   // Build the V8 context. | 3116   // Build the V8 context. | 
| 3117   v8::Isolate* isolate = blink::mainThreadIsolate(); | 3117   v8::Isolate* isolate = blink::mainThreadIsolate(); | 
| 3118   v8::HandleScope handle_scope(isolate); | 3118   v8::HandleScope handle_scope(isolate); | 
| 3119   v8::Local<v8::Context> context = | 3119   v8::Local<v8::Context> context = | 
| 3120       web_view_->mainFrame()->mainWorldScriptContext(); | 3120       web_view_->mainFrame()->mainWorldScriptContext(); | 
| 3121   if (context.IsEmpty()) | 3121   if (context.IsEmpty()) | 
| 3122     return; | 3122     return; | 
| 3123   v8::Context::Scope context_scope(context); | 3123   v8::Context::Scope context_scope(context); | 
| 3124 | 3124 | 
| 3125   // Convert the argument. | 3125   // Convert the argument. | 
| 3126   v8::Local<v8::Value> arg[1]; | 3126   v8::Local<v8::Value> arg[1]; | 
| 3127   if (!gin::TryConvertToV8(isolate, events, &arg[0])) | 3127   if (!gin::TryConvertToV8(isolate, events, &arg[0])) | 
| 3128     return; | 3128     return; | 
| 3129 | 3129 | 
| 3130   // Call the callback. | 3130   // Call the callback. | 
| 3131   task->SetArguments(1, arg); | 3131   task->SetArguments(1, arg); | 
| 3132   InvokeCallback(task.Pass()); | 3132   InvokeCallback(std::move(task)); | 
| 3133 } | 3133 } | 
| 3134 | 3134 | 
| 3135 void TestRunner::LocationChangeDone() { | 3135 void TestRunner::LocationChangeDone() { | 
| 3136   web_history_item_count_ = delegate_->NavigationEntryCount(); | 3136   web_history_item_count_ = delegate_->NavigationEntryCount(); | 
| 3137 | 3137 | 
| 3138   // No more new work after the first complete load. | 3138   // No more new work after the first complete load. | 
| 3139   work_queue_.set_frozen(true); | 3139   work_queue_.set_frozen(true); | 
| 3140 | 3140 | 
| 3141   if (!wait_until_done_) | 3141   if (!wait_until_done_) | 
| 3142     work_queue_.ProcessWorkSoon(); | 3142     work_queue_.ProcessWorkSoon(); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3179 } | 3179 } | 
| 3180 | 3180 | 
| 3181 void TestRunner::DidLosePointerLockInternal() { | 3181 void TestRunner::DidLosePointerLockInternal() { | 
| 3182   bool was_locked = pointer_locked_; | 3182   bool was_locked = pointer_locked_; | 
| 3183   pointer_locked_ = false; | 3183   pointer_locked_ = false; | 
| 3184   if (was_locked) | 3184   if (was_locked) | 
| 3185     web_view_->didLosePointerLock(); | 3185     web_view_->didLosePointerLock(); | 
| 3186 } | 3186 } | 
| 3187 | 3187 | 
| 3188 }  // namespace test_runner | 3188 }  // namespace test_runner | 
| OLD | NEW | 
|---|