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 "content/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "content/child/push_messaging/push_provider.h" | 45 #include "content/child/push_messaging/push_provider.h" |
46 #include "content/child/thread_safe_sender.h" | 46 #include "content/child/thread_safe_sender.h" |
47 #include "content/child/web_url_loader_impl.h" | 47 #include "content/child/web_url_loader_impl.h" |
48 #include "content/child/web_url_request_util.h" | 48 #include "content/child/web_url_request_util.h" |
49 #include "content/child/worker_thread_registry.h" | 49 #include "content/child/worker_thread_registry.h" |
50 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
51 #include "content/public/common/service_manager_connection.h" | 51 #include "content/public/common/service_manager_connection.h" |
52 #include "net/base/net_errors.h" | 52 #include "net/base/net_errors.h" |
53 #include "third_party/WebKit/public/platform/WebData.h" | 53 #include "third_party/WebKit/public/platform/WebData.h" |
54 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 54 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 55 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
55 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 56 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
56 #include "third_party/WebKit/public/platform/WebString.h" | 57 #include "third_party/WebKit/public/platform/WebString.h" |
57 #include "third_party/WebKit/public/platform/WebURL.h" | 58 #include "third_party/WebKit/public/platform/WebURL.h" |
58 #include "third_party/WebKit/public/platform/scheduler/child/webthread_base.h" | 59 #include "third_party/WebKit/public/platform/scheduler/child/webthread_base.h" |
59 #include "third_party/zlib/google/compression_utils.h" | 60 #include "third_party/zlib/google/compression_utils.h" |
60 #include "ui/base/layout.h" | 61 #include "ui/base/layout.h" |
61 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" | 62 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" |
62 #include "ui/events/keycodes/dom/keycode_converter.h" | 63 #include "ui/events/keycodes/dom/keycode_converter.h" |
63 | 64 |
64 using blink::WebData; | 65 using blink::WebData; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 396 |
396 WebString BlinkPlatformImpl::UserAgent() { | 397 WebString BlinkPlatformImpl::UserAgent() { |
397 return blink::WebString::FromUTF8(GetContentClient()->GetUserAgent()); | 398 return blink::WebString::FromUTF8(GetContentClient()->GetUserAgent()); |
398 } | 399 } |
399 | 400 |
400 WebURLError BlinkPlatformImpl::CancelledError( | 401 WebURLError BlinkPlatformImpl::CancelledError( |
401 const WebURL& unreachableURL) const { | 402 const WebURL& unreachableURL) const { |
402 return CreateWebURLError(unreachableURL, false, net::ERR_ABORTED); | 403 return CreateWebURLError(unreachableURL, false, net::ERR_ABORTED); |
403 } | 404 } |
404 | 405 |
405 blink::WebThread* BlinkPlatformImpl::CreateThread(const char* name) { | 406 std::unique_ptr<blink::WebThread> BlinkPlatformImpl::CreateThread( |
| 407 const char* name) { |
406 std::unique_ptr<blink::scheduler::WebThreadBase> thread = | 408 std::unique_ptr<blink::scheduler::WebThreadBase> thread = |
407 blink::scheduler::WebThreadBase::CreateWorkerThread( | 409 blink::scheduler::WebThreadBase::CreateWorkerThread( |
408 name, base::Thread::Options()); | 410 name, base::Thread::Options()); |
409 thread->Init(); | 411 thread->Init(); |
410 WaitUntilWebThreadTLSUpdate(thread.get()); | 412 WaitUntilWebThreadTLSUpdate(thread.get()); |
411 return thread.release(); | 413 return std::move(thread); |
412 } | 414 } |
413 | 415 |
414 void BlinkPlatformImpl::SetCompositorThread( | 416 void BlinkPlatformImpl::SetCompositorThread( |
415 blink::scheduler::WebThreadBase* compositor_thread) { | 417 blink::scheduler::WebThreadBase* compositor_thread) { |
416 compositor_thread_ = compositor_thread; | 418 compositor_thread_ = compositor_thread; |
417 if (compositor_thread_) | 419 if (compositor_thread_) |
418 WaitUntilWebThreadTLSUpdate(compositor_thread_); | 420 WaitUntilWebThreadTLSUpdate(compositor_thread_); |
419 } | 421 } |
420 | 422 |
421 blink::WebThread* BlinkPlatformImpl::CurrentThread() { | 423 blink::WebThread* BlinkPlatformImpl::CurrentThread() { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 values.push_back(value1.Utf16()); | 676 values.push_back(value1.Utf16()); |
675 values.push_back(value2.Utf16()); | 677 values.push_back(value2.Utf16()); |
676 return WebString::FromUTF16(base::ReplaceStringPlaceholders( | 678 return WebString::FromUTF16(base::ReplaceStringPlaceholders( |
677 GetContentClient()->GetLocalizedString(message_id), values, NULL)); | 679 GetContentClient()->GetLocalizedString(message_id), values, NULL)); |
678 } | 680 } |
679 | 681 |
680 blink::WebThread* BlinkPlatformImpl::CompositorThread() const { | 682 blink::WebThread* BlinkPlatformImpl::CompositorThread() const { |
681 return compositor_thread_; | 683 return compositor_thread_; |
682 } | 684 } |
683 | 685 |
684 blink::WebGestureCurve* BlinkPlatformImpl::CreateFlingAnimationCurve( | 686 std::unique_ptr<blink::WebGestureCurve> |
| 687 BlinkPlatformImpl::CreateFlingAnimationCurve( |
685 blink::WebGestureDevice device_source, | 688 blink::WebGestureDevice device_source, |
686 const blink::WebFloatPoint& velocity, | 689 const blink::WebFloatPoint& velocity, |
687 const blink::WebSize& cumulative_scroll) { | 690 const blink::WebSize& cumulative_scroll) { |
688 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( | 691 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( |
689 gfx::Vector2dF(velocity.x, velocity.y), | 692 gfx::Vector2dF(velocity.x, velocity.y), |
690 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), | 693 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height), |
691 IsMainThread()).release(); | 694 IsMainThread()); |
692 } | 695 } |
693 | 696 |
694 void BlinkPlatformImpl::DidStartWorkerThread() { | 697 void BlinkPlatformImpl::DidStartWorkerThread() { |
695 WorkerThreadRegistry::Instance()->DidStartCurrentWorkerThread(); | 698 WorkerThreadRegistry::Instance()->DidStartCurrentWorkerThread(); |
696 } | 699 } |
697 | 700 |
698 void BlinkPlatformImpl::WillStopWorkerThread() { | 701 void BlinkPlatformImpl::WillStopWorkerThread() { |
699 WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread(); | 702 WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread(); |
700 } | 703 } |
701 | 704 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 WebString BlinkPlatformImpl::DomKeyStringFromEnum(int dom_key) { | 825 WebString BlinkPlatformImpl::DomKeyStringFromEnum(int dom_key) { |
823 return WebString::FromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 826 return WebString::FromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
824 static_cast<ui::DomKey>(dom_key))); | 827 static_cast<ui::DomKey>(dom_key))); |
825 } | 828 } |
826 | 829 |
827 int BlinkPlatformImpl::DomKeyEnumFromString(const WebString& key_string) { | 830 int BlinkPlatformImpl::DomKeyEnumFromString(const WebString& key_string) { |
828 return static_cast<int>( | 831 return static_cast<int>( |
829 ui::KeycodeConverter::KeyStringToDomKey(key_string.Utf8())); | 832 ui::KeycodeConverter::KeyStringToDomKey(key_string.Utf8())); |
830 } | 833 } |
831 | 834 |
832 blink::WebFeaturePolicy* BlinkPlatformImpl::CreateFeaturePolicy( | 835 std::unique_ptr<blink::WebFeaturePolicy> BlinkPlatformImpl::CreateFeaturePolicy( |
833 const blink::WebFeaturePolicy* parent_policy, | 836 const blink::WebFeaturePolicy* parent_policy, |
834 const blink::WebParsedFeaturePolicy& container_policy, | 837 const blink::WebParsedFeaturePolicy& container_policy, |
835 const blink::WebParsedFeaturePolicy& policy_header, | 838 const blink::WebParsedFeaturePolicy& policy_header, |
836 const blink::WebSecurityOrigin& origin) { | 839 const blink::WebSecurityOrigin& origin) { |
837 std::unique_ptr<FeaturePolicy> policy = FeaturePolicy::CreateFromParentPolicy( | 840 std::unique_ptr<FeaturePolicy> policy = FeaturePolicy::CreateFromParentPolicy( |
838 static_cast<const FeaturePolicy*>(parent_policy), | 841 static_cast<const FeaturePolicy*>(parent_policy), |
839 FeaturePolicyHeaderFromWeb(container_policy), url::Origin(origin)); | 842 FeaturePolicyHeaderFromWeb(container_policy), url::Origin(origin)); |
840 policy->SetHeaderPolicy(FeaturePolicyHeaderFromWeb(policy_header)); | 843 policy->SetHeaderPolicy(FeaturePolicyHeaderFromWeb(policy_header)); |
841 return policy.release(); | 844 return std::move(policy); |
842 } | 845 } |
843 | 846 |
844 blink::WebFeaturePolicy* BlinkPlatformImpl::DuplicateFeaturePolicyWithOrigin( | 847 std::unique_ptr<blink::WebFeaturePolicy> |
| 848 BlinkPlatformImpl::DuplicateFeaturePolicyWithOrigin( |
845 const blink::WebFeaturePolicy& policy, | 849 const blink::WebFeaturePolicy& policy, |
846 const blink::WebSecurityOrigin& new_origin) { | 850 const blink::WebSecurityOrigin& new_origin) { |
847 std::unique_ptr<FeaturePolicy> new_policy = | 851 return FeaturePolicy::CreateFromPolicyWithOrigin( |
848 FeaturePolicy::CreateFromPolicyWithOrigin( | 852 static_cast<const FeaturePolicy&>(policy), url::Origin(new_origin)); |
849 static_cast<const FeaturePolicy&>(policy), url::Origin(new_origin)); | |
850 return new_policy.release(); | |
851 } | 853 } |
852 | 854 |
853 } // namespace content | 855 } // namespace content |
OLD | NEW |