summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj8
-rw-r--r--chrome/renderer/render_thread.cc59
-rw-r--r--chrome/renderer/render_thread.h26
-rw-r--r--chrome/renderer/renderer.scons2
-rw-r--r--chrome/renderer/renderer.vcproj8
-rw-r--r--chrome/renderer/renderer_glue.cc41
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc57
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h30
8 files changed, 145 insertions, 86 deletions
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index 07d3200..e1121d5 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -318,6 +318,7 @@
8F51B73AAAF1772ECF9BD180 /* url_fetcher.cc in Sources */ = {isa = PBXBuildFile; fileRef = 778D7927798B7E3FAA498D3D /* url_fetcher.cc */; };
9084D27A4F8690E6FD31083B /* session_backend.cc in Sources */ = {isa = PBXBuildFile; fileRef = 35AC9D9A03545594C102C5C1 /* session_backend.cc */; };
928300674E414B42615BA4F0 /* download_manager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF9CE0E9D48CE009A6919 /* download_manager.cc */; };
+ 938D10370F57401C009F1128 /* renderer_webkitclient_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 938D10350F57401C009F1128 /* renderer_webkitclient_impl.cc */; };
93FB3ECE0F55E38400AA1185 /* libwebkit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4BD53D90F54AB4300591DFA /* libwebkit.a */; };
93FB3ED10F55E38900AA1185 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45065DD0EEEC6FF003BE099 /* AppKit.framework */; };
93FB3ED20F55E38900AA1185 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4DCDB9C0F4091BF0084059A /* ApplicationServices.framework */; };
@@ -2594,6 +2595,8 @@
844EA0820F3E0C1000B0EF26 /* debugger_wrapper.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = debugger_wrapper.cc; path = debugger/debugger_wrapper.cc; sourceTree = "<group>"; };
844EA0830F3E0C1000B0EF26 /* debugger_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = debugger_wrapper.h; path = debugger/debugger_wrapper.h; sourceTree = "<group>"; };
90BF0D1189BB7158BD7F1600 /* bookmark_context_menu.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_context_menu.cc; path = browser/bookmarks/bookmark_context_menu.cc; sourceTree = SOURCE_ROOT; };
+ 938D10350F57401C009F1128 /* renderer_webkitclient_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = renderer_webkitclient_impl.cc; sourceTree = "<group>"; };
+ 938D10360F57401C009F1128 /* renderer_webkitclient_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = renderer_webkitclient_impl.h; sourceTree = "<group>"; };
A2FC5EE73E0DE8BF6C1C4C0F /* bookmark_utils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_utils.cc; path = browser/bookmarks/bookmark_utils.cc; sourceTree = SOURCE_ROOT; };
A54612D90EE9957000A8EE5D /* extensions_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extensions_service.cc; sourceTree = "<group>"; };
A54612DA0EE9957000A8EE5D /* extensions_service.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extensions_service.h; sourceTree = "<group>"; };
@@ -3262,7 +3265,6 @@
4D640CCF0EAE868600EBCFC0 /* render_process.cc */,
4D640CD00EAE868600EBCFC0 /* render_process.h */,
3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */,
- F4143C8B0F4B1D07008C8F73 /* renderer.sb */,
4D640CD10EAE868600EBCFC0 /* render_thread.cc */,
4D640CD20EAE868600EBCFC0 /* render_thread.h */,
3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */,
@@ -3272,6 +3274,7 @@
4D640CD50EAE868600EBCFC0 /* render_widget.cc */,
4D640CD60EAE868600EBCFC0 /* render_widget.h */,
4D640CD70EAE868600EBCFC0 /* render_widget_unittest.cc */,
+ F4143C8B0F4B1D07008C8F73 /* renderer.sb */,
4D640CD80EAE868600EBCFC0 /* renderer_glue.cc */,
AB3B4B290F549D9E0009E2BF /* renderer_histogram_snapshots.cc */,
AB3B4B2A0F549D9E0009E2BF /* renderer_histogram_snapshots.h */,
@@ -3281,6 +3284,8 @@
B51F6D120F37C4DC00152D66 /* renderer_main_platform_delegate_win.cc */,
B5D030EF0F3A3C43001238AB /* renderer_main_unittest.cc */,
4D640CDA0EAE868600EBCFC0 /* renderer_resources.h */,
+ 938D10350F57401C009F1128 /* renderer_webkitclient_impl.cc */,
+ 938D10360F57401C009F1128 /* renderer_webkitclient_impl.h */,
4D640CC90EAE868600EBCFC0 /* user_script_slave.cc */,
4D640CCA0EAE868600EBCFC0 /* user_script_slave.h */,
4D640CDC0EAE868600EBCFC0 /* visitedlink_slave.cc */,
@@ -5680,6 +5685,7 @@
B503E0F00F0175FD00547DC6 /* user_script_slave.cc in Sources */,
AB8963020F4E090D009CFFAC /* video_renderer_impl.cc in Sources */,
4D640CF50EAE86EF00EBCFC0 /* visitedlink_slave.cc in Sources */,
+ 938D10370F57401C009F1128 /* renderer_webkitclient_impl.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index dacbd8a..fb8082b 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -29,10 +29,10 @@
#include "chrome/renderer/net/render_dns_master.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_view.h"
+#include "chrome/renderer/renderer_webkitclient_impl.h"
#include "chrome/renderer/user_script_slave.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "webkit/glue/cache_manager.h"
-#include "webkit/glue/webkit_client_impl.h"
#include "WebKit.h"
@@ -49,20 +49,13 @@ static const size_t kStackSize = 1024 * 1024;
RenderThread::RenderThread()
: ChildThread(
base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)),
- visited_link_slave_(NULL),
- user_script_slave_(NULL),
- render_dns_master_(NULL) {
+ MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)) {
}
RenderThread::RenderThread(const std::wstring& channel_name)
: ChildThread(
base::Thread::Options(RenderProcess::InProcessPlugins() ?
- MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)),
- visited_link_slave_(NULL),
- user_script_slave_(NULL),
- render_dns_master_(NULL),
- renderer_histogram_snapshots_(NULL) {
+ MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT, kStackSize)) {
SetChannelName(channel_name);
}
@@ -83,50 +76,54 @@ void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
}
void RenderThread::Resolve(const char* name, size_t length) {
- return render_dns_master_->Resolve(name, length);
+ return dns_master_->Resolve(name, length);
}
void RenderThread::SendHistograms() {
- return renderer_histogram_snapshots_->SendHistograms();
+ return histogram_snapshots_->SendHistograms();
}
void RenderThread::Init() {
- ChildThread::Init();
- notification_service_.reset(new NotificationService);
- cache_stats_factory_.reset(
- new ScopedRunnableMethodFactory<RenderThread>(this));
-
+ // TODO(darin): Why do we need COM here? This is probably bogus.
#if defined(OS_WIN)
// The renderer thread should wind-up COM.
CoInitialize(0);
#endif
- webkit_client_impl_.reset(new webkit_glue::WebKitClientImpl);
+ ChildThread::Init();
+ notification_service_.reset(new NotificationService);
+ cache_stats_factory_.reset(
+ new ScopedRunnableMethodFactory<RenderThread>(this));
+
+ webkit_client_impl_.reset(new RendererWebKitClientImpl);
WebKit::initialize(webkit_client_impl_.get());
- visited_link_slave_ = new VisitedLinkSlave();
- user_script_slave_ = new UserScriptSlave();
- render_dns_master_.reset(new RenderDnsMaster());
- renderer_histogram_snapshots_.reset(new RendererHistogramSnapshots());
+ visited_link_slave_.reset(new VisitedLinkSlave());
+ user_script_slave_.reset(new UserScriptSlave());
+ dns_master_.reset(new RenderDnsMaster());
+ histogram_snapshots_.reset(new RendererHistogramSnapshots());
}
void RenderThread::CleanUp() {
+ // Shutdown in reverse of the initialization order.
+
+ histogram_snapshots_.reset();
+ dns_master_.reset();
+ user_script_slave_.reset();
+ visited_link_slave_.reset();
+
+ WebKit::shutdown();
+
+ notification_service_.reset();
+
ChildThread::CleanUp();
-// TODO(port)
+ // TODO(port)
#if defined(OS_WIN)
// Clean up plugin channels before this thread goes away.
PluginChannelBase::CleanupChannels();
#endif
- notification_service_.reset();
-
- delete visited_link_slave_;
- visited_link_slave_ = NULL;
-
- delete user_script_slave_;
- user_script_slave_ = NULL;
-
#if defined(OS_WIN)
CoUninitialize();
#endif
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index cfc3d9a..8f41cce 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -18,16 +18,13 @@ class FilePath;
class NotificationService;
class RenderDnsMaster;
class RendererHistogram;
+class RendererWebKitClientImpl;
class SkBitmap;
class UserScriptSlave;
class VisitedLinkSlave;
struct ModalDialogEvent;
struct WebPreferences;
-namespace webkit_glue {
-class WebKitClientImpl;
-}
-
// The RenderThreadBase is the minimal interface that a RenderView/Widget
// expects from a render thread. The interface basically abstracts a way to send
// and receive messages.
@@ -83,11 +80,13 @@ class RenderThread : public RenderThreadBase,
virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter);
- // Gets the VisitedLinkSlave instance for this thread
- VisitedLinkSlave* visited_link_slave() const { return visited_link_slave_; }
+ VisitedLinkSlave* visited_link_slave() const {
+ return visited_link_slave_.get();
+ }
- // Gets the UserScriptSlave instance for this thread
- UserScriptSlave* user_script_slave() const { return user_script_slave_; }
+ UserScriptSlave* user_script_slave() const {
+ return user_script_slave_.get();
+ }
// Do DNS prefetch resolution of a hostname.
void Resolve(const char* name, size_t length);
@@ -131,18 +130,19 @@ class RenderThread : public RenderThreadBase,
void InformHostOfCacheStats();
// These objects live solely on the render thread.
- VisitedLinkSlave* visited_link_slave_;
- UserScriptSlave* user_script_slave_;
+ scoped_ptr<VisitedLinkSlave> visited_link_slave_;
+
+ scoped_ptr<UserScriptSlave> user_script_slave_;
- scoped_ptr<RenderDnsMaster> render_dns_master_;
+ scoped_ptr<RenderDnsMaster> dns_master_;
- scoped_ptr<RendererHistogramSnapshots> renderer_histogram_snapshots_;
+ scoped_ptr<RendererHistogramSnapshots> histogram_snapshots_;
scoped_ptr<ScopedRunnableMethodFactory<RenderThread> > cache_stats_factory_;
scoped_ptr<NotificationService> notification_service_;
- scoped_ptr<webkit_glue::WebKitClientImpl> webkit_client_impl_;
+ scoped_ptr<RendererWebKitClientImpl> webkit_client_impl_;
DISALLOW_COPY_AND_ASSIGN(RenderThread);
};
diff --git a/chrome/renderer/renderer.scons b/chrome/renderer/renderer.scons
index 85bfde1..e280cb8 100644
--- a/chrome/renderer/renderer.scons
+++ b/chrome/renderer/renderer.scons
@@ -95,6 +95,8 @@ input_files = ChromeFileList([
'renderer_glue.cc',
'renderer_histogram_snapshots.cc',
'renderer_histogram_snapshots.h',
+ 'renderer_webkitclient_impl.cc',
+ 'renderer_webkitclient_impl.h',
'renderer_main.cc',
'renderer_resources.h',
'user_script_slave.cc',
diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj
index 8e81aac..4879a93 100644
--- a/chrome/renderer/renderer.vcproj
+++ b/chrome/renderer/renderer.vcproj
@@ -342,6 +342,14 @@
>
</File>
<File
+ RelativePath=".\renderer_webkitclient_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\renderer_webkitclient_impl.h"
+ >
+ </File>
+ <File
RelativePath=".\user_script_slave.cc"
>
</File>
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 055f342..1058698 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -24,8 +24,6 @@
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "googleurl/src/url_util.h"
-#include "net/base/mime_util.h"
-#include "net/base/net_errors.h"
#include "webkit/glue/scoped_clipboard_writer_glue.h"
#include "webkit/glue/webframe.h"
#include "webkit/glue/webkit_glue.h"
@@ -174,45 +172,6 @@ void AppendToLog(const char* file, int line, const char* msg) {
logging::LogMessage(file, line).stream() << msg;
}
-bool GetMimeTypeFromExtension(const FilePath::StringType &ext,
- std::string *mime_type) {
- if (IsPluginProcess())
- return net::GetMimeTypeFromExtension(ext, mime_type);
-
- // The sandbox restricts our access to the registry, so we need to proxy
- // these calls over to the browser process.
- DCHECK(mime_type->empty());
- RenderThread::current()->Send(
- new ViewHostMsg_GetMimeTypeFromExtension(ext, mime_type));
- return !mime_type->empty();
-}
-
-bool GetMimeTypeFromFile(const FilePath &file_path,
- std::string *mime_type) {
- if (IsPluginProcess())
- return net::GetMimeTypeFromFile(file_path, mime_type);
-
- // The sandbox restricts our access to the registry, so we need to proxy
- // these calls over to the browser process.
- DCHECK(mime_type->empty());
- RenderThread::current()->Send(
- new ViewHostMsg_GetMimeTypeFromFile(file_path, mime_type));
- return !mime_type->empty();
-}
-
-bool GetPreferredExtensionForMimeType(const std::string& mime_type,
- FilePath::StringType* ext) {
- if (IsPluginProcess())
- return net::GetPreferredExtensionForMimeType(mime_type, ext);
-
- // The sandbox restricts our access to the registry, so we need to proxy
- // these calls over to the browser process.
- DCHECK(ext->empty());
- RenderThread::current()->Send(
- new ViewHostMsg_GetPreferredExtensionForMimeType(mime_type, ext));
- return !ext->empty();
-}
-
std::string GetDataResource(int resource_id) {
return ResourceBundle::GetSharedInstance().GetDataResource(resource_id);
}
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
new file mode 100644
index 0000000..b33d12e
--- /dev/null
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "chrome/renderer/renderer_webkitclient_impl.h"
+
+#include "WebString.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/plugin/npobject_util.h"
+#include "chrome/renderer/render_thread.h"
+#include "webkit/glue/glue_util.h"
+
+using WebKit::WebString;
+
+WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension(
+ const WebString& file_extension) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ std::string mime_type;
+ RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromExtension(
+ webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
+ return ASCIIToUTF16(mime_type);
+
+}
+
+WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile(
+ const WebString& file_path) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ std::string mime_type;
+ RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromFile(
+ FilePath(webkit_glue::WebStringToFilePathString(file_path)),
+ &mime_type));
+ return ASCIIToUTF16(mime_type);
+
+}
+
+WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType(
+ const WebString& mime_type) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ FilePath::StringType file_extension;
+ RenderThread::current()->Send(
+ new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type),
+ &file_extension));
+ return webkit_glue::FilePathStringToWebString(file_extension);
+}
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
new file mode 100644
index 0000000..2e85234
--- /dev/null
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef CHROME_RENDERER_RENDERER_WEBKIT_CLIENT_IMPL_H_
+#define CHROME_RENDERER_RENDERER_WEBKIT_CLIENT_IMPL_H_
+
+#include "webkit/glue/simple_webmimeregistry_impl.h"
+#include "webkit/glue/webkitclient_impl.h"
+
+class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
+ public:
+ // WebKitClient methods:
+ virtual WebKit::WebMimeRegistry* mimeRegistry() {
+ return &mime_registry_;
+ }
+
+ private:
+ class MimeRegistry : public webkit_glue::SimpleWebMimeRegistryImpl {
+ public:
+ virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&);
+ virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&);
+ virtual WebKit::WebString preferredExtensionForMIMEType(
+ const WebKit::WebString&);
+ };
+
+ MimeRegistry mime_registry_;
+};
+
+#endif // CHROME_RENDERER_WEBKIT_CLIENT_IMPL_H_