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

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moves whitelist to a new file, adds new OWNERS reviewers for that file. Also fixes ordering of met… Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/utility/chrome_content_utility_client.h" 5 #include "chrome/utility/chrome_content_utility_client.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/common/chrome_utility_messages.h" 16 #include "chrome/common/chrome_utility_messages.h"
17 #include "chrome/common/extensions/chrome_extensions_client.h" 17 #include "chrome/common/extensions/chrome_extensions_client.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_l10n_util.h" 19 #include "chrome/common/extensions/extension_l10n_util.h"
20 #include "chrome/common/extensions/update_manifest.h" 20 #include "chrome/common/extensions/update_manifest.h"
21 #include "chrome/common/safe_browsing/zip_analyzer.h" 21 #include "chrome/common/safe_browsing/zip_analyzer.h"
22 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
22 #include "chrome/utility/extensions/unpacker.h" 23 #include "chrome/utility/extensions/unpacker.h"
23 #include "chrome/utility/profile_import_handler.h" 24 #include "chrome/utility/profile_import_handler.h"
24 #include "chrome/utility/web_resource_unpacker.h" 25 #include "chrome/utility/web_resource_unpacker.h"
25 #include "content/public/child/image_decoder_utils.h" 26 #include "content/public/child/image_decoder_utils.h"
26 #include "content/public/common/content_paths.h" 27 #include "content/public/common/content_paths.h"
27 #include "content/public/utility/utility_thread.h" 28 #include "content/public/utility/utility_thread.h"
28 #include "extensions/common/manifest.h" 29 #include "extensions/common/manifest.h"
29 #include "media/base/media.h" 30 #include "media/base/media.h"
30 #include "media/base/media_file_checker.h" 31 #include "media/base/media_file_checker.h"
31 #include "printing/page_range.h" 32 #include "printing/page_range.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bool Send(IPC::Message* message) { 71 bool Send(IPC::Message* message) {
71 return content::UtilityThread::Get()->Send(message); 72 return content::UtilityThread::Get()->Send(message);
72 } 73 }
73 74
74 void ReleaseProcessIfNeeded() { 75 void ReleaseProcessIfNeeded() {
75 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 76 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
76 } 77 }
77 78
78 } // namespace 79 } // namespace
79 80
80 ChromeContentUtilityClient::ChromeContentUtilityClient() { 81 ChromeContentUtilityClient::ChromeContentUtilityClient()
82 : filter_messages_(false) {
81 #if !defined(OS_ANDROID) 83 #if !defined(OS_ANDROID)
82 handlers_.push_back(new ProfileImportHandler()); 84 handlers_.push_back(new ProfileImportHandler());
83 #endif // OS_ANDROID 85 #endif // OS_ANDROID
84 86
85 #if defined(ENABLE_MDNS) 87 #if defined(ENABLE_MDNS)
86 if (CommandLine::ForCurrentProcess()->HasSwitch( 88 if (CommandLine::ForCurrentProcess()->HasSwitch(
87 switches::kUtilityProcessEnableMDns)) { 89 switches::kUtilityProcessEnableMDns)) {
88 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); 90 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler());
89 } 91 }
90 #endif // ENABLE_MDNS 92 #endif // ENABLE_MDNS
(...skipping 11 matching lines...) Expand all
102 base::PathExists(pdf)) { 104 base::PathExists(pdf)) {
103 bool rv = !!LoadLibrary(pdf.value().c_str()); 105 bool rv = !!LoadLibrary(pdf.value().c_str());
104 DCHECK(rv) << "Couldn't load PDF plugin"; 106 DCHECK(rv) << "Couldn't load PDF plugin";
105 } 107 }
106 #endif 108 #endif
107 109
108 CommandLine* command_line = CommandLine::ForCurrentProcess(); 110 CommandLine* command_line = CommandLine::ForCurrentProcess();
109 std::string lang = command_line->GetSwitchValueASCII(switches::kLang); 111 std::string lang = command_line->GetSwitchValueASCII(switches::kLang);
110 if (!lang.empty()) 112 if (!lang.empty())
111 extension_l10n_util::SetProcessLocale(lang); 113 extension_l10n_util::SetProcessLocale(lang);
114
115 if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) {
116 DVLOG(0) << "Utility process is running elevated, restricting messages.";
Nico 2014/02/05 05:38:11 Do you need this logging statement? (likely not, c
Drew Haven 2014/02/05 20:13:22 Done.
117 for (size_t i = 0; i < kMessageWhitelistSize; i++) {
118 message_id_whitelist_.insert(kMessageWhitelist[i]);
119 }
Nico 2014/02/05 05:38:11 message_id_whitelist_.insert(kMessageWhitelist, kM
Drew Haven 2014/02/05 20:13:22 Done.
120 filter_messages_ = true;
121 }
112 } 122 }
113 123
114 bool ChromeContentUtilityClient::OnMessageReceived( 124 bool ChromeContentUtilityClient::OnMessageReceived(
115 const IPC::Message& message) { 125 const IPC::Message& message) {
126 if (filter_messages_
127 && message_id_whitelist_.find(message.type())
Nico 2014/02/05 05:38:11 && goes at the end of the line, not at the start.
Drew Haven 2014/02/05 20:13:22 Oh, I didn't know about `git cl format`. Thanks.
128 == message_id_whitelist_.end()) {
129 DVLOG(0) << "Message rejected, not in whitelist: "
130 << message.type();
Nico 2014/02/05 05:38:11 remove logging
Drew Haven 2014/02/05 20:13:22 Done.
131 return false;
132 }
133
116 bool handled = true; 134 bool handled = true;
117 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) 135 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message)
118 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) 136 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension)
119 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource, 137 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource,
120 OnUnpackWebResource) 138 OnUnpackWebResource)
121 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest, 139 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest,
122 OnParseUpdateManifest) 140 OnParseUpdateManifest)
123 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) 141 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage)
124 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) 142 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
125 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile, 143 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile,
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 picasa::PicasaAlbumsIndexer indexer(album_uids); 620 picasa::PicasaAlbumsIndexer indexer(album_uids);
603 indexer.ParseFolderINI(folders_inis); 621 indexer.ParseFolderINI(folders_inis);
604 622
605 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 623 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
606 indexer.albums_images())); 624 indexer.albums_images()));
607 ReleaseProcessIfNeeded(); 625 ReleaseProcessIfNeeded();
608 } 626 }
609 #endif // defined(OS_WIN) || defined(OS_MACOSX) 627 #endif // defined(OS_WIN) || defined(OS_MACOSX)
610 628
611 } // namespace chrome 629 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698