OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file provides the Chrome-specific embedder's side of random webkit glue |
| 6 // functions. |
| 7 |
| 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/common/chrome_version_info.h" |
| 10 #include "chrome/common/render_messages.h" |
| 11 #include "content/renderer/render_thread.h" |
| 12 #include "webkit/glue/webkit_glue.h" |
| 13 |
| 14 #if !defined(DISABLE_NACL) |
| 15 #include "native_client/src/shared/imc/nacl_imc.h" |
| 16 #include "native_client/src/trusted/plugin/nacl_entry_points.h" |
| 17 #endif |
| 18 |
| 19 namespace webkit_glue { |
| 20 |
| 21 void UserMetricsRecordAction(const std::string& action) { |
| 22 RenderThread::current()->Send( |
| 23 new ViewHostMsg_UserMetricsRecordAction(action)); |
| 24 } |
| 25 |
| 26 std::string GetProductVersion() { |
| 27 chrome::VersionInfo version_info; |
| 28 std::string product("Chrome/"); |
| 29 product += version_info.is_valid() ? version_info.Version() |
| 30 : "0.0.0.0"; |
| 31 return product; |
| 32 } |
| 33 |
| 34 #if !defined(DISABLE_NACL) |
| 35 bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles, |
| 36 void* nacl_process_handle, int* nacl_process_id) { |
| 37 std::vector<nacl::FileDescriptor> sockets; |
| 38 base::ProcessHandle nacl_process; |
| 39 if (!RenderThread::current()->Send( |
| 40 new ViewHostMsg_LaunchNaCl( |
| 41 ASCIIToWide(alleged_url), |
| 42 socket_count, |
| 43 &sockets, |
| 44 &nacl_process, |
| 45 reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { |
| 46 return false; |
| 47 } |
| 48 CHECK(static_cast<int>(sockets.size()) == socket_count); |
| 49 for (int i = 0; i < socket_count; i++) { |
| 50 static_cast<nacl::Handle*>(imc_handles)[i] = |
| 51 nacl::ToNativeHandle(sockets[i]); |
| 52 } |
| 53 *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; |
| 54 return true; |
| 55 } |
| 56 #endif |
| 57 |
| 58 } // namespace webkit_glue |
OLD | NEW |