Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / content / child / blink_platform_impl.h
blob83576e24e9ee56120fc5579d201cbc1db1d798bd
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
6 #define CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/threading/thread_local_storage.h"
11 #include "base/timer/timer.h"
12 #include "base/trace_event/trace_event.h"
13 #include "components/webcrypto/webcrypto_impl.h"
14 #include "content/child/webfallbackthemeengine_impl.h"
15 #include "content/common/content_export.h"
16 #include "third_party/WebKit/public/platform/Platform.h"
17 #include "third_party/WebKit/public/platform/WebGestureDevice.h"
18 #include "third_party/WebKit/public/platform/WebURLError.h"
19 #include "ui/base/layout.h"
21 #if defined(USE_DEFAULT_RENDER_THEME)
22 #include "content/child/webthemeengine_impl_default.h"
23 #elif defined(OS_WIN)
24 #include "content/child/webthemeengine_impl_win.h"
25 #elif defined(OS_MACOSX)
26 #include "content/child/webthemeengine_impl_mac.h"
27 #elif defined(OS_ANDROID)
28 #include "content/child/webthemeengine_impl_android.h"
29 #endif
31 namespace base {
32 class MessageLoop;
35 namespace content {
36 class BackgroundSyncProvider;
37 class FlingCurveConfiguration;
38 class NotificationDispatcher;
39 class PermissionDispatcher;
40 class PushDispatcher;
41 class ThreadSafeSender;
42 class WebCryptoImpl;
43 class WebGeofencingProviderImpl;
44 class WebMemoryDumpProviderAdapter;
46 class CONTENT_EXPORT BlinkPlatformImpl
47 : NON_EXPORTED_BASE(public blink::Platform) {
48 public:
49 BlinkPlatformImpl();
50 explicit BlinkPlatformImpl(
51 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
52 virtual ~BlinkPlatformImpl();
54 // Platform methods (partial implementation):
55 virtual blink::WebThemeEngine* themeEngine();
56 virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
57 virtual blink::Platform::FileHandle databaseOpenFile(
58 const blink::WebString& vfs_file_name, int desired_flags);
59 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
60 bool sync_dir);
61 virtual long databaseGetFileAttributes(
62 const blink::WebString& vfs_file_name);
63 virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
64 virtual long long databaseGetSpaceAvailableForOrigin(
65 const blink::WebString& origin_identifier);
66 virtual bool databaseSetFileSize(
67 const blink::WebString& vfs_file_name, long long size);
68 virtual blink::WebString signedPublicKeyAndChallengeString(
69 unsigned key_size_index, const blink::WebString& challenge,
70 const blink::WebURL& url);
71 virtual size_t memoryUsageMB();
72 virtual size_t actualMemoryUsageMB();
73 virtual size_t physicalMemoryMB();
74 virtual size_t virtualMemoryLimitMB();
75 virtual bool isLowEndDeviceMode();
76 virtual size_t numberOfProcessors();
78 virtual bool processMemorySizesInBytes(size_t* private_bytes,
79 size_t* shared_bytes);
80 virtual bool memoryAllocatorWasteInBytes(size_t* size);
81 virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
82 size_t bytes);
83 virtual size_t maxDecodedImageBytes();
84 virtual uint32_t getUniqueIdForProcess();
85 virtual blink::WebURLLoader* createURLLoader();
86 virtual blink::WebSocketHandle* createWebSocketHandle();
87 virtual blink::WebString userAgent();
88 virtual blink::WebData parseDataURL(
89 const blink::WebURL& url, blink::WebString& mimetype,
90 blink::WebString& charset);
91 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
92 virtual bool isReservedIPAddress(const blink::WebString& host) const;
93 virtual bool portAllowed(const blink::WebURL& url) const;
94 virtual blink::WebThread* createThread(const char* name);
95 virtual blink::WebThread* currentThread();
96 virtual void yieldCurrentThread();
97 virtual blink::WebWaitableEvent* createWaitableEvent(
98 blink::WebWaitableEvent::ResetPolicy policy,
99 blink::WebWaitableEvent::InitialState state);
100 virtual blink::WebWaitableEvent* waitMultipleEvents(
101 const blink::WebVector<blink::WebWaitableEvent*>& events);
102 virtual void decrementStatsCounter(const char* name);
103 virtual void incrementStatsCounter(const char* name);
104 virtual void histogramCustomCounts(
105 const char* name, int sample, int min, int max, int bucket_count);
106 virtual void histogramEnumeration(
107 const char* name, int sample, int boundary_value);
108 virtual void histogramSparse(const char* name, int sample);
109 virtual const unsigned char* getTraceCategoryEnabledFlag(
110 const char* category_name);
111 virtual TraceEventAPIAtomicWord* getTraceSamplingState(
112 const unsigned thread_bucket);
113 virtual TraceEventHandle addTraceEvent(
114 char phase,
115 const unsigned char* category_group_enabled,
116 const char* name,
117 unsigned long long id,
118 double timestamp,
119 int num_args,
120 const char** arg_names,
121 const unsigned char* arg_types,
122 const unsigned long long* arg_values,
123 unsigned char flags);
124 virtual TraceEventHandle addTraceEvent(
125 char phase,
126 const unsigned char* category_group_enabled,
127 const char* name,
128 unsigned long long id,
129 double timestamp,
130 int num_args,
131 const char** arg_names,
132 const unsigned char* arg_types,
133 const unsigned long long* arg_values,
134 blink::WebConvertableToTraceFormat* convertable_values,
135 unsigned char flags);
136 virtual void updateTraceEventDuration(
137 const unsigned char* category_group_enabled,
138 const char* name,
139 TraceEventHandle);
140 virtual void registerMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
141 virtual void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider* wmdp);
142 virtual blink::WebProcessMemoryDump* createProcessMemoryDump();
143 virtual blink::Platform::WebMemoryAllocatorDumpGuid
144 createWebMemoryAllocatorDumpGuid(const blink::WebString& guidStr);
146 virtual blink::WebData loadResource(const char* name);
147 virtual blink::WebString queryLocalizedString(
148 blink::WebLocalizedString::Name name);
149 virtual blink::WebString queryLocalizedString(
150 blink::WebLocalizedString::Name name, int numeric_value);
151 virtual blink::WebString queryLocalizedString(
152 blink::WebLocalizedString::Name name, const blink::WebString& value);
153 virtual blink::WebString queryLocalizedString(
154 blink::WebLocalizedString::Name name,
155 const blink::WebString& value1, const blink::WebString& value2);
156 virtual void suddenTerminationChanged(bool enabled) { }
157 virtual double currentTime();
158 virtual double monotonicallyIncreasingTime();
159 virtual double systemTraceTime();
160 virtual void cryptographicallyRandomValues(
161 unsigned char* buffer, size_t length);
162 virtual blink::WebGestureCurve* createFlingAnimationCurve(
163 blink::WebGestureDevice device_source,
164 const blink::WebFloatPoint& velocity,
165 const blink::WebSize& cumulative_scroll);
166 virtual void didStartWorkerRunLoop();
167 virtual void didStopWorkerRunLoop();
168 virtual blink::WebCrypto* crypto();
169 virtual blink::WebGeofencingProvider* geofencingProvider();
170 virtual blink::WebNotificationManager* notificationManager();
171 virtual blink::WebPushProvider* pushProvider();
172 virtual blink::WebServicePortProvider* createServicePortProvider(
173 blink::WebServicePortProviderClient*);
174 virtual blink::WebPermissionClient* permissionClient();
175 virtual blink::WebSyncProvider* backgroundSyncProvider();
177 virtual blink::WebString domCodeStringFromEnum(int dom_code);
178 virtual int domEnumFromCodeString(const blink::WebString& codeString);
179 virtual blink::WebString domKeyStringFromEnum(int dom_key);
180 virtual int domKeyEnumFromString(const blink::WebString& key_string);
182 private:
183 void InternalInit();
184 void UpdateWebThreadTLS(blink::WebThread* thread);
186 bool IsMainThread() const;
188 scoped_refptr<base::SingleThreadTaskRunner> MainTaskRunnerForCurrentThread();
190 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
191 WebThemeEngineImpl native_theme_engine_;
192 WebFallbackThemeEngineImpl fallback_theme_engine_;
193 base::ThreadLocalStorage::Slot current_thread_slot_;
194 webcrypto::WebCryptoImpl web_crypto_;
195 scoped_ptr<WebGeofencingProviderImpl> geofencing_provider_;
196 base::ScopedPtrHashMap<blink::WebMemoryDumpProvider*,
197 scoped_ptr<WebMemoryDumpProviderAdapter>>
198 memory_dump_providers_;
200 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
201 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
202 scoped_refptr<PushDispatcher> push_dispatcher_;
203 scoped_ptr<PermissionDispatcher> permission_client_;
204 scoped_ptr<BackgroundSyncProvider> sync_provider_;
207 } // namespace content
209 #endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_