| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/extensions_handler.h" | 5 #include "chrome/utility/extensions/extensions_handler.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
| 10 #include "chrome/common/extensions/chrome_extensions_client.h" | 10 #include "chrome/common/extensions/chrome_extensions_client.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // static | 79 // static |
| 80 void ExtensionsHandler::UtilityThreadStarted() { | 80 void ExtensionsHandler::UtilityThreadStarted() { |
| 81 UtilityHandler::UtilityThreadStarted(); | 81 UtilityHandler::UtilityThreadStarted(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { | 84 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { |
| 85 bool handled = true; | 85 bool handled = true; |
| 86 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) | 86 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) |
| 87 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) | 87 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) |
| 88 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) | 88 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) |
| 89 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) | |
| 90 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) | 89 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) |
| 91 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
| 92 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, | 91 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, |
| 93 OnParseITunesPrefXml) | 92 OnParseITunesPrefXml) |
| 94 #endif // defined(OS_WIN) | 93 #endif // defined(OS_WIN) |
| 95 | 94 |
| 96 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
| 97 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile, | 96 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile, |
| 98 OnParseIPhotoLibraryXmlFile) | 97 OnParseIPhotoLibraryXmlFile) |
| 99 #endif // defined(OS_MACOSX) | 98 #endif // defined(OS_MACOSX) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 if (!zip::Unzip(zip_path, dir)) { | 145 if (!zip::Unzip(zip_path, dir)) { |
| 147 Send(new ChromeUtilityHostMsg_UnzipToDir_Failed( | 146 Send(new ChromeUtilityHostMsg_UnzipToDir_Failed( |
| 148 std::string(kExtensionHandlerUnzipError))); | 147 std::string(kExtensionHandlerUnzipError))); |
| 149 } else { | 148 } else { |
| 150 Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(dir)); | 149 Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(dir)); |
| 151 } | 150 } |
| 152 | 151 |
| 153 ReleaseProcessIfNeeded(); | 152 ReleaseProcessIfNeeded(); |
| 154 } | 153 } |
| 155 | 154 |
| 156 void ExtensionsHandler::OnDecodeImageBase64( | |
| 157 const std::string& encoded_string) { | |
| 158 std::string decoded_string; | |
| 159 | |
| 160 if (!base::Base64Decode(encoded_string, &decoded_string)) { | |
| 161 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); | |
| 162 return; | |
| 163 } | |
| 164 | |
| 165 std::vector<unsigned char> decoded_vector(decoded_string.size()); | |
| 166 for (size_t i = 0; i < decoded_string.size(); ++i) { | |
| 167 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]); | |
| 168 } | |
| 169 | |
| 170 ChromeContentUtilityClient::DecodeImageAndSend(decoded_vector, false); | |
| 171 } | |
| 172 | |
| 173 void ExtensionsHandler::OnCheckMediaFile( | 155 void ExtensionsHandler::OnCheckMediaFile( |
| 174 int64 milliseconds_of_decoding, | 156 int64 milliseconds_of_decoding, |
| 175 const IPC::PlatformFileForTransit& media_file) { | 157 const IPC::PlatformFileForTransit& media_file) { |
| 176 media::MediaFileChecker checker( | 158 media::MediaFileChecker checker( |
| 177 IPC::PlatformFileForTransitToFile(media_file)); | 159 IPC::PlatformFileForTransitToFile(media_file)); |
| 178 const bool check_success = checker.Start( | 160 const bool check_success = checker.Start( |
| 179 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); | 161 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); |
| 180 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); | 162 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); |
| 181 ReleaseProcessIfNeeded(); | 163 ReleaseProcessIfNeeded(); |
| 182 } | 164 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 238 |
| 257 std::string key_data; | 239 std::string key_data; |
| 258 std::string error; | 240 std::string error; |
| 259 wifi_service->GetKeyFromSystem(network_guid, &key_data, &error); | 241 wifi_service->GetKeyFromSystem(network_guid, &key_data, &error); |
| 260 | 242 |
| 261 Send(new ChromeUtilityHostMsg_GotWiFiCredentials(key_data, error.empty())); | 243 Send(new ChromeUtilityHostMsg_GotWiFiCredentials(key_data, error.empty())); |
| 262 } | 244 } |
| 263 #endif // defined(OS_WIN) | 245 #endif // defined(OS_WIN) |
| 264 | 246 |
| 265 } // namespace extensions | 247 } // namespace extensions |
| OLD | NEW |