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

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

Issue 20860003: Remove hyphenation code from Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 months 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 16 matching lines...) Expand all
27 #include "content/common/gpu/client/context_provider_command_buffer.h" 27 #include "content/common/gpu/client/context_provider_command_buffer.h"
28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
29 #include "content/common/mime_registry_messages.h" 29 #include "content/common/mime_registry_messages.h"
30 #include "content/common/view_messages.h" 30 #include "content/common/view_messages.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/webplugininfo.h" 32 #include "content/public/common/webplugininfo.h"
33 #include "content/public/renderer/content_renderer_client.h" 33 #include "content/public/renderer/content_renderer_client.h"
34 #include "content/renderer/device_orientation/device_motion_event_pump.h" 34 #include "content/renderer/device_orientation/device_motion_event_pump.h"
35 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 35 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
36 #include "content/renderer/gamepad_shared_memory_reader.h" 36 #include "content/renderer/gamepad_shared_memory_reader.h"
37 #include "content/renderer/hyphenator/hyphenator.h"
38 #include "content/renderer/media/audio_decoder.h" 37 #include "content/renderer/media/audio_decoder.h"
39 #include "content/renderer/media/crypto/key_systems.h" 38 #include "content/renderer/media/crypto/key_systems.h"
40 #include "content/renderer/media/media_stream_dependency_factory.h" 39 #include "content/renderer/media/media_stream_dependency_factory.h"
41 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 40 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
42 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 41 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
43 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 42 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
44 #include "content/renderer/render_thread_impl.h" 43 #include "content/renderer/render_thread_impl.h"
45 #include "content/renderer/renderer_clipboard_client.h" 44 #include "content/renderer/renderer_clipboard_client.h"
46 #include "content/renderer/webclipboard_impl.h" 45 #include "content/renderer/webclipboard_impl.h"
47 #include "content/renderer/webcrypto_impl.h" 46 #include "content/renderer/webcrypto_impl.h"
48 #include "content/renderer/websharedworkerrepository_impl.h" 47 #include "content/renderer/websharedworkerrepository_impl.h"
49 #include "gpu/config/gpu_info.h" 48 #include "gpu/config/gpu_info.h"
50 #include "ipc/ipc_sync_message_filter.h" 49 #include "ipc/ipc_sync_message_filter.h"
51 #include "media/audio/audio_output_device.h" 50 #include "media/audio/audio_output_device.h"
52 #include "media/base/audio_hardware_config.h" 51 #include "media/base/audio_hardware_config.h"
53 #include "media/filters/stream_parser_factory.h" 52 #include "media/filters/stream_parser_factory.h"
54 #include "net/base/mime_util.h" 53 #include "net/base/mime_util.h"
55 #include "net/base/net_util.h" 54 #include "net/base/net_util.h"
56 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 55 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
57 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h" 56 #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h"
58 #include "third_party/WebKit/public/platform/WebFileInfo.h" 57 #include "third_party/WebKit/public/platform/WebFileInfo.h"
59 #include "third_party/WebKit/public/platform/WebGamepads.h" 58 #include "third_party/WebKit/public/platform/WebGamepads.h"
60 #include "third_party/WebKit/public/platform/WebHyphenator.h"
61 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 59 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
62 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" 60 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
63 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" 61 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
64 #include "third_party/WebKit/public/platform/WebURL.h" 62 #include "third_party/WebKit/public/platform/WebURL.h"
65 #include "third_party/WebKit/public/platform/WebVector.h" 63 #include "third_party/WebKit/public/platform/WebVector.h"
66 #include "third_party/WebKit/public/web/WebFrame.h" 64 #include "third_party/WebKit/public/web/WebFrame.h"
67 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 65 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
68 #include "url/gurl.h" 66 #include "url/gurl.h"
69 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" 67 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h"
70 #include "webkit/common/quota/quota_types.h" 68 #include "webkit/common/quota/quota_types.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 explicit FileUtilities(ThreadSafeSender* sender) 155 explicit FileUtilities(ThreadSafeSender* sender)
158 : thread_safe_sender_(sender) {} 156 : thread_safe_sender_(sender) {}
159 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); 157 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
160 virtual base::PlatformFile openFile(const WebKit::WebString& path, 158 virtual base::PlatformFile openFile(const WebKit::WebString& path,
161 int mode); 159 int mode);
162 private: 160 private:
163 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const; 161 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const;
164 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 162 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
165 }; 163 };
166 164
167 class RendererWebKitPlatformSupportImpl::Hyphenator
168 : public WebKit::WebHyphenator {
169 public:
170 Hyphenator();
171 virtual ~Hyphenator();
172
173 virtual bool canHyphenate(const WebKit::WebString& locale);
174 virtual size_t computeLastHyphenLocation(
175 const WebKit::WebString& word,
176 size_t before_index,
177 const WebKit::WebString& locale);
178
179 private:
180 scoped_ptr<content::Hyphenator> hyphenator_;
181
182 DISALLOW_COPY_AND_ASSIGN(Hyphenator);
183 };
184
185 #if defined(OS_ANDROID) 165 #if defined(OS_ANDROID)
186 // WebKit doesn't use WebSandboxSupport on android so we don't need to 166 // WebKit doesn't use WebSandboxSupport on android so we don't need to
187 // implement anything here. 167 // implement anything here.
188 class RendererWebKitPlatformSupportImpl::SandboxSupport { 168 class RendererWebKitPlatformSupportImpl::SandboxSupport {
189 }; 169 };
190 #else 170 #else
191 class RendererWebKitPlatformSupportImpl::SandboxSupport 171 class RendererWebKitPlatformSupportImpl::SandboxSupport
192 : public WebKit::WebSandboxSupport { 172 : public WebKit::WebSandboxSupport {
193 public: 173 public:
194 virtual ~SandboxSupport() {} 174 virtual ~SandboxSupport() {}
(...skipping 24 matching lines...) Expand all
219 #endif 199 #endif
220 }; 200 };
221 #endif // defined(OS_ANDROID) 201 #endif // defined(OS_ANDROID)
222 202
223 //------------------------------------------------------------------------------ 203 //------------------------------------------------------------------------------
224 204
225 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() 205 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl()
226 : clipboard_client_(new RendererClipboardClient), 206 : clipboard_client_(new RendererClipboardClient),
227 clipboard_(new WebClipboardImpl(clipboard_client_.get())), 207 clipboard_(new WebClipboardImpl(clipboard_client_.get())),
228 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), 208 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry),
229 hyphenator_(new RendererWebKitPlatformSupportImpl::Hyphenator),
230 sudden_termination_disables_(0), 209 sudden_termination_disables_(0),
231 plugin_refresh_allowed_(true), 210 plugin_refresh_allowed_(true),
232 shared_worker_repository_(new WebSharedWorkerRepositoryImpl), 211 shared_worker_repository_(new WebSharedWorkerRepositoryImpl),
233 child_thread_loop_(base::MessageLoopProxy::current()) { 212 child_thread_loop_(base::MessageLoopProxy::current()) {
234 if (g_sandbox_enabled && sandboxEnabled()) { 213 if (g_sandbox_enabled && sandboxEnabled()) {
235 sandbox_support_.reset( 214 sandbox_support_.reset(
236 new RendererWebKitPlatformSupportImpl::SandboxSupport); 215 new RendererWebKitPlatformSupportImpl::SandboxSupport);
237 } else { 216 } else {
238 DVLOG(1) << "Disabling sandbox support for testing."; 217 DVLOG(1) << "Disabling sandbox support for testing.";
239 } 218 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const { 540 SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const {
562 base::TimeTicks begin = base::TimeTicks::Now(); 541 base::TimeTicks begin = base::TimeTicks::Now();
563 const bool success = thread_safe_sender_->Send(msg); 542 const bool success = thread_safe_sender_->Send(msg);
564 base::TimeDelta delta = base::TimeTicks::Now() - begin; 543 base::TimeDelta delta = base::TimeTicks::Now() - begin;
565 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta); 544 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta);
566 return success; 545 return success;
567 } 546 }
568 547
569 //------------------------------------------------------------------------------ 548 //------------------------------------------------------------------------------
570 549
571 RendererWebKitPlatformSupportImpl::Hyphenator::Hyphenator() {}
572
573 RendererWebKitPlatformSupportImpl::Hyphenator::~Hyphenator() {}
574
575 bool RendererWebKitPlatformSupportImpl::Hyphenator::canHyphenate(
576 const WebKit::WebString& locale) {
577 // Return false unless WebKit asks for US English dictionaries because WebKit
578 // can currently hyphenate only English words.
579 if (!locale.isEmpty() && !locale.equals("en-US"))
580 return false;
581
582 // Create a hyphenator object and attach it to the render thread so it can
583 // receive a dictionary file opened by a browser.
584 if (!hyphenator_) {
585 hyphenator_.reset(new content::Hyphenator(base::kInvalidPlatformFileValue));
586 if (!hyphenator_)
587 return false;
588 return hyphenator_->Attach(RenderThreadImpl::current(), locale);
589 }
590 return hyphenator_->CanHyphenate(locale);
591 }
592
593 size_t RendererWebKitPlatformSupportImpl::Hyphenator::computeLastHyphenLocation(
594 const WebKit::WebString& word,
595 size_t before_index,
596 const WebKit::WebString& locale) {
597 // Crash if WebKit calls this function when canHyphenate returns false.
598 DCHECK(locale.isEmpty() || locale.equals("en-US"));
599 DCHECK(hyphenator_.get());
600 return hyphenator_->ComputeLastHyphenLocation(word, before_index);
601 }
602
603 //------------------------------------------------------------------------------
604
605 #if defined(OS_WIN) 550 #if defined(OS_WIN)
606 551
607 bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( 552 bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded(
608 HFONT font) { 553 HFONT font) {
609 LOGFONT logfont; 554 LOGFONT logfont;
610 GetObject(font, sizeof(LOGFONT), &logfont); 555 GetObject(font, sizeof(LOGFONT), &logfont);
611 RenderThread::Get()->PreCacheFont(logfont); 556 RenderThread::Get()->PreCacheFont(logfont);
612 return true; 557 return true;
613 } 558 }
614 559
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 } 963 }
1019 964
1020 // static 965 // static
1021 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting( 966 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(
1022 const WebGamepads& pads) { 967 const WebGamepads& pads) {
1023 g_test_gamepads.Get() = pads; 968 g_test_gamepads.Get() = pads;
1024 } 969 }
1025 970
1026 //------------------------------------------------------------------------------ 971 //------------------------------------------------------------------------------
1027 972
1028 WebKit::WebHyphenator* RendererWebKitPlatformSupportImpl::hyphenator() {
1029 WebKit::WebHyphenator* hyphenator =
1030 GetContentClient()->renderer()->OverrideWebHyphenator();
1031 if (hyphenator)
1032 return hyphenator;
1033 return hyphenator_.get();
1034 }
1035
1036 //------------------------------------------------------------------------------
1037
1038 WebKit::WebSpeechSynthesizer* 973 WebKit::WebSpeechSynthesizer*
1039 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( 974 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer(
1040 WebKit::WebSpeechSynthesizerClient* client) { 975 WebKit::WebSpeechSynthesizerClient* client) {
1041 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); 976 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client);
1042 } 977 }
1043 978
1044 //------------------------------------------------------------------------------ 979 //------------------------------------------------------------------------------
1045 980
1046 bool RendererWebKitPlatformSupportImpl::processMemorySizesInBytes( 981 bool RendererWebKitPlatformSupportImpl::processMemorySizesInBytes(
1047 size_t* private_bytes, size_t* shared_bytes) { 982 size_t* private_bytes, size_t* shared_bytes) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 return; 1089 return;
1155 QuotaDispatcher::ThreadSpecificInstance( 1090 QuotaDispatcher::ThreadSpecificInstance(
1156 thread_safe_sender_.get(), 1091 thread_safe_sender_.get(),
1157 quota_message_filter_.get())->QueryStorageUsageAndQuota( 1092 quota_message_filter_.get())->QueryStorageUsageAndQuota(
1158 storage_partition, 1093 storage_partition,
1159 static_cast<quota::StorageType>(type), 1094 static_cast<quota::StorageType>(type),
1160 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1095 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1161 } 1096 }
1162 1097
1163 } // namespace content 1098 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | content/shell/common/shell_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698