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 "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/database_util.h" | 12 #include "chrome/common/database_util.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/webmessageportchannel_impl.h" | 14 #include "chrome/common/webmessageportchannel_impl.h" |
15 #include "chrome/plugin/npobject_util.h" | 15 #include "chrome/plugin/npobject_util.h" |
16 #include "chrome/renderer/net/renderer_net_predictor.h" | 16 #include "chrome/renderer/net/renderer_net_predictor.h" |
17 #include "chrome/renderer/render_thread.h" | 17 #include "chrome/renderer/render_thread.h" |
18 #include "chrome/renderer/render_view.h" | 18 #include "chrome/renderer/render_view.h" |
19 #include "chrome/renderer/renderer_webindexeddatabase_impl.h" | 19 #include "chrome/renderer/renderer_webindexeddatabase_impl.h" |
20 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 20 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
21 #include "chrome/renderer/visitedlink_slave.h" | 21 #include "chrome/renderer/visitedlink_slave.h" |
22 #include "chrome/renderer/webgles2context_impl.h" | 22 #include "chrome/renderer/webgles2context_impl.h" |
23 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" | 23 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" |
| 24 #include "chrome/renderer/websharedworkerrepository_impl.h" |
24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
25 #include "ipc/ipc_sync_message_filter.h" | 26 #include "ipc/ipc_sync_message_filter.h" |
26 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
27 #include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h" | 28 #include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h" |
28 #include "third_party/WebKit/WebKit/chromium/public/WebIndexedDatabase.h" | 29 #include "third_party/WebKit/WebKit/chromium/public/WebIndexedDatabase.h" |
29 #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h" |
30 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 31 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
31 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
| 33 #include "webkit/glue/simple_webmimeregistry_impl.h" |
| 34 #include "webkit/glue/webclipboard_impl.h" |
| 35 #include "webkit/glue/webfilesystem_impl.h" |
32 #include "webkit/glue/webkit_glue.h" | 36 #include "webkit/glue/webkit_glue.h" |
33 | 37 |
| 38 #if defined(OS_WIN) |
| 39 #include "third_party/WebKit/WebKit/chromium/public/win/WebSandboxSupport.h" |
| 40 #endif |
| 41 |
34 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
35 #include "chrome/common/font_descriptor_mac.h" | 43 #include "chrome/common/font_descriptor_mac.h" |
36 #include "chrome/common/font_loader_mac.h" | 44 #include "chrome/common/font_loader_mac.h" |
| 45 #include "third_party/WebKit/WebKit/chromium/public/mac/WebSandboxSupport.h" |
37 #endif | 46 #endif |
38 | 47 |
39 #if defined(OS_LINUX) | 48 #if defined(OS_LINUX) |
| 49 #include <string> |
| 50 #include <map> |
| 51 |
| 52 #include "base/lock.h" |
40 #include "chrome/renderer/renderer_sandbox_support_linux.h" | 53 #include "chrome/renderer/renderer_sandbox_support_linux.h" |
| 54 #include "third_party/WebKit/WebKit/chromium/public/linux/WebSandboxSupport.h" |
41 #endif | 55 #endif |
42 | 56 |
43 #if defined(OS_POSIX) | 57 #if defined(OS_POSIX) |
44 #include "base/file_descriptor_posix.h" | 58 #include "base/file_descriptor_posix.h" |
45 #endif | 59 #endif |
46 | 60 |
47 using WebKit::WebFrame; | 61 using WebKit::WebFrame; |
48 using WebKit::WebIndexedDatabase; | 62 using WebKit::WebIndexedDatabase; |
49 using WebKit::WebKitClient; | 63 using WebKit::WebKitClient; |
50 using WebKit::WebStorageArea; | 64 using WebKit::WebStorageArea; |
51 using WebKit::WebStorageEventDispatcher; | 65 using WebKit::WebStorageEventDispatcher; |
52 using WebKit::WebStorageNamespace; | 66 using WebKit::WebStorageNamespace; |
53 using WebKit::WebString; | 67 using WebKit::WebString; |
54 using WebKit::WebURL; | 68 using WebKit::WebURL; |
55 using WebKit::WebVector; | 69 using WebKit::WebVector; |
56 | 70 |
| 71 //------------------------------------------------------------------------------ |
| 72 |
| 73 class RendererWebKitClientImpl::MimeRegistry |
| 74 : public webkit_glue::SimpleWebMimeRegistryImpl { |
| 75 public: |
| 76 virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); |
| 77 virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); |
| 78 virtual WebKit::WebString preferredExtensionForMIMEType( |
| 79 const WebKit::WebString&); |
| 80 }; |
| 81 |
| 82 class RendererWebKitClientImpl::FileSystem |
| 83 : public webkit_glue::WebFileSystemImpl { |
| 84 public: |
| 85 virtual bool getFileSize(const WebKit::WebString& path, long long& result); |
| 86 virtual bool getFileModificationTime(const WebKit::WebString& path, |
| 87 double& result); |
| 88 virtual base::PlatformFile openFile(const WebKit::WebString& path, |
| 89 int mode); |
| 90 }; |
| 91 |
| 92 class RendererWebKitClientImpl::SandboxSupport |
| 93 : public WebKit::WebSandboxSupport { |
| 94 public: |
| 95 #if defined(OS_WIN) |
| 96 virtual bool ensureFontLoaded(HFONT); |
| 97 #elif defined(OS_MACOSX) |
| 98 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); |
| 99 #elif defined(OS_LINUX) |
| 100 virtual WebKit::WebString getFontFamilyForCharacters( |
| 101 const WebKit::WebUChar* characters, size_t numCharacters); |
| 102 virtual void getRenderStyleForStrike( |
| 103 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
| 104 |
| 105 private: |
| 106 // WebKit likes to ask us for the correct font family to use for a set of |
| 107 // unicode code points. It needs this information frequently so we cache it |
| 108 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
| 109 // The value is a string containing the correct font family. |
| 110 Lock unicode_font_families_mutex_; |
| 111 std::map<std::string, std::string> unicode_font_families_; |
| 112 #endif |
| 113 }; |
| 114 |
| 115 //------------------------------------------------------------------------------ |
| 116 |
57 RendererWebKitClientImpl::RendererWebKitClientImpl() | 117 RendererWebKitClientImpl::RendererWebKitClientImpl() |
58 : sudden_termination_disables_(0) { | 118 : clipboard_(new webkit_glue::WebClipboardImpl), |
| 119 file_system_(new RendererWebKitClientImpl::FileSystem), |
| 120 mime_registry_(new RendererWebKitClientImpl::MimeRegistry), |
| 121 sandbox_support_(new RendererWebKitClientImpl::SandboxSupport), |
| 122 sudden_termination_disables_(0), |
| 123 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { |
59 } | 124 } |
60 | 125 |
61 RendererWebKitClientImpl::~RendererWebKitClientImpl() { | 126 RendererWebKitClientImpl::~RendererWebKitClientImpl() { |
62 } | 127 } |
63 | 128 |
64 //------------------------------------------------------------------------------ | 129 //------------------------------------------------------------------------------ |
65 | 130 |
66 WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() { | 131 WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() { |
67 return &clipboard_; | 132 return clipboard_.get(); |
68 } | 133 } |
69 | 134 |
70 WebKit::WebMimeRegistry* RendererWebKitClientImpl::mimeRegistry() { | 135 WebKit::WebMimeRegistry* RendererWebKitClientImpl::mimeRegistry() { |
71 return &mime_registry_; | 136 return mime_registry_.get(); |
72 } | 137 } |
73 | 138 |
74 WebKit::WebFileSystem* RendererWebKitClientImpl::fileSystem() { | 139 WebKit::WebFileSystem* RendererWebKitClientImpl::fileSystem() { |
75 return &file_system_; | 140 return file_system_.get(); |
76 } | 141 } |
77 | 142 |
78 WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() { | 143 WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() { |
79 return &sandbox_support_; | 144 return sandbox_support_.get(); |
80 } | 145 } |
81 | 146 |
82 WebKit::WebCookieJar* RendererWebKitClientImpl::cookieJar() { | 147 WebKit::WebCookieJar* RendererWebKitClientImpl::cookieJar() { |
83 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; | 148 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; |
84 return NULL; | 149 return NULL; |
85 } | 150 } |
86 | 151 |
87 bool RendererWebKitClientImpl::sandboxEnabled() { | 152 bool RendererWebKitClientImpl::sandboxEnabled() { |
88 // As explained in WebKitClient.h, this function is used to decide whether to | 153 // As explained in WebKitClient.h, this function is used to decide whether to |
89 // allow file system operations to come out of WebKit or not. Even if the | 154 // allow file system operations to come out of WebKit or not. Even if the |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 443 |
379 long long RendererWebKitClientImpl::databaseGetFileSize( | 444 long long RendererWebKitClientImpl::databaseGetFileSize( |
380 const WebString& vfs_file_name) { | 445 const WebString& vfs_file_name) { |
381 return DatabaseUtil::databaseGetFileSize(vfs_file_name); | 446 return DatabaseUtil::databaseGetFileSize(vfs_file_name); |
382 } | 447 } |
383 | 448 |
384 WebKit::WebSharedWorkerRepository* | 449 WebKit::WebSharedWorkerRepository* |
385 RendererWebKitClientImpl::sharedWorkerRepository() { | 450 RendererWebKitClientImpl::sharedWorkerRepository() { |
386 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 451 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
387 switches::kDisableSharedWorkers)) { | 452 switches::kDisableSharedWorkers)) { |
388 return &shared_worker_repository_; | 453 return shared_worker_repository_.get(); |
389 } else { | 454 } else { |
390 return NULL; | 455 return NULL; |
391 } | 456 } |
392 } | 457 } |
393 | 458 |
394 WebKit::WebGraphicsContext3D* | 459 WebKit::WebGraphicsContext3D* |
395 RendererWebKitClientImpl::createGraphicsContext3D() { | 460 RendererWebKitClientImpl::createGraphicsContext3D() { |
396 // TODO(kbr): remove the WebGraphicsContext3D::createDefault code path | 461 // TODO(kbr): remove the WebGraphicsContext3D::createDefault code path |
397 // completely. | 462 // completely. |
398 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | 463 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
(...skipping 23 matching lines...) Expand all Loading... |
422 const WebKit::WebString& challenge, | 487 const WebKit::WebString& challenge, |
423 const WebKit::WebURL& url) { | 488 const WebKit::WebURL& url) { |
424 std::string signed_public_key; | 489 std::string signed_public_key; |
425 RenderThread::current()->Send(new ViewHostMsg_Keygen( | 490 RenderThread::current()->Send(new ViewHostMsg_Keygen( |
426 static_cast<uint32>(key_size_index), | 491 static_cast<uint32>(key_size_index), |
427 challenge.utf8(), | 492 challenge.utf8(), |
428 GURL(url), | 493 GURL(url), |
429 &signed_public_key)); | 494 &signed_public_key)); |
430 return WebString::fromUTF8(signed_public_key); | 495 return WebString::fromUTF8(signed_public_key); |
431 } | 496 } |
OLD | NEW |