OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/renderer_webkitclient_impl.h" | 5 #include "chrome/renderer/renderer_webkitclient_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/database_util.h" | 13 #include "chrome/common/database_util.h" |
14 #include "chrome/common/file_system/webfilesystem_impl.h" | 14 #include "chrome/common/file_system/webfilesystem_impl.h" |
| 15 #include "chrome/common/file_utilities_messages.h" |
| 16 #include "chrome/common/mime_registry_messages.h" |
15 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
16 #include "chrome/common/webblobregistry_impl.h" | 18 #include "chrome/common/webblobregistry_impl.h" |
17 #include "chrome/common/webmessageportchannel_impl.h" | 19 #include "chrome/common/webmessageportchannel_impl.h" |
18 #include "chrome/plugin/npobject_util.h" | 20 #include "chrome/plugin/npobject_util.h" |
19 #include "chrome/renderer/net/renderer_net_predictor.h" | 21 #include "chrome/renderer/net/renderer_net_predictor.h" |
20 #include "chrome/renderer/render_thread.h" | 22 #include "chrome/renderer/render_thread.h" |
21 #include "chrome/renderer/render_view.h" | 23 #include "chrome/renderer/render_view.h" |
22 #include "chrome/renderer/renderer_webidbfactory_impl.h" | 24 #include "chrome/renderer/renderer_webidbfactory_impl.h" |
23 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 25 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
24 #include "chrome/renderer/visitedlink_slave.h" | 26 #include "chrome/renderer/visitedlink_slave.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 //------------------------------------------------------------------------------ | 319 //------------------------------------------------------------------------------ |
318 | 320 |
319 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension( | 321 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension( |
320 const WebString& file_extension) { | 322 const WebString& file_extension) { |
321 if (IsPluginProcess()) | 323 if (IsPluginProcess()) |
322 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | 324 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
323 | 325 |
324 // The sandbox restricts our access to the registry, so we need to proxy | 326 // The sandbox restricts our access to the registry, so we need to proxy |
325 // these calls over to the browser process. | 327 // these calls over to the browser process. |
326 std::string mime_type; | 328 std::string mime_type; |
327 RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromExtension( | 329 RenderThread::current()->Send( |
328 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); | 330 new MimeRegistryMsg_GetMimeTypeFromExtension( |
| 331 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); |
329 return ASCIIToUTF16(mime_type); | 332 return ASCIIToUTF16(mime_type); |
330 | 333 |
331 } | 334 } |
332 | 335 |
333 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile( | 336 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile( |
334 const WebString& file_path) { | 337 const WebString& file_path) { |
335 if (IsPluginProcess()) | 338 if (IsPluginProcess()) |
336 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); | 339 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); |
337 | 340 |
338 // The sandbox restricts our access to the registry, so we need to proxy | 341 // The sandbox restricts our access to the registry, so we need to proxy |
339 // these calls over to the browser process. | 342 // these calls over to the browser process. |
340 std::string mime_type; | 343 std::string mime_type; |
341 RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromFile( | 344 RenderThread::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( |
342 FilePath(webkit_glue::WebStringToFilePathString(file_path)), | 345 FilePath(webkit_glue::WebStringToFilePathString(file_path)), |
343 &mime_type)); | 346 &mime_type)); |
344 return ASCIIToUTF16(mime_type); | 347 return ASCIIToUTF16(mime_type); |
345 | 348 |
346 } | 349 } |
347 | 350 |
348 WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType( | 351 WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType( |
349 const WebString& mime_type) { | 352 const WebString& mime_type) { |
350 if (IsPluginProcess()) | 353 if (IsPluginProcess()) |
351 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); | 354 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); |
352 | 355 |
353 // The sandbox restricts our access to the registry, so we need to proxy | 356 // The sandbox restricts our access to the registry, so we need to proxy |
354 // these calls over to the browser process. | 357 // these calls over to the browser process. |
355 FilePath::StringType file_extension; | 358 FilePath::StringType file_extension; |
356 RenderThread::current()->Send( | 359 RenderThread::current()->Send( |
357 new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type), | 360 new MimeRegistryMsg_GetPreferredExtensionForMimeType( |
358 &file_extension)); | 361 UTF16ToASCII(mime_type), &file_extension)); |
359 return webkit_glue::FilePathStringToWebString(file_extension); | 362 return webkit_glue::FilePathStringToWebString(file_extension); |
360 } | 363 } |
361 | 364 |
362 //------------------------------------------------------------------------------ | 365 //------------------------------------------------------------------------------ |
363 | 366 |
364 bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, | 367 bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, |
365 long long& result) { | 368 long long& result) { |
366 if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileSize( | 369 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize( |
367 webkit_glue::WebStringToFilePath(path), | 370 webkit_glue::WebStringToFilePath(path), |
368 reinterpret_cast<int64*>(&result)))) { | 371 reinterpret_cast<int64*>(&result)))) { |
369 return result >= 0; | 372 return result >= 0; |
370 } | 373 } |
371 | 374 |
372 result = -1; | 375 result = -1; |
373 return false; | 376 return false; |
374 } | 377 } |
375 | 378 |
376 void RendererWebKitClientImpl::FileUtilities::revealFolderInOS( | 379 void RendererWebKitClientImpl::FileUtilities::revealFolderInOS( |
377 const WebString& path) { | 380 const WebString& path) { |
378 FilePath file_path(webkit_glue::WebStringToFilePath(path)); | 381 FilePath file_path(webkit_glue::WebStringToFilePath(path)); |
379 file_util::AbsolutePath(&file_path); | 382 file_util::AbsolutePath(&file_path); |
380 RenderThread::current()->Send(new ViewHostMsg_RevealFolderInOS(file_path)); | 383 RenderThread::current()->Send(new ViewHostMsg_RevealFolderInOS(file_path)); |
381 } | 384 } |
382 | 385 |
383 bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime( | 386 bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime( |
384 const WebString& path, | 387 const WebString& path, |
385 double& result) { | 388 double& result) { |
386 base::Time time; | 389 base::Time time; |
387 if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileModificationTime( | 390 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime( |
388 webkit_glue::WebStringToFilePath(path), &time))) { | 391 webkit_glue::WebStringToFilePath(path), &time))) { |
389 result = time.ToDoubleT(); | 392 result = time.ToDoubleT(); |
390 return !time.is_null(); | 393 return !time.is_null(); |
391 } | 394 } |
392 | 395 |
393 result = 0; | 396 result = 0; |
394 return false; | 397 return false; |
395 } | 398 } |
396 | 399 |
397 base::PlatformFile RendererWebKitClientImpl::FileUtilities::openFile( | 400 base::PlatformFile RendererWebKitClientImpl::FileUtilities::openFile( |
398 const WebString& path, | 401 const WebString& path, |
399 int mode) { | 402 int mode) { |
400 IPC::PlatformFileForTransit handle = IPC::InvalidPlatformFileForTransit(); | 403 IPC::PlatformFileForTransit handle = IPC::InvalidPlatformFileForTransit(); |
401 SendSyncMessageFromAnyThread(new ViewHostMsg_OpenFile( | 404 SendSyncMessageFromAnyThread(new FileUtilitiesMsg_OpenFile( |
402 webkit_glue::WebStringToFilePath(path), mode, &handle)); | 405 webkit_glue::WebStringToFilePath(path), mode, &handle)); |
403 return IPC::PlatformFileForTransitToPlatformFile(handle); | 406 return IPC::PlatformFileForTransitToPlatformFile(handle); |
404 } | 407 } |
405 | 408 |
406 //------------------------------------------------------------------------------ | 409 //------------------------------------------------------------------------------ |
407 | 410 |
408 #if defined(OS_WIN) | 411 #if defined(OS_WIN) |
409 | 412 |
410 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { | 413 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { |
411 LOGFONT logfont; | 414 LOGFONT logfont; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 return WebString::fromUTF8(signed_public_key); | 533 return WebString::fromUTF8(signed_public_key); |
531 } | 534 } |
532 | 535 |
533 //------------------------------------------------------------------------------ | 536 //------------------------------------------------------------------------------ |
534 | 537 |
535 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 538 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
536 if (!blob_registry_.get()) | 539 if (!blob_registry_.get()) |
537 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 540 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
538 return blob_registry_.get(); | 541 return blob_registry_.get(); |
539 } | 542 } |
OLD | NEW |