Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/renderer_webkitplatformsupport_impl.h" 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #endif 96 #endif
97 97
98 #if defined(OS_POSIX) 98 #if defined(OS_POSIX)
99 #include "base/file_descriptor_posix.h" 99 #include "base/file_descriptor_posix.h"
100 #endif 100 #endif
101 101
102 #if defined(OS_ANDROID) 102 #if defined(OS_ANDROID)
103 #include "content/renderer/media/android/audio_decoder_android.h" 103 #include "content/renderer/media/android/audio_decoder_android.h"
104 #endif 104 #endif
105 105
106 using WebKit::WebAudioDevice; 106 using blink::WebAudioDevice;
107 using WebKit::WebBlobRegistry; 107 using blink::WebBlobRegistry;
108 using WebKit::WebFileInfo; 108 using blink::WebFileInfo;
109 using WebKit::WebFileSystem; 109 using blink::WebFileSystem;
110 using WebKit::WebFrame; 110 using blink::WebFrame;
111 using WebKit::WebGamepads; 111 using blink::WebGamepads;
112 using WebKit::WebIDBFactory; 112 using blink::WebIDBFactory;
113 using WebKit::WebMIDIAccessor; 113 using blink::WebMIDIAccessor;
114 using WebKit::Platform; 114 using blink::Platform;
115 using WebKit::WebMediaStreamCenter; 115 using blink::WebMediaStreamCenter;
116 using WebKit::WebMediaStreamCenterClient; 116 using blink::WebMediaStreamCenterClient;
117 using WebKit::WebMimeRegistry; 117 using blink::WebMimeRegistry;
118 using WebKit::WebRTCPeerConnectionHandler; 118 using blink::WebRTCPeerConnectionHandler;
119 using WebKit::WebRTCPeerConnectionHandlerClient; 119 using blink::WebRTCPeerConnectionHandlerClient;
120 using WebKit::WebStorageNamespace; 120 using blink::WebStorageNamespace;
121 using WebKit::WebString; 121 using blink::WebString;
122 using WebKit::WebURL; 122 using blink::WebURL;
123 using WebKit::WebVector; 123 using blink::WebVector;
124 124
125 namespace content { 125 namespace content {
126 126
127 static bool g_sandbox_enabled = true; 127 static bool g_sandbox_enabled = true;
128 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = 128 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
129 LAZY_INSTANCE_INITIALIZER; 129 LAZY_INSTANCE_INITIALIZER;
130 base::LazyInstance<WebKit::WebDeviceMotionData>::Leaky 130 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
131 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 131 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
132 base::LazyInstance<WebKit::WebDeviceOrientationData>::Leaky 132 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
133 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 133 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
134 134
135 //------------------------------------------------------------------------------ 135 //------------------------------------------------------------------------------
136 136
137 class RendererWebKitPlatformSupportImpl::MimeRegistry 137 class RendererWebKitPlatformSupportImpl::MimeRegistry
138 : public webkit_glue::SimpleWebMimeRegistryImpl { 138 : public webkit_glue::SimpleWebMimeRegistryImpl {
139 public: 139 public:
140 virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( 140 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
141 const WebKit::WebString& mime_type, 141 const blink::WebString& mime_type,
142 const WebKit::WebString& codecs, 142 const blink::WebString& codecs,
143 const WebKit::WebString& key_system); 143 const blink::WebString& key_system);
144 virtual bool supportsMediaSourceMIMEType(const WebKit::WebString& mime_type, 144 virtual bool supportsMediaSourceMIMEType(const blink::WebString& mime_type,
145 const WebKit::WebString& codecs); 145 const blink::WebString& codecs);
146 virtual WebKit::WebString mimeTypeForExtension( 146 virtual blink::WebString mimeTypeForExtension(
147 const WebKit::WebString& file_extension); 147 const blink::WebString& file_extension);
148 virtual WebKit::WebString mimeTypeFromFile( 148 virtual blink::WebString mimeTypeFromFile(
149 const WebKit::WebString& file_path); 149 const blink::WebString& file_path);
150 }; 150 };
151 151
152 class RendererWebKitPlatformSupportImpl::FileUtilities 152 class RendererWebKitPlatformSupportImpl::FileUtilities
153 : public webkit_glue::WebFileUtilitiesImpl { 153 : public webkit_glue::WebFileUtilitiesImpl {
154 public: 154 public:
155 explicit FileUtilities(ThreadSafeSender* sender) 155 explicit FileUtilities(ThreadSafeSender* sender)
156 : thread_safe_sender_(sender) {} 156 : thread_safe_sender_(sender) {}
157 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); 157 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
158 private: 158 private:
159 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const; 159 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const;
160 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 160 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
161 }; 161 };
162 162
163 #if defined(OS_ANDROID) 163 #if defined(OS_ANDROID)
164 // WebKit doesn't use WebSandboxSupport on android so we don't need to 164 // WebKit doesn't use WebSandboxSupport on android so we don't need to
165 // implement anything here. 165 // implement anything here.
166 class RendererWebKitPlatformSupportImpl::SandboxSupport { 166 class RendererWebKitPlatformSupportImpl::SandboxSupport {
167 }; 167 };
168 #else 168 #else
169 class RendererWebKitPlatformSupportImpl::SandboxSupport 169 class RendererWebKitPlatformSupportImpl::SandboxSupport
170 : public WebKit::WebSandboxSupport { 170 : public blink::WebSandboxSupport {
171 public: 171 public:
172 virtual ~SandboxSupport() {} 172 virtual ~SandboxSupport() {}
173 173
174 #if defined(OS_WIN) 174 #if defined(OS_WIN)
175 virtual bool ensureFontLoaded(HFONT); 175 virtual bool ensureFontLoaded(HFONT);
176 #elif defined(OS_MACOSX) 176 #elif defined(OS_MACOSX)
177 virtual bool loadFont( 177 virtual bool loadFont(
178 NSFont* src_font, 178 NSFont* src_font,
179 CGFontRef* container, 179 CGFontRef* container,
180 uint32* font_id); 180 uint32* font_id);
181 #elif defined(OS_POSIX) 181 #elif defined(OS_POSIX)
182 virtual void getFontFamilyForCharacter( 182 virtual void getFontFamilyForCharacter(
183 WebKit::WebUChar32 character, 183 blink::WebUChar32 character,
184 const char* preferred_locale, 184 const char* preferred_locale,
185 WebKit::WebFontFamily* family); 185 blink::WebFontFamily* family);
186 virtual void getRenderStyleForStrike( 186 virtual void getRenderStyleForStrike(
187 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); 187 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out);
188 188
189 private: 189 private:
190 // WebKit likes to ask us for the correct font family to use for a set of 190 // WebKit likes to ask us for the correct font family to use for a set of
191 // unicode code points. It needs this information frequently so we cache it 191 // unicode code points. It needs this information frequently so we cache it
192 // here. 192 // here.
193 base::Lock unicode_font_families_mutex_; 193 base::Lock unicode_font_families_mutex_;
194 std::map<int32_t, WebKit::WebFontFamily> unicode_font_families_; 194 std::map<int32_t, blink::WebFontFamily> unicode_font_families_;
195 #endif 195 #endif
196 }; 196 };
197 #endif // defined(OS_ANDROID) 197 #endif // defined(OS_ANDROID)
198 198
199 //------------------------------------------------------------------------------ 199 //------------------------------------------------------------------------------
200 200
201 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() 201 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl()
202 : clipboard_client_(new RendererClipboardClient), 202 : clipboard_client_(new RendererClipboardClient),
203 clipboard_(new WebClipboardImpl(clipboard_client_.get())), 203 clipboard_(new WebClipboardImpl(clipboard_client_.get())),
204 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), 204 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry),
(...skipping 15 matching lines...) Expand all
220 blob_registry_.reset(new WebBlobRegistryImpl(thread_safe_sender_)); 220 blob_registry_.reset(new WebBlobRegistryImpl(thread_safe_sender_));
221 } 221 }
222 } 222 }
223 223
224 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() { 224 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() {
225 WebFileSystemImpl::DeleteThreadSpecificInstance(); 225 WebFileSystemImpl::DeleteThreadSpecificInstance();
226 } 226 }
227 227
228 //------------------------------------------------------------------------------ 228 //------------------------------------------------------------------------------
229 229
230 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { 230 blink::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() {
231 WebKit::WebClipboard* clipboard = 231 blink::WebClipboard* clipboard =
232 GetContentClient()->renderer()->OverrideWebClipboard(); 232 GetContentClient()->renderer()->OverrideWebClipboard();
233 if (clipboard) 233 if (clipboard)
234 return clipboard; 234 return clipboard;
235 return clipboard_.get(); 235 return clipboard_.get();
236 } 236 }
237 237
238 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { 238 blink::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() {
239 return mime_registry_.get(); 239 return mime_registry_.get();
240 } 240 }
241 241
242 WebKit::WebFileUtilities* 242 blink::WebFileUtilities*
243 RendererWebKitPlatformSupportImpl::fileUtilities() { 243 RendererWebKitPlatformSupportImpl::fileUtilities() {
244 if (!file_utilities_) { 244 if (!file_utilities_) {
245 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); 245 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get()));
246 file_utilities_->set_sandbox_enabled(sandboxEnabled()); 246 file_utilities_->set_sandbox_enabled(sandboxEnabled());
247 } 247 }
248 return file_utilities_.get(); 248 return file_utilities_.get();
249 } 249 }
250 250
251 WebKit::WebSandboxSupport* RendererWebKitPlatformSupportImpl::sandboxSupport() { 251 blink::WebSandboxSupport* RendererWebKitPlatformSupportImpl::sandboxSupport() {
252 #if defined(OS_ANDROID) 252 #if defined(OS_ANDROID)
253 // WebKit doesn't use WebSandboxSupport on android. 253 // WebKit doesn't use WebSandboxSupport on android.
254 return NULL; 254 return NULL;
255 #else 255 #else
256 return sandbox_support_.get(); 256 return sandbox_support_.get();
257 #endif 257 #endif
258 } 258 }
259 259
260 WebKit::WebCookieJar* RendererWebKitPlatformSupportImpl::cookieJar() { 260 blink::WebCookieJar* RendererWebKitPlatformSupportImpl::cookieJar() {
261 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; 261 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!";
262 return NULL; 262 return NULL;
263 } 263 }
264 264
265 WebKit::WebThemeEngine* RendererWebKitPlatformSupportImpl::themeEngine() { 265 blink::WebThemeEngine* RendererWebKitPlatformSupportImpl::themeEngine() {
266 WebKit::WebThemeEngine* theme_engine = 266 blink::WebThemeEngine* theme_engine =
267 GetContentClient()->renderer()->OverrideThemeEngine(); 267 GetContentClient()->renderer()->OverrideThemeEngine();
268 if (theme_engine) 268 if (theme_engine)
269 return theme_engine; 269 return theme_engine;
270 return WebKitPlatformSupportImpl::themeEngine(); 270 return WebKitPlatformSupportImpl::themeEngine();
271 } 271 }
272 272
273 bool RendererWebKitPlatformSupportImpl::sandboxEnabled() { 273 bool RendererWebKitPlatformSupportImpl::sandboxEnabled() {
274 // As explained in Platform.h, this function is used to decide 274 // As explained in Platform.h, this function is used to decide
275 // whether to allow file system operations to come out of WebKit or not. 275 // whether to allow file system operations to come out of WebKit or not.
276 // Even if the sandbox is disabled, there's no reason why the code should 276 // Even if the sandbox is disabled, there's no reason why the code should
277 // act any differently...unless we're in single process mode. In which 277 // act any differently...unless we're in single process mode. In which
278 // case, we have no other choice. Platform.h discourages using 278 // case, we have no other choice. Platform.h discourages using
279 // this switch unless absolutely necessary, so hopefully we won't end up 279 // this switch unless absolutely necessary, so hopefully we won't end up
280 // with too many code paths being different in single-process mode. 280 // with too many code paths being different in single-process mode.
281 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); 281 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
282 } 282 }
283 283
284 unsigned long long RendererWebKitPlatformSupportImpl::visitedLinkHash( 284 unsigned long long RendererWebKitPlatformSupportImpl::visitedLinkHash(
285 const char* canonical_url, 285 const char* canonical_url,
286 size_t length) { 286 size_t length) {
287 return GetContentClient()->renderer()->VisitedLinkHash(canonical_url, length); 287 return GetContentClient()->renderer()->VisitedLinkHash(canonical_url, length);
288 } 288 }
289 289
290 bool RendererWebKitPlatformSupportImpl::isLinkVisited( 290 bool RendererWebKitPlatformSupportImpl::isLinkVisited(
291 unsigned long long link_hash) { 291 unsigned long long link_hash) {
292 return GetContentClient()->renderer()->IsLinkVisited(link_hash); 292 return GetContentClient()->renderer()->IsLinkVisited(link_hash);
293 } 293 }
294 294
295 WebKit::WebMessagePortChannel* 295 blink::WebMessagePortChannel*
296 RendererWebKitPlatformSupportImpl::createMessagePortChannel() { 296 RendererWebKitPlatformSupportImpl::createMessagePortChannel() {
297 return new WebMessagePortChannelImpl(child_thread_loop_.get()); 297 return new WebMessagePortChannelImpl(child_thread_loop_.get());
298 } 298 }
299 299
300 WebKit::WebPrescientNetworking* 300 blink::WebPrescientNetworking*
301 RendererWebKitPlatformSupportImpl::prescientNetworking() { 301 RendererWebKitPlatformSupportImpl::prescientNetworking() {
302 return GetContentClient()->renderer()->GetPrescientNetworking(); 302 return GetContentClient()->renderer()->GetPrescientNetworking();
303 } 303 }
304 304
305 bool 305 bool
306 RendererWebKitPlatformSupportImpl::CheckPreparsedJsCachingEnabled() const { 306 RendererWebKitPlatformSupportImpl::CheckPreparsedJsCachingEnabled() const {
307 static bool checked = false; 307 static bool checked = false;
308 static bool result = false; 308 static bool result = false;
309 if (!checked) { 309 if (!checked) {
310 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 310 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
311 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching); 311 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching);
312 checked = true; 312 checked = true;
313 } 313 }
314 return result; 314 return result;
315 } 315 }
316 316
317 void RendererWebKitPlatformSupportImpl::cacheMetadata( 317 void RendererWebKitPlatformSupportImpl::cacheMetadata(
318 const WebKit::WebURL& url, 318 const blink::WebURL& url,
319 double response_time, 319 double response_time,
320 const char* data, 320 const char* data,
321 size_t size) { 321 size_t size) {
322 if (!CheckPreparsedJsCachingEnabled()) 322 if (!CheckPreparsedJsCachingEnabled())
323 return; 323 return;
324 324
325 // Let the browser know we generated cacheable metadata for this resource. The 325 // Let the browser know we generated cacheable metadata for this resource. The
326 // browser may cache it and return it on subsequent responses to speed 326 // browser may cache it and return it on subsequent responses to speed
327 // the processing of this resource. 327 // the processing of this resource.
328 std::vector<char> copy(data, data + size); 328 std::vector<char> copy(data, data + size);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); 422 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
423 if (!net::AreSupportedMediaCodecs(parsed_codecs)) 423 if (!net::AreSupportedMediaCodecs(parsed_codecs))
424 return MayBeSupported; 424 return MayBeSupported;
425 425
426 // Otherwise we have a perfect match. 426 // Otherwise we have a perfect match.
427 return IsSupported; 427 return IsSupported;
428 } 428 }
429 429
430 bool 430 bool
431 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( 431 RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType(
432 const WebKit::WebString& mime_type, 432 const blink::WebString& mime_type,
433 const WebString& codecs) { 433 const WebString& codecs) {
434 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); 434 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
435 std::vector<std::string> parsed_codec_ids; 435 std::vector<std::string> parsed_codec_ids;
436 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); 436 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
437 if (mime_type_ascii.empty()) 437 if (mime_type_ascii.empty())
438 return false; 438 return false;
439 return media::StreamParserFactory::IsTypeSupported( 439 return media::StreamParserFactory::IsTypeSupported(
440 mime_type_ascii, parsed_codec_ids); 440 mime_type_ascii, parsed_codec_ids);
441 } 441 }
442 442
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 #elif defined(OS_ANDROID) 540 #elif defined(OS_ANDROID)
541 541
542 // WebKit doesn't use WebSandboxSupport on android so we don't need to 542 // WebKit doesn't use WebSandboxSupport on android so we don't need to
543 // implement anything here. This is cleaner to support than excluding the 543 // implement anything here. This is cleaner to support than excluding the
544 // whole class for android. 544 // whole class for android.
545 545
546 #elif defined(OS_POSIX) 546 #elif defined(OS_POSIX)
547 547
548 void 548 void
549 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter( 549 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter(
550 WebKit::WebUChar32 character, 550 blink::WebUChar32 character,
551 const char* preferred_locale, 551 const char* preferred_locale,
552 WebKit::WebFontFamily* family) { 552 blink::WebFontFamily* family) {
553 base::AutoLock lock(unicode_font_families_mutex_); 553 base::AutoLock lock(unicode_font_families_mutex_);
554 const std::map<int32_t, WebKit::WebFontFamily>::const_iterator iter = 554 const std::map<int32_t, blink::WebFontFamily>::const_iterator iter =
555 unicode_font_families_.find(character); 555 unicode_font_families_.find(character);
556 if (iter != unicode_font_families_.end()) { 556 if (iter != unicode_font_families_.end()) {
557 family->name = iter->second.name; 557 family->name = iter->second.name;
558 family->isBold = iter->second.isBold; 558 family->isBold = iter->second.isBold;
559 family->isItalic = iter->second.isItalic; 559 family->isItalic = iter->second.isItalic;
560 return; 560 return;
561 } 561 }
562 562
563 GetFontFamilyForCharacter(character, preferred_locale, family); 563 GetFontFamilyForCharacter(character, preferred_locale, family);
564 unicode_font_families_.insert(std::make_pair(character, *family)); 564 unicode_font_families_.insert(std::make_pair(character, *family));
565 } 565 }
566 566
567 void 567 void
568 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( 568 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike(
569 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { 569 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) {
570 GetRenderStyleForStrike(family, sizeAndStyle, out); 570 GetRenderStyleForStrike(family, sizeAndStyle, out);
571 } 571 }
572 572
573 #endif 573 #endif
574 574
575 //------------------------------------------------------------------------------ 575 //------------------------------------------------------------------------------
576 576
577 Platform::FileHandle 577 Platform::FileHandle
578 RendererWebKitPlatformSupportImpl::databaseOpenFile( 578 RendererWebKitPlatformSupportImpl::databaseOpenFile(
579 const WebString& vfs_file_name, int desired_flags) { 579 const WebString& vfs_file_name, int desired_flags) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 buffer_size, input_channels, channels, sample_rate, callback, "default"); 661 buffer_size, input_channels, channels, sample_rate, callback, "default");
662 } 662 }
663 663
664 WebAudioDevice* 664 WebAudioDevice*
665 RendererWebKitPlatformSupportImpl::createAudioDevice( 665 RendererWebKitPlatformSupportImpl::createAudioDevice(
666 size_t buffer_size, 666 size_t buffer_size,
667 unsigned input_channels, 667 unsigned input_channels,
668 unsigned channels, 668 unsigned channels,
669 double sample_rate, 669 double sample_rate,
670 WebAudioDevice::RenderCallback* callback, 670 WebAudioDevice::RenderCallback* callback,
671 const WebKit::WebString& input_device_id) { 671 const blink::WebString& input_device_id) {
672 // Use a mock for testing. 672 // Use a mock for testing.
673 WebKit::WebAudioDevice* mock_device = 673 blink::WebAudioDevice* mock_device =
674 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); 674 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate);
675 if (mock_device) 675 if (mock_device)
676 return mock_device; 676 return mock_device;
677 677
678 // The |channels| does not exactly identify the channel layout of the 678 // The |channels| does not exactly identify the channel layout of the
679 // device. The switch statement below assigns a best guess to the channel 679 // device. The switch statement below assigns a best guess to the channel
680 // layout based on number of channels. 680 // layout based on number of channels.
681 // TODO(crogers): WebKit should give the channel layout instead of the hard 681 // TODO(crogers): WebKit should give the channel layout instead of the hard
682 // channel count. 682 // channel count.
683 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; 683 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 media::AudioParameters params( 722 media::AudioParameters params(
723 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 723 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
724 layout, input_channels, 724 layout, input_channels,
725 static_cast<int>(sample_rate), 16, buffer_size); 725 static_cast<int>(sample_rate), 16, buffer_size);
726 726
727 return new RendererWebAudioDeviceImpl(params, callback, session_id); 727 return new RendererWebAudioDeviceImpl(params, callback, session_id);
728 } 728 }
729 729
730 #if defined(OS_ANDROID) 730 #if defined(OS_ANDROID)
731 bool RendererWebKitPlatformSupportImpl::loadAudioResource( 731 bool RendererWebKitPlatformSupportImpl::loadAudioResource(
732 WebKit::WebAudioBus* destination_bus, const char* audio_file_data, 732 blink::WebAudioBus* destination_bus, const char* audio_file_data,
733 size_t data_size, double sample_rate) { 733 size_t data_size, double sample_rate) {
734 return DecodeAudioFileData(destination_bus, 734 return DecodeAudioFileData(destination_bus,
735 audio_file_data, 735 audio_file_data,
736 data_size, 736 data_size,
737 sample_rate, 737 sample_rate,
738 thread_safe_sender_); 738 thread_safe_sender_);
739 } 739 }
740 #else 740 #else
741 bool RendererWebKitPlatformSupportImpl::loadAudioResource( 741 bool RendererWebKitPlatformSupportImpl::loadAudioResource(
742 WebKit::WebAudioBus* destination_bus, const char* audio_file_data, 742 blink::WebAudioBus* destination_bus, const char* audio_file_data,
743 size_t data_size, double sample_rate) { 743 size_t data_size, double sample_rate) {
744 return DecodeAudioFileData( 744 return DecodeAudioFileData(
745 destination_bus, audio_file_data, data_size, sample_rate); 745 destination_bus, audio_file_data, data_size, sample_rate);
746 } 746 }
747 #endif // defined(OS_ANDROID) 747 #endif // defined(OS_ANDROID)
748 748
749 //------------------------------------------------------------------------------ 749 //------------------------------------------------------------------------------
750 750
751 WebKit::WebContentDecryptionModule* 751 blink::WebContentDecryptionModule*
752 RendererWebKitPlatformSupportImpl::createContentDecryptionModule( 752 RendererWebKitPlatformSupportImpl::createContentDecryptionModule(
753 const WebKit::WebString& key_system) { 753 const blink::WebString& key_system) {
754 return WebContentDecryptionModuleImpl::Create(key_system); 754 return WebContentDecryptionModuleImpl::Create(key_system);
755 } 755 }
756 756
757 //------------------------------------------------------------------------------ 757 //------------------------------------------------------------------------------
758 758
759 WebKit::WebMIDIAccessor* 759 blink::WebMIDIAccessor*
760 RendererWebKitPlatformSupportImpl::createMIDIAccessor( 760 RendererWebKitPlatformSupportImpl::createMIDIAccessor(
761 WebKit::WebMIDIAccessorClient* client) { 761 blink::WebMIDIAccessorClient* client) {
762 WebKit::WebMIDIAccessor* accessor = 762 blink::WebMIDIAccessor* accessor =
763 GetContentClient()->renderer()->OverrideCreateMIDIAccessor(client); 763 GetContentClient()->renderer()->OverrideCreateMIDIAccessor(client);
764 if (accessor) 764 if (accessor)
765 return accessor; 765 return accessor;
766 766
767 return new RendererWebMIDIAccessorImpl(client); 767 return new RendererWebMIDIAccessorImpl(client);
768 } 768 }
769 769
770 void RendererWebKitPlatformSupportImpl::getPluginList( 770 void RendererWebKitPlatformSupportImpl::getPluginList(
771 bool refresh, 771 bool refresh,
772 WebKit::WebPluginListBuilder* builder) { 772 blink::WebPluginListBuilder* builder) {
773 #if defined(ENABLE_PLUGINS) 773 #if defined(ENABLE_PLUGINS)
774 std::vector<WebPluginInfo> plugins; 774 std::vector<WebPluginInfo> plugins;
775 if (!plugin_refresh_allowed_) 775 if (!plugin_refresh_allowed_)
776 refresh = false; 776 refresh = false;
777 RenderThread::Get()->Send( 777 RenderThread::Get()->Send(
778 new ViewHostMsg_GetPlugins(refresh, &plugins)); 778 new ViewHostMsg_GetPlugins(refresh, &plugins));
779 for (size_t i = 0; i < plugins.size(); ++i) { 779 for (size_t i = 0; i < plugins.size(); ++i) {
780 const WebPluginInfo& plugin = plugins[i]; 780 const WebPluginInfo& plugin = plugins[i];
781 781
782 builder->addPlugin( 782 builder->addPlugin(
(...skipping 10 matching lines...) Expand all
793 builder->addFileExtensionToLastMediaType( 793 builder->addFileExtensionToLastMediaType(
794 WebString::fromUTF8(mime_type.file_extensions[k])); 794 WebString::fromUTF8(mime_type.file_extensions[k]));
795 } 795 }
796 } 796 }
797 } 797 }
798 #endif 798 #endif
799 } 799 }
800 800
801 //------------------------------------------------------------------------------ 801 //------------------------------------------------------------------------------
802 802
803 WebKit::WebString 803 blink::WebString
804 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( 804 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString(
805 unsigned key_size_index, 805 unsigned key_size_index,
806 const WebKit::WebString& challenge, 806 const blink::WebString& challenge,
807 const WebKit::WebURL& url) { 807 const blink::WebURL& url) {
808 std::string signed_public_key; 808 std::string signed_public_key;
809 RenderThread::Get()->Send(new ViewHostMsg_Keygen( 809 RenderThread::Get()->Send(new ViewHostMsg_Keygen(
810 static_cast<uint32>(key_size_index), 810 static_cast<uint32>(key_size_index),
811 challenge.utf8(), 811 challenge.utf8(),
812 GURL(url), 812 GURL(url),
813 &signed_public_key)); 813 &signed_public_key));
814 return WebString::fromUTF8(signed_public_key); 814 return WebString::fromUTF8(signed_public_key);
815 } 815 }
816 816
817 //------------------------------------------------------------------------------ 817 //------------------------------------------------------------------------------
(...skipping 16 matching lines...) Expand all
834 //------------------------------------------------------------------------------ 834 //------------------------------------------------------------------------------
835 835
836 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { 836 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
837 if (g_test_gamepads == 0) { 837 if (g_test_gamepads == 0) {
838 RenderThreadImpl::current()->SampleGamepads(&gamepads); 838 RenderThreadImpl::current()->SampleGamepads(&gamepads);
839 } else { 839 } else {
840 gamepads = g_test_gamepads.Get(); 840 gamepads = g_test_gamepads.Get();
841 } 841 }
842 } 842 }
843 843
844 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( 844 blink::WebString RendererWebKitPlatformSupportImpl::userAgent(
845 const WebKit::WebURL& url) { 845 const blink::WebURL& url) {
846 return WebKitPlatformSupportImpl::userAgent(url); 846 return WebKitPlatformSupportImpl::userAgent(url);
847 } 847 }
848 848
849 //------------------------------------------------------------------------------ 849 //------------------------------------------------------------------------------
850 850
851 WebRTCPeerConnectionHandler* 851 WebRTCPeerConnectionHandler*
852 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( 852 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler(
853 WebRTCPeerConnectionHandlerClient* client) { 853 WebRTCPeerConnectionHandlerClient* client) {
854 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 854 RenderThreadImpl* render_thread = RenderThreadImpl::current();
855 DCHECK(render_thread); 855 DCHECK(render_thread);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } 892 }
893 893
894 // static 894 // static
895 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting( 895 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(
896 const WebGamepads& pads) { 896 const WebGamepads& pads) {
897 g_test_gamepads.Get() = pads; 897 g_test_gamepads.Get() = pads;
898 } 898 }
899 899
900 //------------------------------------------------------------------------------ 900 //------------------------------------------------------------------------------
901 901
902 WebKit::WebSpeechSynthesizer* 902 blink::WebSpeechSynthesizer*
903 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( 903 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer(
904 WebKit::WebSpeechSynthesizerClient* client) { 904 blink::WebSpeechSynthesizerClient* client) {
905 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); 905 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client);
906 } 906 }
907 907
908 //------------------------------------------------------------------------------ 908 //------------------------------------------------------------------------------
909 909
910 bool RendererWebKitPlatformSupportImpl::processMemorySizesInBytes( 910 bool RendererWebKitPlatformSupportImpl::processMemorySizesInBytes(
911 size_t* private_bytes, size_t* shared_bytes) { 911 size_t* private_bytes, size_t* shared_bytes) {
912 content::RenderThread::Get()->Send( 912 content::RenderThread::Get()->Send(
913 new ViewHostMsg_GetProcessMemorySizes(private_bytes, shared_bytes)); 913 new ViewHostMsg_GetProcessMemorySizes(private_bytes, shared_bytes));
914 return true; 914 return true;
915 } 915 }
916 916
917 //------------------------------------------------------------------------------ 917 //------------------------------------------------------------------------------
918 918
919 WebKit::WebGraphicsContext3D* 919 blink::WebGraphicsContext3D*
920 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( 920 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
921 const WebKit::WebGraphicsContext3D::Attributes& attributes) { 921 const blink::WebGraphicsContext3D::Attributes& attributes) {
922 if (!RenderThreadImpl::current()) 922 if (!RenderThreadImpl::current())
923 return NULL; 923 return NULL;
924 924
925 scoped_refptr<GpuChannelHost> gpu_channel_host( 925 scoped_refptr<GpuChannelHost> gpu_channel_host(
926 RenderThreadImpl::current()->EstablishGpuChannelSync( 926 RenderThreadImpl::current()->EstablishGpuChannelSync(
927 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); 927 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) );
928 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 928 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
929 gpu_channel_host.get(), 929 gpu_channel_host.get(),
930 attributes, 930 attributes,
931 GURL(attributes.topDocumentURL)); 931 GURL(attributes.topDocumentURL));
932 } 932 }
933 933
934 //------------------------------------------------------------------------------ 934 //------------------------------------------------------------------------------
935 935
936 WebKit::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: 936 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl::
937 createSharedOffscreenGraphicsContext3DProvider() { 937 createSharedOffscreenGraphicsContext3DProvider() {
938 scoped_refptr<cc::ContextProvider> provider = 938 scoped_refptr<cc::ContextProvider> provider =
939 RenderThreadImpl::current()->SharedMainThreadContextProvider(); 939 RenderThreadImpl::current()->SharedMainThreadContextProvider();
940 if (!provider) 940 if (!provider)
941 return NULL; 941 return NULL;
942 return new webkit::gpu::WebGraphicsContext3DProviderImpl(provider); 942 return new webkit::gpu::WebGraphicsContext3DProviderImpl(provider);
943 } 943 }
944 944
945 //------------------------------------------------------------------------------ 945 //------------------------------------------------------------------------------
946 946
947 WebKit::WebCompositorSupport* 947 blink::WebCompositorSupport*
948 RendererWebKitPlatformSupportImpl::compositorSupport() { 948 RendererWebKitPlatformSupportImpl::compositorSupport() {
949 return &compositor_support_; 949 return &compositor_support_;
950 } 950 }
951 951
952 //------------------------------------------------------------------------------ 952 //------------------------------------------------------------------------------
953 953
954 WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( 954 blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
955 const WebKit::WebString& host, 955 const blink::WebString& host,
956 const WebKit::WebString& languages) { 956 const blink::WebString& languages) {
957 return net::IDNToUnicode(host.utf8(), languages.utf8()); 957 return net::IDNToUnicode(host.utf8(), languages.utf8());
958 } 958 }
959 959
960 //------------------------------------------------------------------------------ 960 //------------------------------------------------------------------------------
961 961
962 void RendererWebKitPlatformSupportImpl::setDeviceMotionListener( 962 void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
963 WebKit::WebDeviceMotionListener* listener) { 963 blink::WebDeviceMotionListener* listener) {
964 if (g_test_device_motion_data == 0) { 964 if (g_test_device_motion_data == 0) {
965 if (!device_motion_event_pump_) { 965 if (!device_motion_event_pump_) {
966 device_motion_event_pump_.reset(new DeviceMotionEventPump); 966 device_motion_event_pump_.reset(new DeviceMotionEventPump);
967 device_motion_event_pump_->Attach(RenderThreadImpl::current()); 967 device_motion_event_pump_->Attach(RenderThreadImpl::current());
968 } 968 }
969 device_motion_event_pump_->SetListener(listener); 969 device_motion_event_pump_->SetListener(listener);
970 } else if (listener) { 970 } else if (listener) {
971 // Testing mode: just echo the test data to the listener. 971 // Testing mode: just echo the test data to the listener.
972 base::MessageLoopProxy::current()->PostTask( 972 base::MessageLoopProxy::current()->PostTask(
973 FROM_HERE, 973 FROM_HERE,
974 base::Bind(&WebKit::WebDeviceMotionListener::didChangeDeviceMotion, 974 base::Bind(&blink::WebDeviceMotionListener::didChangeDeviceMotion,
975 base::Unretained(listener), 975 base::Unretained(listener),
976 g_test_device_motion_data.Get())); 976 g_test_device_motion_data.Get()));
977 } 977 }
978 } 978 }
979 979
980 // static 980 // static
981 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting( 981 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
982 const WebKit::WebDeviceMotionData& data) { 982 const blink::WebDeviceMotionData& data) {
983 g_test_device_motion_data.Get() = data; 983 g_test_device_motion_data.Get() = data;
984 } 984 }
985 985
986 //------------------------------------------------------------------------------ 986 //------------------------------------------------------------------------------
987 987
988 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener( 988 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
989 WebKit::WebDeviceOrientationListener* listener) { 989 blink::WebDeviceOrientationListener* listener) {
990 if (g_test_device_orientation_data == 0) { 990 if (g_test_device_orientation_data == 0) {
991 if (!device_orientation_event_pump_) { 991 if (!device_orientation_event_pump_) {
992 device_orientation_event_pump_.reset(new DeviceOrientationEventPump); 992 device_orientation_event_pump_.reset(new DeviceOrientationEventPump);
993 device_orientation_event_pump_->Attach(RenderThreadImpl::current()); 993 device_orientation_event_pump_->Attach(RenderThreadImpl::current());
994 } 994 }
995 device_orientation_event_pump_->SetListener(listener); 995 device_orientation_event_pump_->SetListener(listener);
996 } else if (listener) { 996 } else if (listener) {
997 // Testing mode: just echo the test data to the listener. 997 // Testing mode: just echo the test data to the listener.
998 base::MessageLoopProxy::current()->PostTask( 998 base::MessageLoopProxy::current()->PostTask(
999 FROM_HERE, 999 FROM_HERE,
1000 base::Bind( 1000 base::Bind(
1001 &WebKit::WebDeviceOrientationListener::didChangeDeviceOrientation, 1001 &blink::WebDeviceOrientationListener::didChangeDeviceOrientation,
1002 base::Unretained(listener), 1002 base::Unretained(listener),
1003 g_test_device_orientation_data.Get())); 1003 g_test_device_orientation_data.Get()));
1004 } 1004 }
1005 } 1005 }
1006 1006
1007 // static 1007 // static
1008 void RendererWebKitPlatformSupportImpl::SetMockDeviceOrientationDataForTesting( 1008 void RendererWebKitPlatformSupportImpl::SetMockDeviceOrientationDataForTesting(
1009 const WebKit::WebDeviceOrientationData& data) { 1009 const blink::WebDeviceOrientationData& data) {
1010 g_test_device_orientation_data.Get() = data; 1010 g_test_device_orientation_data.Get() = data;
1011 } 1011 }
1012 1012
1013 //------------------------------------------------------------------------------ 1013 //------------------------------------------------------------------------------
1014 1014
1015 WebKit::WebCrypto* RendererWebKitPlatformSupportImpl::crypto() { 1015 blink::WebCrypto* RendererWebKitPlatformSupportImpl::crypto() {
1016 if (!web_crypto_) 1016 if (!web_crypto_)
1017 web_crypto_.reset(new WebCryptoImpl()); 1017 web_crypto_.reset(new WebCryptoImpl());
1018 return web_crypto_.get(); 1018 return web_crypto_.get();
1019 1019
1020 } 1020 }
1021 1021
1022 //------------------------------------------------------------------------------ 1022 //------------------------------------------------------------------------------
1023 1023
1024 #if defined(OS_ANDROID) 1024 #if defined(OS_ANDROID)
1025 void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) { 1025 void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) {
1026 RenderThread::Get()->Send( 1026 RenderThread::Get()->Send(
1027 new ViewHostMsg_Vibrate(base::checked_numeric_cast<int64>(milliseconds))); 1027 new ViewHostMsg_Vibrate(base::checked_numeric_cast<int64>(milliseconds)));
1028 } 1028 }
1029 1029
1030 void RendererWebKitPlatformSupportImpl::cancelVibration() { 1030 void RendererWebKitPlatformSupportImpl::cancelVibration() {
1031 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); 1031 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration());
1032 } 1032 }
1033 #endif // defined(OS_ANDROID) 1033 #endif // defined(OS_ANDROID)
1034 1034
1035 //------------------------------------------------------------------------------ 1035 //------------------------------------------------------------------------------
1036 1036
1037 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( 1037 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
1038 const WebKit::WebURL& storage_partition, 1038 const blink::WebURL& storage_partition,
1039 WebKit::WebStorageQuotaType type, 1039 blink::WebStorageQuotaType type,
1040 WebKit::WebStorageQuotaCallbacks* callbacks) { 1040 blink::WebStorageQuotaCallbacks* callbacks) {
1041 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1041 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1042 return; 1042 return;
1043 QuotaDispatcher::ThreadSpecificInstance( 1043 QuotaDispatcher::ThreadSpecificInstance(
1044 thread_safe_sender_.get(), 1044 thread_safe_sender_.get(),
1045 quota_message_filter_.get())->QueryStorageUsageAndQuota( 1045 quota_message_filter_.get())->QueryStorageUsageAndQuota(
1046 storage_partition, 1046 storage_partition,
1047 static_cast<quota::StorageType>(type), 1047 static_cast<quota::StorageType>(type),
1048 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1048 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1049 } 1049 }
1050 1050
1051 } // namespace content 1051 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | content/renderer/resource_fetcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698