Index: chrome/utility/chrome_content_utility_client.cc |
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc |
index b8f83f05c01132a69070929806b3baef7ea0d665..449174d9226b9c0743f8200cfeecd34ba007a472 100644 |
--- a/chrome/utility/chrome_content_utility_client.cc |
+++ b/chrome/utility/chrome_content_utility_client.cc |
@@ -19,6 +19,7 @@ |
#include "chrome/common/extensions/extension_l10n_util.h" |
#include "chrome/common/extensions/update_manifest.h" |
#include "chrome/common/safe_browsing/zip_analyzer.h" |
+#include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
#include "chrome/utility/extensions/unpacker.h" |
#include "chrome/utility/profile_import_handler.h" |
#include "chrome/utility/web_resource_unpacker.h" |
@@ -77,7 +78,8 @@ void ReleaseProcessIfNeeded() { |
} // namespace |
-ChromeContentUtilityClient::ChromeContentUtilityClient() { |
+ChromeContentUtilityClient::ChromeContentUtilityClient() |
+ : filter_messages_(false) { |
#if !defined(OS_ANDROID) |
handlers_.push_back(new ProfileImportHandler()); |
#endif // OS_ANDROID |
@@ -109,10 +111,26 @@ void ChromeContentUtilityClient::UtilityThreadStarted() { |
std::string lang = command_line->GetSwitchValueASCII(switches::kLang); |
if (!lang.empty()) |
extension_l10n_util::SetProcessLocale(lang); |
+ |
+ if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) { |
+ 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.
|
+ for (size_t i = 0; i < kMessageWhitelistSize; i++) { |
+ message_id_whitelist_.insert(kMessageWhitelist[i]); |
+ } |
Nico
2014/02/05 05:38:11
message_id_whitelist_.insert(kMessageWhitelist, kM
Drew Haven
2014/02/05 20:13:22
Done.
|
+ filter_messages_ = true; |
+ } |
} |
bool ChromeContentUtilityClient::OnMessageReceived( |
const IPC::Message& message) { |
+ if (filter_messages_ |
+ && 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.
|
+ == message_id_whitelist_.end()) { |
+ DVLOG(0) << "Message rejected, not in whitelist: " |
+ << message.type(); |
Nico
2014/02/05 05:38:11
remove logging
Drew Haven
2014/02/05 20:13:22
Done.
|
+ return false; |
+ } |
+ |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) |
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) |