diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 00:19:17 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-06 00:19:17 +0000 |
commit | 5986ed239f7f2fc3f6b1d5f6385819151ae533db (patch) | |
tree | a07be3bc493c5dd34c5f62c6195a85c49ec22c2a /chrome | |
parent | 8ad85c0ef39433a26a0093853f34d7eec9be0706 (diff) | |
download | chromium_src-5986ed239f7f2fc3f6b1d5f6385819151ae533db.zip chromium_src-5986ed239f7f2fc3f6b1d5f6385819151ae533db.tar.gz chromium_src-5986ed239f7f2fc3f6b1d5f6385819151ae533db.tar.bz2 |
Make ResourceMessageFilter compile on Mac. It stubs out a substantial part of
the printing. It creates new base functions for converting PIDs to handles, and
then closing them (since Windows requires this). This also fixes the formatting
of image_util.
Review URL: http://codereview.chromium.org/20109
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9291 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 45 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.h | 2 | ||||
-rw-r--r-- | chrome/chrome.xcodeproj/project.pbxproj | 2 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cc | 44 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 68 |
5 files changed, 111 insertions, 50 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 15b3f28..2db7124 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -7,20 +7,16 @@ #include "base/clipboard.h" #include "base/gfx/native_widget_types.h" #include "base/histogram.h" +#include "base/process_util.h" #include "base/thread.h" #include "chrome/browser/chrome_plugin_browsing_context.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/net/dns_global.h" -#include "chrome/browser/printing/print_job_manager.h" -#include "chrome/browser/printing/printer_query.h" #include "chrome/browser/profile.h" -#include "chrome/browser/plugin_service.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/render_widget_helper.h" -#include "chrome/browser/spellchecker.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_plugin_util.h" -#include "chrome/common/clipboard_service.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" @@ -30,6 +26,17 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin.h" +#if defined(OS_WIN) +#include "chrome/browser/plugin_service.h" +#include "chrome/browser/printing/print_job_manager.h" +#include "chrome/browser/printing/printer_query.h" +#include "chrome/browser/spellchecker.h" +#include "chrome/common/clipboard_service.h" +#elif defined(OS_MACOSX) || defined(OS_LINUX) +// TODO(port) remove this. +#include "chrome/common/temp_scaffolding_stubs.h" +#endif + namespace { // Context menus are somewhat complicated. We need to intercept them here on @@ -96,12 +103,12 @@ ResourceMessageFilter::ResourceMessageFilter( plugin_service_(plugin_service), print_job_manager_(print_job_manager), render_process_host_id_(render_process_host_id), + spellchecker_(spellchecker), + ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)), render_handle_(NULL), request_context_(profile->GetRequestContext()), profile_(profile), - render_widget_helper_(render_widget_helper), - spellchecker_(spellchecker), - ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)) { + render_widget_helper_(render_widget_helper) { DCHECK(request_context_.get()); DCHECK(request_context_->cookie_store()); @@ -109,7 +116,7 @@ ResourceMessageFilter::ResourceMessageFilter( ResourceMessageFilter::~ResourceMessageFilter() { if (render_handle_) - CloseHandle(render_handle_); + base::CloseProcessHandle(render_handle_); // This function should be called on the IO thread. DCHECK(MessageLoop::current() == @@ -134,8 +141,7 @@ void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) { // Called on the IPC thread: void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { DCHECK(!render_handle_); - render_handle_ = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, - FALSE, peer_pid); + render_handle_ = base::OpenProcessHandle(peer_pid); DCHECK(render_handle_); } @@ -170,7 +176,9 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_GetDataDir, OnGetDataDir) IPC_MESSAGE_HANDLER(ViewHostMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(ViewHostMsg_PluginSyncMessage, OnPluginSyncMessage) +#if defined(OS_WIN) // This hack is Windows-specific. IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) +#endif IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnGetScreenInfo) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPlugins, OnGetPlugins) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath) @@ -385,6 +393,7 @@ void ResourceMessageFilter::OnPluginSyncMessage(const FilePath& plugin_path, } } +#if defined(OS_WIN) // This hack is Windows-specific. void ResourceMessageFilter::OnLoadFont(LOGFONT font) { // If renderer is running in a sandbox, GetTextMetrics // can sometimes fail. If a font has not been loaded @@ -426,6 +435,7 @@ void ResourceMessageFilter::OnLoadFont(LOGFONT font) { hdcs[font_index] = hdc; font_index = (font_index + 1) % kFontCacheSize; } +#endif void ResourceMessageFilter::OnGetScreenInfo( gfx::NativeViewId window, webkit_glue::ScreenInfo* results) { @@ -476,7 +486,11 @@ void ResourceMessageFilter::OnClipboardWriteObjects( // We pass the render_handle_ to assist the clipboard with using shared // memory objects. render_handle_ is a handle to the process that would // own any shared memory that might be in the object list. +#if defined(OS_WIN) Clipboard::DuplicateRemoteHandles(render_handle_, long_living_objects); +#else + NOTIMPLEMENTED(); // TODO(port) implement this. +#endif render_widget_helper_->ui_loop()->PostTask(FROM_HERE, new WriteClipboardTask(long_living_objects)); @@ -484,8 +498,13 @@ void ResourceMessageFilter::OnClipboardWriteObjects( void ResourceMessageFilter::OnClipboardIsFormatAvailable(unsigned int format, bool* result) { +#if defined(OS_WIN) DCHECK(result); *result = GetClipboardService()->IsFormatAvailable(format); +#else + NOTIMPLEMENTED(); // TODO(port) this function should take a + // Clipboard::FormatType instead of an int. +#endif } void ResourceMessageFilter::OnClipboardReadText(std::wstring* result) { @@ -558,7 +577,7 @@ void ResourceMessageFilter::OnDuplicateSection( // Duplicate the handle in this process right now so the memory is kept alive // (even if it is not mapped) base::SharedMemory shared_buf(renderer_handle, true, render_handle_); - shared_buf.GiveToProcess(GetCurrentProcess(), browser_handle); + shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle); } void ResourceMessageFilter::OnResourceTypeStats( @@ -576,7 +595,7 @@ void ResourceMessageFilter::OnResourceTypeStats( } void ResourceMessageFilter::OnResolveProxy(const GURL& url, - IPC::Message* reply_msg) { + IPC::Message* reply_msg) { resolve_proxy_msg_helper_.Start(url, reply_msg); } diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 6ec697f..c4d75e3 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -115,7 +115,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, const std::wstring& filter, uint32 user_data); -#if defined(OS_WIN) +#if defined(OS_WIN) // This hack is Windows-specific. // Cache fonts for the renderer. See ResourceMessageFilter::OnLoadFont // implementation for more details void OnLoadFont(LOGFONT font); diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 2abc67f..e3041c8 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -244,6 +244,7 @@ A76E43A40F29039C009A7E88 /* browser_render_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = A76E43A30F29039C009A7E88 /* browser_render_process_host.cc */; }; A7A20BF20F3A16DC00F62B4D /* render_widget.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD50EAE868600EBCFC0 /* render_widget.cc */; }; A7A20E650F3A1E1C00F62B4D /* render_view.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD30EAE868600EBCFC0 /* render_view.cc */; }; + A7A214A00F3B91B100F62B4D /* resource_message_filter.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7A211730F3A248300F62B4D /* resource_message_filter.cc */; }; A7C612990F30D63D008CEE5D /* render_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5D16EC10F2144D500861FAC /* render_process_host.cc */; }; A7C613C10F30D7E4008CEE5D /* mock_render_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7C613BF0F30D7E4008CEE5D /* mock_render_process_host.cc */; }; A7C6146F0F30DA1D008CEE5D /* ipc_test_sink.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7C6146D0F30DA1D008CEE5D /* ipc_test_sink.cc */; }; @@ -4643,6 +4644,7 @@ E434BFA40F3A03E200B665C7 /* render_widget_host.cc in Sources */, E434BBEB0F37DFA500B665C7 /* renderer_security_policy.cc in Sources */, BADB8B710F3A35AC00989B26 /* resource_dispatcher_host.cc in Sources */, + A7A214A00F3B91B100F62B4D /* resource_message_filter.cc in Sources */, B0AC9501DED2809AC208AEEA /* resolve_proxy_msg_helper.cc in Sources */, 4D7BFAF30E9D49EF009A6919 /* safe_browsing_database.cc in Sources */, E48FB9590EC4E9C10052B72B /* safe_browsing_database_bloom.cc in Sources */, diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index df04efe..f902539 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -259,7 +259,8 @@ void SetRecordPlaybackMode(bool) { } void SetJavaScriptFlags(const std::wstring&) { } void CheckForLeaks() { } std::string CreateHistoryStateForURL(const GURL& url) { return ""; } -} +void GetScreenInfoHelper(NSView*) { NOTIMPLEMENTED(); } +} // namespace webkit_glue #endif //-------------------------------------------------------------------------- @@ -267,11 +268,18 @@ std::string CreateHistoryStateForURL(const GURL& url) { return ""; } namespace chrome_browser_net { void EnableDnsPrefetch(bool) { NOTIMPLEMENTED(); } + +void DnsPrefetchList(const std::vector<std::string>& hostnames) { NOTIMPLEMENTED(); } } // namespace chrome_browser_net //-------------------------------------------------------------------------- +// This is from chrome_plugin_util.cc. +void CPB_Free(void* memory) { NOTIMPLEMENTED(); } + +//-------------------------------------------------------------------------- + void RunJavascriptMessageBox(WebContents* web_contents, int dialog_flags, const std::wstring& message_text, @@ -303,40 +311,6 @@ void SSLManager::OnSSLCertificateError( //-------------------------------------------------------------------------- -ResourceMessageFilter::ResourceMessageFilter( - ResourceDispatcherHost* resource_dispatcher_host, - PluginService* plugin_service, - printing::PrintJobManager* print_job_manager, - int render_process_host_id, - Profile* profile, - RenderWidgetHelper* render_widget_helper, - SpellChecker* spellchecker) - : ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)) { -} -ResourceMessageFilter::~ResourceMessageFilter() { NOTIMPLEMENTED(); } -void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) { - NOTIMPLEMENTED(); -} -void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { - NOTIMPLEMENTED(); -} -void ResourceMessageFilter::OnChannelClosing() { NOTIMPLEMENTED(); } -bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { - NOTIMPLEMENTED(); - return false; -} -bool ResourceMessageFilter::Send(IPC::Message* message) { - NOTIMPLEMENTED(); - return false; -} -void ResourceMessageFilter::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { } -void ResourceMessageFilter::OnResolveProxyCompleted( - IPC::Message* reply_msg,int result, const std::string& proxy_list) { - NOTIMPLEMENTED(); -} - void RunRepostFormWarningDialog(NavigationController*) { } diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index 8b72a7e..681fdae 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -12,6 +12,7 @@ #include <string> #include "base/basictypes.h" +#include "base/clipboard.h" #include "base/file_path.h" #include "base/logging.h" #include "base/message_loop.h" @@ -62,6 +63,7 @@ class ProfileManager; class Profile; class RenderProcessHost; class RenderWidgetHelper; +class ResourceMessageFilter; class SessionID; class SiteInstance; class SpellChecker; @@ -75,6 +77,7 @@ class URLRequestContext; class UserScriptMaster; class VisitedLinkMaster; class WebContents; +struct WebPluginInfo; struct WebPluginGeometry; class WebPreferences; @@ -290,14 +293,53 @@ GURL NewTabUIURL(); //--------------------------------------------------------------------------- // These stubs are for BrowserProcessImpl -class ClipboardService { +class ClipboardService : public Clipboard { + public: }; +class CancelableTask; +class ViewMsg_Print_Params; + namespace printing { + +class PrintingContext { + public: + enum Result { OK, CANCEL, FAILED }; +}; + +class PrintSettings { + public: + void RenderParams(ViewMsg_Print_Params* params) const { NOTIMPLEMENTED(); } + int dpi() const { NOTIMPLEMENTED(); return 92; } +}; + +class PrinterQuery : public base::RefCountedThreadSafe<PrinterQuery> { + public: + enum GetSettingsAskParam { + DEFAULTS, + ASK_USER, + }; + + void GetSettings(GetSettingsAskParam ask_user_for_settings, + int parent_window, + int expected_page_count, + CancelableTask* callback) { NOTIMPLEMENTED(); } + PrintingContext::Result last_status() { return PrintingContext::FAILED; } + const PrintSettings& settings() { NOTIMPLEMENTED(); return settings_; } + int cookie() { NOTIMPLEMENTED(); return 0; } + void StopWorker() { NOTIMPLEMENTED(); } + + private: + PrintSettings settings_; +}; class PrintJobManager { public: void OnQuit() { NOTIMPLEMENTED(); } + void PopPrinterQuery(int document_cookie, scoped_refptr<PrinterQuery>* job) { + NOTIMPLEMENTED(); + } + void QueuePrinterQuery(PrinterQuery* job) { NOTIMPLEMENTED(); } }; } // namespace printing @@ -831,6 +873,15 @@ class SpellChecker : public base::RefCountedThreadSafe<SpellChecker> { const Language& language, URLRequestContext* request_context, const std::wstring& custom_dictionary_file_name) {} + + bool SpellCheckWord(const wchar_t* in_word, + int in_word_len, + int* misspelling_start, + int* misspelling_len, + std::vector<std::wstring>* optional_suggestions) { + NOTIMPLEMENTED(); + return true; + } }; class WebAppLauncher { @@ -984,6 +1035,21 @@ class PluginService { return true; } void SetChromePluginDataDir(const FilePath& data_dir); + FilePath GetChromePluginDataDir() { return chrome_plugin_data_dir_; } + void GetPlugins(bool reload, std::vector<WebPluginInfo>* plugins) {} + FilePath GetPluginPath(const GURL& url, + const std::string& mime_type, + const std::string& clsid, + std::string* actual_mime_type) { + NOTIMPLEMENTED(); + return FilePath(); + } + void OpenChannelToPlugin(ResourceMessageFilter* renderer_msg_filter, + const GURL& url, + const std::string& mime_type, + const std::string& clsid, + const std::wstring& locale, + IPC::Message* reply_msg) { NOTIMPLEMENTED(); } private: MessageLoop* main_message_loop_; ResourceDispatcherHost* resource_dispatcher_host_; |