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

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

Issue 976163002: [Win, Android] Don't create WebSandboxSupport when it would have no methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_blink_platform_impl.h" 5 #include "content/renderer/renderer_blink_platform_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/logging.h" 10 #include "base/logging.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 #include "base/synchronization/lock.h" 104 #include "base/synchronization/lock.h"
105 #include "content/common/child_process_sandbox_support_impl_linux.h" 105 #include "content/common/child_process_sandbox_support_impl_linux.h"
106 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" 106 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
107 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" 107 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
108 #include "third_party/icu/source/common/unicode/utf16.h" 108 #include "third_party/icu/source/common/unicode/utf16.h"
109 #endif 109 #endif
110 #endif 110 #endif
111 111
112 #if defined(OS_WIN) 112 #if defined(OS_WIN)
113 #include "content/common/child_process_messages.h" 113 #include "content/common/child_process_messages.h"
114 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
115 #endif 114 #endif
116 115
117 #if defined(USE_AURA) 116 #if defined(USE_AURA)
118 #include "content/renderer/webscrollbarbehavior_impl_gtkoraura.h" 117 #include "content/renderer/webscrollbarbehavior_impl_gtkoraura.h"
119 #elif !defined(OS_MACOSX) 118 #elif !defined(OS_MACOSX)
120 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h" 119 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
121 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior 120 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior
122 #endif 121 #endif
123 122
124 #if defined(ENABLE_WEBRTC) 123 #if defined(ENABLE_WEBRTC)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl { 180 class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl {
182 public: 181 public:
183 explicit FileUtilities(ThreadSafeSender* sender) 182 explicit FileUtilities(ThreadSafeSender* sender)
184 : thread_safe_sender_(sender) {} 183 : thread_safe_sender_(sender) {}
185 virtual bool getFileInfo(const WebString& path, WebFileInfo& result); 184 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
186 private: 185 private:
187 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const; 186 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const;
188 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 187 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
189 }; 188 };
190 189
191 #if defined(OS_ANDROID) 190 #if !defined(OS_ANDROID) && !defined(OS_WIN)
192 // WebKit doesn't use WebSandboxSupport on android so we don't need to
193 // implement anything here.
194 class RendererBlinkPlatformImpl::SandboxSupport {};
195 #else
196 class RendererBlinkPlatformImpl::SandboxSupport 191 class RendererBlinkPlatformImpl::SandboxSupport
197 : public blink::WebSandboxSupport { 192 : public blink::WebSandboxSupport {
198 public: 193 public:
199 virtual ~SandboxSupport() {} 194 virtual ~SandboxSupport() {}
200 195
201 #if defined(OS_WIN) 196 #if defined(OS_MACOSX)
202 virtual bool ensureFontLoaded(HFONT);
203 #elif defined(OS_MACOSX)
204 virtual bool loadFont( 197 virtual bool loadFont(
205 NSFont* src_font, 198 NSFont* src_font,
206 CGFontRef* container, 199 CGFontRef* container,
207 uint32* font_id); 200 uint32* font_id);
208 #elif defined(OS_POSIX) 201 #elif defined(OS_POSIX)
209 virtual void getFallbackFontForCharacter( 202 virtual void getFallbackFontForCharacter(
210 blink::WebUChar32 character, 203 blink::WebUChar32 character,
211 const char* preferred_locale, 204 const char* preferred_locale,
212 blink::WebFallbackFont* fallbackFont); 205 blink::WebFallbackFont* fallbackFont);
213 virtual void getRenderStyleForStrike( 206 virtual void getRenderStyleForStrike(
214 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out); 207 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out);
215 208
216 private: 209 private:
217 // WebKit likes to ask us for the correct font family to use for a set of 210 // WebKit likes to ask us for the correct font family to use for a set of
218 // unicode code points. It needs this information frequently so we cache it 211 // unicode code points. It needs this information frequently so we cache it
219 // here. 212 // here.
220 base::Lock unicode_font_families_mutex_; 213 base::Lock unicode_font_families_mutex_;
221 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; 214 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
222 #endif 215 #endif
223 }; 216 };
224 #endif // defined(OS_ANDROID) 217 #endif // !defined(OS_ANDROID) && !defined(OS_WIN)
225 218
226 //------------------------------------------------------------------------------ 219 //------------------------------------------------------------------------------
227 220
228 RendererBlinkPlatformImpl::RendererBlinkPlatformImpl( 221 RendererBlinkPlatformImpl::RendererBlinkPlatformImpl(
229 RendererScheduler* renderer_scheduler) 222 RendererScheduler* renderer_scheduler)
230 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()), 223 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()),
231 web_scheduler_(new WebSchedulerImpl(renderer_scheduler)), 224 web_scheduler_(new WebSchedulerImpl(renderer_scheduler)),
232 main_thread_(new WebThreadImplForScheduler(renderer_scheduler)), 225 main_thread_(new WebThreadImplForScheduler(renderer_scheduler)),
233 clipboard_delegate_(new RendererClipboardDelegate), 226 clipboard_delegate_(new RendererClipboardDelegate),
234 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())), 227 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())),
235 mime_registry_(new RendererBlinkPlatformImpl::MimeRegistry), 228 mime_registry_(new RendererBlinkPlatformImpl::MimeRegistry),
236 sudden_termination_disables_(0), 229 sudden_termination_disables_(0),
237 plugin_refresh_allowed_(true), 230 plugin_refresh_allowed_(true),
238 default_task_runner_(renderer_scheduler->DefaultTaskRunner()), 231 default_task_runner_(renderer_scheduler->DefaultTaskRunner()),
239 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { 232 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) {
233 #if !defined(OS_ANDROID) && !defined(OS_WIN)
240 if (g_sandbox_enabled && sandboxEnabled()) { 234 if (g_sandbox_enabled && sandboxEnabled()) {
241 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); 235 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport);
242 } else { 236 } else {
243 DVLOG(1) << "Disabling sandbox support for testing."; 237 DVLOG(1) << "Disabling sandbox support for testing.";
244 } 238 }
239 #endif
245 240
246 // ChildThread may not exist in some tests. 241 // ChildThread may not exist in some tests.
247 if (ChildThreadImpl::current()) { 242 if (ChildThreadImpl::current()) {
248 sync_message_filter_ = ChildThreadImpl::current()->sync_message_filter(); 243 sync_message_filter_ = ChildThreadImpl::current()->sync_message_filter();
249 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); 244 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender();
250 quota_message_filter_ = ChildThreadImpl::current()->quota_message_filter(); 245 quota_message_filter_ = ChildThreadImpl::current()->quota_message_filter();
251 blob_registry_.reset(new WebBlobRegistryImpl(thread_safe_sender_.get())); 246 blob_registry_.reset(new WebBlobRegistryImpl(thread_safe_sender_.get()));
252 web_idb_factory_.reset(new WebIDBFactoryImpl(thread_safe_sender_.get())); 247 web_idb_factory_.reset(new WebIDBFactoryImpl(thread_safe_sender_.get()));
253 web_database_observer_impl_.reset( 248 web_database_observer_impl_.reset(
254 new WebDatabaseObserverImpl(sync_message_filter_.get())); 249 new WebDatabaseObserverImpl(sync_message_filter_.get()));
(...skipping 30 matching lines...) Expand all
285 280
286 blink::WebFileUtilities* RendererBlinkPlatformImpl::fileUtilities() { 281 blink::WebFileUtilities* RendererBlinkPlatformImpl::fileUtilities() {
287 if (!file_utilities_) { 282 if (!file_utilities_) {
288 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); 283 file_utilities_.reset(new FileUtilities(thread_safe_sender_.get()));
289 file_utilities_->set_sandbox_enabled(sandboxEnabled()); 284 file_utilities_->set_sandbox_enabled(sandboxEnabled());
290 } 285 }
291 return file_utilities_.get(); 286 return file_utilities_.get();
292 } 287 }
293 288
294 blink::WebSandboxSupport* RendererBlinkPlatformImpl::sandboxSupport() { 289 blink::WebSandboxSupport* RendererBlinkPlatformImpl::sandboxSupport() {
295 #if defined(OS_ANDROID) 290 #if defined(OS_ANDROID) || defined(OS_WIN)
296 // WebKit doesn't use WebSandboxSupport on android. 291 // These platforms do not require sandbox support.
297 return NULL; 292 return NULL;
298 #else 293 #else
299 return sandbox_support_.get(); 294 return sandbox_support_.get();
300 #endif 295 #endif
301 } 296 }
302 297
303 blink::WebCookieJar* RendererBlinkPlatformImpl::cookieJar() { 298 blink::WebCookieJar* RendererBlinkPlatformImpl::cookieJar() {
304 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!"; 299 NOTREACHED() << "Use WebFrameClient::cookieJar() instead!";
305 return NULL; 300 return NULL;
306 } 301 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 IPC::SyncMessage* msg) const { 507 IPC::SyncMessage* msg) const {
513 base::TimeTicks begin = base::TimeTicks::Now(); 508 base::TimeTicks begin = base::TimeTicks::Now();
514 const bool success = thread_safe_sender_->Send(msg); 509 const bool success = thread_safe_sender_->Send(msg);
515 base::TimeDelta delta = base::TimeTicks::Now() - begin; 510 base::TimeDelta delta = base::TimeTicks::Now() - begin;
516 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta); 511 UMA_HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta);
517 return success; 512 return success;
518 } 513 }
519 514
520 //------------------------------------------------------------------------------ 515 //------------------------------------------------------------------------------
521 516
522 #if defined(OS_WIN) 517 #if defined(OS_MACOSX)
523
524 bool RendererBlinkPlatformImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
525 LOGFONT logfont;
526 GetObject(font, sizeof(LOGFONT), &logfont);
527 RenderThread::Get()->PreCacheFont(logfont);
528 return true;
529 }
530
531 #elif defined(OS_MACOSX)
532 518
533 bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font, 519 bool RendererBlinkPlatformImpl::SandboxSupport::loadFont(NSFont* src_font,
534 CGFontRef* out, 520 CGFontRef* out,
535 uint32* font_id) { 521 uint32* font_id) {
536 uint32 font_data_size; 522 uint32 font_data_size;
537 FontDescriptor src_font_descriptor(src_font); 523 FontDescriptor src_font_descriptor(src_font);
538 base::SharedMemoryHandle font_data; 524 base::SharedMemoryHandle font_data;
539 if (!RenderThread::Get()->Send(new ViewHostMsg_LoadFont( 525 if (!RenderThread::Get()->Send(new ViewHostMsg_LoadFont(
540 src_font_descriptor, &font_data_size, &font_data, font_id))) { 526 src_font_descriptor, &font_data_size, &font_data, font_id))) {
541 *out = NULL; 527 *out = NULL;
(...skipping 10 matching lines...) Expand all
552 return false; 538 return false;
553 } 539 }
554 540
555 // TODO(jeremy): Need to call back into WebKit to make sure that the font 541 // TODO(jeremy): Need to call back into WebKit to make sure that the font
556 // isn't already activated, based on the font id. If it's already 542 // isn't already activated, based on the font id. If it's already
557 // activated, don't reactivate it here - crbug.com/72727 . 543 // activated, don't reactivate it here - crbug.com/72727 .
558 544
559 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out); 545 return FontLoader::CGFontRefFromBuffer(font_data, font_data_size, out);
560 } 546 }
561 547
562 #elif defined(OS_ANDROID) 548 #elif defined(OS_POSIX) && !defined(OS_ANDROID)
563
564 // WebKit doesn't use WebSandboxSupport on android so we don't need to
565 // implement anything here. This is cleaner to support than excluding the
566 // whole class for android.
567
568 #elif defined(OS_POSIX)
569 549
570 void RendererBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter( 550 void RendererBlinkPlatformImpl::SandboxSupport::getFallbackFontForCharacter(
571 blink::WebUChar32 character, 551 blink::WebUChar32 character,
572 const char* preferred_locale, 552 const char* preferred_locale,
573 blink::WebFallbackFont* fallbackFont) { 553 blink::WebFallbackFont* fallbackFont) {
574 base::AutoLock lock(unicode_font_families_mutex_); 554 base::AutoLock lock(unicode_font_families_mutex_);
575 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter = 555 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
576 unicode_font_families_.find(character); 556 unicode_font_families_.find(character);
577 if (iter != unicode_font_families_.end()) { 557 if (iter != unicode_font_families_.end()) {
578 fallbackFont->name = iter->second.name; 558 fallbackFont->name = iter->second.name;
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 //------------------------------------------------------------------------------ 1201 //------------------------------------------------------------------------------
1222 1202
1223 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( 1203 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1224 const blink::WebBatteryStatus& status) { 1204 const blink::WebBatteryStatus& status) {
1225 if (!g_test_battery_status_listener) 1205 if (!g_test_battery_status_listener)
1226 return; 1206 return;
1227 g_test_battery_status_listener->updateBatteryStatus(status); 1207 g_test_battery_status_listener->updateBatteryStatus(status);
1228 } 1208 }
1229 1209
1230 } // namespace content 1210 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698