| 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" | |
| 16 #include "base/memory/ref_counted.h" | |
| 17 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 18 #include "base/string_util.h" | |
| 19 #include "content/common/clipboard_messages.h" | 16 #include "content/common/clipboard_messages.h" |
| 20 #include "content/common/npobject_util.h" | |
| 21 #include "content/common/socket_stream_dispatcher.h" | |
| 22 #include "content/common/view_messages.h" | |
| 23 #include "content/public/common/content_switches.h" | |
| 24 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 25 #include "content/public/renderer/content_renderer_client.h" | 18 #include "content/public/renderer/content_renderer_client.h" |
| 26 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
| 27 #include "googleurl/src/url_util.h" | |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" | |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | |
| 32 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
| 33 #include "ui/base/ui_base_switches.h" | 21 #include "ui/gfx/size.h" |
| 34 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 22 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
| 35 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
| 36 #include "webkit/glue/websocketstreamhandle_bridge.h" | |
| 37 | 24 |
| 38 // This definition of WriteBitmapFromPixels uses shared memory to communicate | 25 // This definition of WriteBitmapFromPixels uses shared memory to communicate |
| 39 // across processes. | 26 // across processes. |
| 40 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, | 27 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, |
| 41 const gfx::Size& size) { | 28 const gfx::Size& size) { |
| 42 // Do not try to write a bitmap more than once | 29 // Do not try to write a bitmap more than once |
| 43 if (shared_buf_) | 30 if (shared_buf_) |
| 44 return; | 31 return; |
| 45 | 32 |
| 46 uint32 buf_size = 4 * size.width() * size.height(); | 33 uint32 buf_size = 4 * size.width() * size.height(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 uint32 image_size; | 129 uint32 image_size; |
| 143 RenderThreadImpl::current()->Send( | 130 RenderThreadImpl::current()->Send( |
| 144 new ClipboardHostMsg_ReadImage(buffer, &image_handle, &image_size)); | 131 new ClipboardHostMsg_ReadImage(buffer, &image_handle, &image_size)); |
| 145 if (base::SharedMemory::IsHandleValid(image_handle)) { | 132 if (base::SharedMemory::IsHandleValid(image_handle)) { |
| 146 base::SharedMemory buffer(image_handle, true); | 133 base::SharedMemory buffer(image_handle, true); |
| 147 buffer.Map(image_size); | 134 buffer.Map(image_size); |
| 148 data->append(static_cast<char*>(buffer.memory()), image_size); | 135 data->append(static_cast<char*>(buffer.memory()), image_size); |
| 149 } | 136 } |
| 150 } | 137 } |
| 151 | 138 |
| 152 void GetPlugins(bool refresh, | |
| 153 std::vector<webkit::WebPluginInfo>* plugins) { | |
| 154 if (!RenderThreadImpl::current()->plugin_refresh_allowed()) | |
| 155 refresh = false; | |
| 156 RenderThreadImpl::current()->Send( | |
| 157 new ViewHostMsg_GetPlugins(refresh, plugins)); | |
| 158 } | |
| 159 | |
| 160 bool IsProtocolSupportedForMedia(const GURL& url) { | 139 bool IsProtocolSupportedForMedia(const GURL& url) { |
| 161 // If new protocol is to be added here, we need to make sure the response is | 140 // If new protocol is to be added here, we need to make sure the response is |
| 162 // validated accordingly in the media engine. | 141 // validated accordingly in the media engine. |
| 163 if (url.SchemeIsFile() || url.SchemeIs(chrome::kHttpScheme) || | 142 if (url.SchemeIsFile() || url.SchemeIs(chrome::kHttpScheme) || |
| 164 url.SchemeIs(chrome::kHttpsScheme) || | 143 url.SchemeIs(chrome::kHttpsScheme) || |
| 165 url.SchemeIs(chrome::kDataScheme) || | 144 url.SchemeIs(chrome::kDataScheme) || |
| 166 url.SchemeIs(chrome::kFileSystemScheme) || | 145 url.SchemeIs(chrome::kFileSystemScheme) || |
| 167 url.SchemeIs(chrome::kBlobScheme)) | 146 url.SchemeIs(chrome::kBlobScheme)) |
| 168 return true; | 147 return true; |
| 169 return | 148 return |
| 170 content::GetContentClient()->renderer()->IsProtocolSupportedForMedia(url); | 149 content::GetContentClient()->renderer()->IsProtocolSupportedForMedia(url); |
| 171 } | 150 } |
| 172 | 151 |
| 173 // static factory function | |
| 174 ResourceLoaderBridge* ResourceLoaderBridge::Create( | |
| 175 const ResourceLoaderBridge::RequestInfo& request_info) { | |
| 176 return ChildThread::current()->CreateBridge(request_info); | |
| 177 } | |
| 178 | |
| 179 // static factory function | |
| 180 WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( | |
| 181 WebKit::WebSocketStreamHandle* handle, | |
| 182 WebSocketStreamHandleDelegate* delegate) { | |
| 183 SocketStreamDispatcher* dispatcher = | |
| 184 ChildThread::current()->socket_stream_dispatcher(); | |
| 185 return dispatcher->CreateBridge(handle, delegate); | |
| 186 } | |
| 187 | |
| 188 string16 GetLocalizedString(int message_id) { | |
| 189 return content::GetContentClient()->GetLocalizedString(message_id); | |
| 190 } | |
| 191 | |
| 192 base::StringPiece GetDataResource(int resource_id) { | |
| 193 return content::GetContentClient()->GetDataResource(resource_id); | |
| 194 } | |
| 195 | |
| 196 } // namespace webkit_glue | 152 } // namespace webkit_glue |
| OLD | NEW |