Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: chrome/browser/renderer_host/resource_message_filter.cc

Issue 2846018: Revert "Mac: Infrastructure for serialization of OS fonts over IPC." (Closed)
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/font_loader_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/renderer_host/resource_message_filter.h" 5 #include "chrome/browser/renderer_host/resource_message_filter.h"
6 6
7 #include "app/clipboard/clipboard.h" 7 #include "app/clipboard/clipboard.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #if defined(OS_POSIX) 10 #if defined(OS_POSIX)
11 #include "base/file_descriptor_posix.h" 11 #include "base/file_descriptor_posix.h"
12 #endif 12 #endif
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/histogram.h" 14 #include "base/histogram.h"
15 #include "base/process_util.h" 15 #include "base/process_util.h"
16 #include "base/thread.h" 16 #include "base/thread.h"
17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/appcache/appcache_dispatcher_host.h" 17 #include "chrome/browser/appcache/appcache_dispatcher_host.h"
19 #include "chrome/browser/browser_about_handler.h" 18 #include "chrome/browser/browser_about_handler.h"
20 #include "chrome/browser/child_process_security_policy.h" 19 #include "chrome/browser/child_process_security_policy.h"
21 #include "chrome/browser/chrome_plugin_browsing_context.h" 20 #include "chrome/browser/chrome_plugin_browsing_context.h"
22 #include "chrome/browser/chrome_thread.h" 21 #include "chrome/browser/chrome_thread.h"
23 #include "chrome/browser/download/download_file.h" 22 #include "chrome/browser/download/download_file.h"
24 #include "chrome/browser/extensions/extension_message_service.h" 23 #include "chrome/browser/extensions/extension_message_service.h"
25 #include "chrome/browser/geolocation/geolocation_permission_context.h" 24 #include "chrome/browser/geolocation/geolocation_permission_context.h"
26 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" 25 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h"
27 #include "chrome/browser/gpu_process_host.h" 26 #include "chrome/browser/gpu_process_host.h"
(...skipping 21 matching lines...) Expand all
49 #include "chrome/browser/spellchecker_platform_engine.h" 48 #include "chrome/browser/spellchecker_platform_engine.h"
50 #include "chrome/browser/task_manager.h" 49 #include "chrome/browser/task_manager.h"
51 #include "chrome/browser/worker_host/message_port_dispatcher.h" 50 #include "chrome/browser/worker_host/message_port_dispatcher.h"
52 #include "chrome/browser/worker_host/worker_service.h" 51 #include "chrome/browser/worker_host/worker_service.h"
53 #include "chrome/common/chrome_plugin_lib.h" 52 #include "chrome/common/chrome_plugin_lib.h"
54 #include "chrome/common/chrome_plugin_util.h" 53 #include "chrome/common/chrome_plugin_util.h"
55 #include "chrome/common/chrome_switches.h" 54 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/extensions/extension_constants.h" 55 #include "chrome/common/extensions/extension_constants.h"
57 #include "chrome/common/extensions/extension_file_util.h" 56 #include "chrome/common/extensions/extension_file_util.h"
58 #include "chrome/common/extensions/extension_message_bundle.h" 57 #include "chrome/common/extensions/extension_message_bundle.h"
59 #if defined(OS_MACOSX)
60 #include "chrome/common/font_descriptor_mac.h"
61 #include "chrome/common/font_loader_mac.h"
62 #endif
63 #include "chrome/common/notification_service.h" 58 #include "chrome/common/notification_service.h"
64 #include "chrome/common/pref_names.h" 59 #include "chrome/common/pref_names.h"
65 #include "chrome/common/render_messages.h" 60 #include "chrome/common/render_messages.h"
66 #include "chrome/common/url_constants.h" 61 #include "chrome/common/url_constants.h"
67 #include "chrome/common/worker_messages.h" 62 #include "chrome/common/worker_messages.h"
68 #include "gfx/native_widget_types.h" 63 #include "gfx/native_widget_types.h"
69 #include "net/base/cookie_monster.h" 64 #include "net/base/cookie_monster.h"
70 #include "net/base/file_stream.h" 65 #include "net/base/file_stream.h"
71 #include "net/base/keygen_handler.h" 66 #include "net/base/keygen_handler.h"
72 #include "net/base/load_flags.h" 67 #include "net/base/load_flags.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 #endif 466 #endif
472 467
473 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow) 468 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow)
474 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) 469 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget)
475 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) 470 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
476 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) 471 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
477 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, 472 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies,
478 OnGetRawCookies) 473 OnGetRawCookies)
479 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) 474 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie)
480 IPC_MESSAGE_HANDLER(ViewHostMsg_GetCookiesEnabled, OnGetCookiesEnabled) 475 IPC_MESSAGE_HANDLER(ViewHostMsg_GetCookiesEnabled, OnGetCookiesEnabled)
481 #if defined(OS_MACOSX)
482 IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont)
483 #endif
484 #if defined(OS_WIN) // This hack is Windows-specific. 476 #if defined(OS_WIN) // This hack is Windows-specific.
485 IPC_MESSAGE_HANDLER(ViewHostMsg_PreCacheFont, OnPreCacheFont) 477 IPC_MESSAGE_HANDLER(ViewHostMsg_PreCacheFont, OnPreCacheFont)
486 #endif 478 #endif
487 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) 479 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins)
488 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath) 480 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath)
489 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) 481 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
490 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ContextMenu, 482 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ContextMenu,
491 OnReceiveContextMenuMsg(msg)) 483 OnReceiveContextMenuMsg(msg))
492 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin, 484 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin,
493 OnOpenChannelToPlugin) 485 OnOpenChannelToPlugin)
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 context->cookie_store()->DeleteCookie(url, cookie_name); 746 context->cookie_store()->DeleteCookie(url, cookie_name);
755 } 747 }
756 748
757 void ResourceMessageFilter::OnGetCookiesEnabled( 749 void ResourceMessageFilter::OnGetCookiesEnabled(
758 const GURL& url, 750 const GURL& url,
759 const GURL& first_party_for_cookies, 751 const GURL& first_party_for_cookies,
760 bool* enabled) { 752 bool* enabled) {
761 *enabled = GetRequestContextForURL(url)->AreCookiesEnabled(); 753 *enabled = GetRequestContextForURL(url)->AreCookiesEnabled();
762 } 754 }
763 755
764 #if defined(OS_MACOSX)
765 void ResourceMessageFilter::OnLoadFont(const FontDescriptor& font,
766 uint32* handle_size,
767 base::SharedMemoryHandle* handle) {
768 base::SharedMemory font_data;
769 uint32 font_data_size = 0;
770 bool ok = FontLoader::LoadFontIntoBuffer(font.nsFont(), &font_data,
771 &font_data_size);
772 if (!ok || font_data_size == 0) {
773 LOG(ERROR) << "Couldn't load font data for " << font.font_name <<
774 " ok=" << ok << " font_data_size=" << font_data_size;
775 *handle_size = 0;
776 *handle = base::SharedMemory::NULLHandle();
777 return;
778 }
779
780 *handle_size = font_data_size;
781 font_data.GiveToProcess(base::GetCurrentProcessHandle(), handle);
782 }
783 #endif // OS_MACOSX
784
785 #if defined(OS_WIN) // This hack is Windows-specific. 756 #if defined(OS_WIN) // This hack is Windows-specific.
786 void ResourceMessageFilter::OnPreCacheFont(LOGFONT font) { 757 void ResourceMessageFilter::OnPreCacheFont(LOGFONT font) {
787 // If the renderer is running in a sandbox, GetTextMetrics() 758 // If the renderer is running in a sandbox, GetTextMetrics()
788 // can sometimes fail. If a font has not been loaded 759 // can sometimes fail. If a font has not been loaded
789 // previously, GetTextMetrics() will try to load the font 760 // previously, GetTextMetrics() will try to load the font
790 // from the font file. However, the sandboxed renderer does 761 // from the font file. However, the sandboxed renderer does
791 // not have permissions to access any font files and 762 // not have permissions to access any font files and
792 // the call fails. So we make the browser pre-load the 763 // the call fails. So we make the browser pre-load the
793 // font for us by using a dummy call to GetTextMetrics of 764 // font for us by using a dummy call to GetTextMetrics of
794 // the same font. 765 // the same font.
(...skipping 22 matching lines...) Expand all
817 if (fonts[font_index] || hdcs[font_index]) { 788 if (fonts[font_index] || hdcs[font_index]) {
818 // We already have too many fonts, we will delete one and take it's place. 789 // We already have too many fonts, we will delete one and take it's place.
819 DeleteObject(fonts[font_index]); 790 DeleteObject(fonts[font_index]);
820 ReleaseDC(NULL, hdcs[font_index]); 791 ReleaseDC(NULL, hdcs[font_index]);
821 } 792 }
822 793
823 fonts[font_index] = font_handle; 794 fonts[font_index] = font_handle;
824 hdcs[font_index] = hdc; 795 hdcs[font_index] = hdc;
825 font_index = (font_index + 1) % kFontCacheSize; 796 font_index = (font_index + 1) % kFontCacheSize;
826 } 797 }
827 #endif // OS_WIN 798 #endif
828 799
829 void ResourceMessageFilter::OnGetPlugins(bool refresh, 800 void ResourceMessageFilter::OnGetPlugins(bool refresh,
830 IPC::Message* reply_msg) { 801 IPC::Message* reply_msg) {
831 ChromeThread::PostTask( 802 ChromeThread::PostTask(
832 ChromeThread::FILE, FROM_HERE, 803 ChromeThread::FILE, FROM_HERE,
833 NewRunnableMethod( 804 NewRunnableMethod(
834 this, &ResourceMessageFilter::OnGetPluginsOnFileThread, refresh, 805 this, &ResourceMessageFilter::OnGetPluginsOnFileThread, refresh,
835 reply_msg)); 806 reply_msg));
836 } 807 }
837 808
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 dictionary_map.insert( 1630 dictionary_map.insert(
1660 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); 1631 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id));
1661 1632
1662 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams( 1633 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams(
1663 reply_msg, dictionary_map); 1634 reply_msg, dictionary_map);
1664 1635
1665 ChromeThread::PostTask( 1636 ChromeThread::PostTask(
1666 ChromeThread::IO, FROM_HERE, 1637 ChromeThread::IO, FROM_HERE,
1667 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); 1638 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg));
1668 } 1639 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/font_loader_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698