| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <wininet.h> | 11 #include <wininet.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "base/clipboard.h" | 14 #include "base/clipboard.h" |
| 15 #include "base/scoped_clipboard_writer.h" | 15 #include "base/scoped_clipboard_writer.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
| 19 #include "chrome/common/resource_bundle.h" | 19 #include "chrome/common/resource_bundle.h" |
| 20 #include "chrome/plugin/npobject_util.h" | 20 #include "chrome/plugin/npobject_util.h" |
| 21 #include "chrome/renderer/net/render_dns_master.h" | 21 #include "chrome/renderer/net/render_dns_master.h" |
| 22 #include "chrome/renderer/render_process.h" | 22 #include "chrome/renderer/render_process.h" |
| 23 #include "chrome/renderer/render_thread.h" | 23 #include "chrome/renderer/render_thread.h" |
| 24 #include "chrome/renderer/render_view.h" | 24 #include "chrome/renderer/render_view.h" |
| 25 #include "chrome/renderer/visitedlink_slave.h" | 25 #include "chrome/renderer/visitedlink_slave.h" |
| 26 #include "googleurl/src/url_util.h" | 26 #include "googleurl/src/url_util.h" |
| 27 #include "net/base/mime_util.h" | |
| 28 #include "net/base/net_errors.h" | |
| 29 #include "webkit/glue/scoped_clipboard_writer_glue.h" | 27 #include "webkit/glue/scoped_clipboard_writer_glue.h" |
| 30 #include "webkit/glue/webframe.h" | 28 #include "webkit/glue/webframe.h" |
| 31 #include "webkit/glue/webkit_glue.h" | 29 #include "webkit/glue/webkit_glue.h" |
| 32 | 30 |
| 33 #include <vector> | 31 #include <vector> |
| 34 | 32 |
| 35 #include "SkBitmap.h" | 33 #include "SkBitmap.h" |
| 36 | 34 |
| 37 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 38 #include <strsafe.h> // note: per msdn docs, this must *follow* other includes | 36 #include <strsafe.h> // note: per msdn docs, this must *follow* other includes |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // TBD: jar: Need implementation that loads the targetted URL into our cache. | 165 // TBD: jar: Need implementation that loads the targetted URL into our cache. |
| 168 // For now, at least prefetch DNS lookup | 166 // For now, at least prefetch DNS lookup |
| 169 GURL parsed_url(WideToUTF8(std::wstring(url, url_length))); | 167 GURL parsed_url(WideToUTF8(std::wstring(url, url_length))); |
| 170 PrefetchDns(parsed_url.host()); | 168 PrefetchDns(parsed_url.host()); |
| 171 } | 169 } |
| 172 | 170 |
| 173 void AppendToLog(const char* file, int line, const char* msg) { | 171 void AppendToLog(const char* file, int line, const char* msg) { |
| 174 logging::LogMessage(file, line).stream() << msg; | 172 logging::LogMessage(file, line).stream() << msg; |
| 175 } | 173 } |
| 176 | 174 |
| 177 bool GetMimeTypeFromExtension(const FilePath::StringType &ext, | |
| 178 std::string *mime_type) { | |
| 179 if (IsPluginProcess()) | |
| 180 return net::GetMimeTypeFromExtension(ext, mime_type); | |
| 181 | |
| 182 // The sandbox restricts our access to the registry, so we need to proxy | |
| 183 // these calls over to the browser process. | |
| 184 DCHECK(mime_type->empty()); | |
| 185 RenderThread::current()->Send( | |
| 186 new ViewHostMsg_GetMimeTypeFromExtension(ext, mime_type)); | |
| 187 return !mime_type->empty(); | |
| 188 } | |
| 189 | |
| 190 bool GetMimeTypeFromFile(const FilePath &file_path, | |
| 191 std::string *mime_type) { | |
| 192 if (IsPluginProcess()) | |
| 193 return net::GetMimeTypeFromFile(file_path, mime_type); | |
| 194 | |
| 195 // The sandbox restricts our access to the registry, so we need to proxy | |
| 196 // these calls over to the browser process. | |
| 197 DCHECK(mime_type->empty()); | |
| 198 RenderThread::current()->Send( | |
| 199 new ViewHostMsg_GetMimeTypeFromFile(file_path, mime_type)); | |
| 200 return !mime_type->empty(); | |
| 201 } | |
| 202 | |
| 203 bool GetPreferredExtensionForMimeType(const std::string& mime_type, | |
| 204 FilePath::StringType* ext) { | |
| 205 if (IsPluginProcess()) | |
| 206 return net::GetPreferredExtensionForMimeType(mime_type, ext); | |
| 207 | |
| 208 // The sandbox restricts our access to the registry, so we need to proxy | |
| 209 // these calls over to the browser process. | |
| 210 DCHECK(ext->empty()); | |
| 211 RenderThread::current()->Send( | |
| 212 new ViewHostMsg_GetPreferredExtensionForMimeType(mime_type, ext)); | |
| 213 return !ext->empty(); | |
| 214 } | |
| 215 | |
| 216 std::string GetDataResource(int resource_id) { | 175 std::string GetDataResource(int resource_id) { |
| 217 return ResourceBundle::GetSharedInstance().GetDataResource(resource_id); | 176 return ResourceBundle::GetSharedInstance().GetDataResource(resource_id); |
| 218 } | 177 } |
| 219 | 178 |
| 220 SkBitmap* GetBitmapResource(int resource_id) { | 179 SkBitmap* GetBitmapResource(int resource_id) { |
| 221 return ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id); | 180 return ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id); |
| 222 } | 181 } |
| 223 | 182 |
| 224 #if defined(OS_WIN) | 183 #if defined(OS_WIN) |
| 225 HCURSOR LoadCursor(int cursor_id) { | 184 HCURSOR LoadCursor(int cursor_id) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // Update the browser about our cache | 315 // Update the browser about our cache |
| 357 // NOTE: Since this can be called from the plugin process, we might not have | 316 // NOTE: Since this can be called from the plugin process, we might not have |
| 358 // a RenderThread. Do nothing in that case. | 317 // a RenderThread. Do nothing in that case. |
| 359 if (!IsPluginProcess()) | 318 if (!IsPluginProcess()) |
| 360 RenderThread::current()->InformHostOfCacheStatsLater(); | 319 RenderThread::current()->InformHostOfCacheStatsLater(); |
| 361 } | 320 } |
| 362 | 321 |
| 363 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE | 322 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE |
| 364 | 323 |
| 365 } // namespace webkit_glue | 324 } // namespace webkit_glue |
| OLD | NEW |