| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file provides the embedder's side of random webkit glue functions. | 5 // This file provides the embedder's side of random webkit glue functions. |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/utf_string_conversions.h" | |
| 19 #include "chrome/common/chrome_switches.h" | |
| 20 #include "chrome/common/chrome_version_info.h" | |
| 21 #include "chrome/common/render_messages.h" | |
| 22 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 23 #include "content/common/clipboard_messages.h" | 19 #include "content/common/clipboard_messages.h" |
| 20 #include "content/common/content_switches.h" |
| 24 #include "content/common/socket_stream_dispatcher.h" | 21 #include "content/common/socket_stream_dispatcher.h" |
| 25 #include "content/common/view_messages.h" | 22 #include "content/common/view_messages.h" |
| 26 #include "content/plugin/npobject_util.h" | 23 #include "content/plugin/npobject_util.h" |
| 27 #include "content/renderer/render_thread.h" | 24 #include "content/renderer/render_thread.h" |
| 28 #include "googleurl/src/url_util.h" | 25 #include "googleurl/src/url_util.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 33 #include "ui/base/clipboard/clipboard.h" | 30 #include "ui/base/clipboard/clipboard.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 32 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
| 36 #include "webkit/glue/webkit_glue.h" | 33 #include "webkit/glue/webkit_glue.h" |
| 37 #include "webkit/glue/websocketstreamhandle_bridge.h" | 34 #include "webkit/glue/websocketstreamhandle_bridge.h" |
| 38 | 35 |
| 39 #if !defined(DISABLE_NACL) | |
| 40 #include "native_client/src/shared/imc/nacl_imc.h" | |
| 41 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | |
| 42 #endif | |
| 43 | |
| 44 #if defined(OS_LINUX) | 36 #if defined(OS_LINUX) |
| 45 #include "content/renderer/renderer_sandbox_support_linux.h" | 37 #include "content/renderer/renderer_sandbox_support_linux.h" |
| 46 #endif | 38 #endif |
| 47 | 39 |
| 48 // This definition of WriteBitmapFromPixels uses shared memory to communicate | 40 // This definition of WriteBitmapFromPixels uses shared memory to communicate |
| 49 // across processes. | 41 // across processes. |
| 50 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, | 42 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, |
| 51 const gfx::Size& size) { | 43 const gfx::Size& size) { |
| 52 // Do not try to write a bitmap more than once | 44 // Do not try to write a bitmap more than once |
| 53 if (shared_buf_) | 45 if (shared_buf_) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 RenderThread::current()->Send(new ViewHostMsg_GetPlugins(refresh, plugins)); | 194 RenderThread::current()->Send(new ViewHostMsg_GetPlugins(refresh, plugins)); |
| 203 } | 195 } |
| 204 | 196 |
| 205 bool IsProtocolSupportedForMedia(const GURL& url) { | 197 bool IsProtocolSupportedForMedia(const GURL& url) { |
| 206 // If new protocol is to be added here, we need to make sure the response is | 198 // If new protocol is to be added here, we need to make sure the response is |
| 207 // validated accordingly in the media engine. | 199 // validated accordingly in the media engine. |
| 208 if (url.SchemeIsFile() || url.SchemeIs(chrome::kHttpScheme) || | 200 if (url.SchemeIsFile() || url.SchemeIs(chrome::kHttpScheme) || |
| 209 url.SchemeIs(chrome::kHttpsScheme) || | 201 url.SchemeIs(chrome::kHttpsScheme) || |
| 210 url.SchemeIs(chrome::kDataScheme) || | 202 url.SchemeIs(chrome::kDataScheme) || |
| 211 url.SchemeIs(chrome::kExtensionScheme) || | 203 url.SchemeIs(chrome::kExtensionScheme) || |
| 204 url.SchemeIs(chrome::kFileSystemScheme) || |
| 212 url.SchemeIs(chrome::kBlobScheme)) | 205 url.SchemeIs(chrome::kBlobScheme)) |
| 213 return true; | 206 return true; |
| 214 return false; | 207 return false; |
| 215 } | 208 } |
| 216 | 209 |
| 217 // static factory function | 210 // static factory function |
| 218 ResourceLoaderBridge* ResourceLoaderBridge::Create( | 211 ResourceLoaderBridge* ResourceLoaderBridge::Create( |
| 219 const ResourceLoaderBridge::RequestInfo& request_info) { | 212 const ResourceLoaderBridge::RequestInfo& request_info) { |
| 220 return ChildThread::current()->CreateBridge(request_info); | 213 return ChildThread::current()->CreateBridge(request_info); |
| 221 } | 214 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 242 } | 235 } |
| 243 | 236 |
| 244 void ClearHostResolverCache() { | 237 void ClearHostResolverCache() { |
| 245 RenderThread::current()->ClearHostResolverCache(); | 238 RenderThread::current()->ClearHostResolverCache(); |
| 246 } | 239 } |
| 247 | 240 |
| 248 void ClearPredictorCache() { | 241 void ClearPredictorCache() { |
| 249 RenderThread::current()->ClearPredictorCache(); | 242 RenderThread::current()->ClearPredictorCache(); |
| 250 } | 243 } |
| 251 | 244 |
| 252 std::string GetProductVersion() { | |
| 253 chrome::VersionInfo version_info; | |
| 254 std::string product("Chrome/"); | |
| 255 product += version_info.is_valid() ? version_info.Version() | |
| 256 : "0.0.0.0"; | |
| 257 return product; | |
| 258 } | |
| 259 | |
| 260 bool IsSingleProcess() { | 245 bool IsSingleProcess() { |
| 261 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 246 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
| 262 } | 247 } |
| 263 | 248 |
| 264 void EnableSpdy(bool enable) { | 249 void EnableSpdy(bool enable) { |
| 265 RenderThread::current()->EnableSpdy(enable); | 250 RenderThread::current()->EnableSpdy(enable); |
| 266 } | 251 } |
| 267 | 252 |
| 268 void UserMetricsRecordAction(const std::string& action) { | |
| 269 RenderThread::current()->Send( | |
| 270 new ViewHostMsg_UserMetricsRecordAction(action)); | |
| 271 } | |
| 272 | |
| 273 #if !defined(DISABLE_NACL) | |
| 274 bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles, | |
| 275 void* nacl_process_handle, int* nacl_process_id) { | |
| 276 std::vector<nacl::FileDescriptor> sockets; | |
| 277 base::ProcessHandle nacl_process; | |
| 278 if (!RenderThread::current()->Send( | |
| 279 new ViewHostMsg_LaunchNaCl( | |
| 280 ASCIIToWide(alleged_url), | |
| 281 socket_count, | |
| 282 &sockets, | |
| 283 &nacl_process, | |
| 284 reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { | |
| 285 return false; | |
| 286 } | |
| 287 CHECK(static_cast<int>(sockets.size()) == socket_count); | |
| 288 for (int i = 0; i < socket_count; i++) { | |
| 289 static_cast<nacl::Handle*>(imc_handles)[i] = | |
| 290 nacl::ToNativeHandle(sockets[i]); | |
| 291 } | |
| 292 *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; | |
| 293 return true; | |
| 294 } | |
| 295 #endif | |
| 296 | |
| 297 #if defined(OS_LINUX) | 253 #if defined(OS_LINUX) |
| 298 int MatchFontWithFallback(const std::string& face, bool bold, | 254 int MatchFontWithFallback(const std::string& face, bool bold, |
| 299 bool italic, int charset) { | 255 bool italic, int charset) { |
| 300 return renderer_sandbox_support::MatchFontWithFallback( | 256 return renderer_sandbox_support::MatchFontWithFallback( |
| 301 face, bold, italic, charset); | 257 face, bold, italic, charset); |
| 302 } | 258 } |
| 303 | 259 |
| 304 bool GetFontTable(int fd, uint32_t table, uint8_t* output, | 260 bool GetFontTable(int fd, uint32_t table, uint8_t* output, |
| 305 size_t* output_length) { | 261 size_t* output_length) { |
| 306 return renderer_sandbox_support::GetFontTable( | 262 return renderer_sandbox_support::GetFontTable( |
| 307 fd, table, output, output_length); | 263 fd, table, output, output_length); |
| 308 } | 264 } |
| 309 #endif | 265 #endif |
| 310 | 266 |
| 311 } // namespace webkit_glue | 267 } // namespace webkit_glue |
| OLD | NEW |