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

Side by Side Diff: chrome/utility/extensions/extensions_handler.cc

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a few comments Created 5 years, 9 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/utility/extensions/extensions_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 base::FilePath media_path; 73 base::FilePath media_path;
74 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); 74 PathService::Get(content::DIR_MEDIA_LIBS, &media_path);
75 if (!media_path.empty()) 75 if (!media_path.empty())
76 media::InitializeMediaLibrary(media_path); 76 media::InitializeMediaLibrary(media_path);
77 } 77 }
78 78
79 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { 79 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
80 bool handled = true; 80 bool handled = true;
81 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) 81 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
82 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) 82 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir)
83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
84 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) 83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
85 #if defined(OS_WIN) 84 #if defined(OS_WIN)
86 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 85 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
87 OnParseITunesPrefXml) 86 OnParseITunesPrefXml)
88 #endif // defined(OS_WIN) 87 #endif // defined(OS_WIN)
89 88
90 #if defined(OS_MACOSX) 89 #if defined(OS_MACOSX)
91 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile, 90 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile,
92 OnParseIPhotoLibraryXmlFile) 91 OnParseIPhotoLibraryXmlFile)
93 #endif // defined(OS_MACOSX) 92 #endif // defined(OS_MACOSX)
(...skipping 22 matching lines...) Expand all
116 if (!zip::Unzip(zip_path, dir)) { 115 if (!zip::Unzip(zip_path, dir)) {
117 Send(new ChromeUtilityHostMsg_UnzipToDir_Failed( 116 Send(new ChromeUtilityHostMsg_UnzipToDir_Failed(
118 std::string(kExtensionHandlerUnzipError))); 117 std::string(kExtensionHandlerUnzipError)));
119 } else { 118 } else {
120 Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(dir)); 119 Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(dir));
121 } 120 }
122 121
123 ReleaseProcessIfNeeded(); 122 ReleaseProcessIfNeeded();
124 } 123 }
125 124
126 void ExtensionsHandler::OnDecodeImageBase64(
127 const std::string& encoded_string) {
128 std::string decoded_string;
129
130 if (!base::Base64Decode(encoded_string, &decoded_string)) {
131 Send(new ChromeUtilityHostMsg_DecodeImage_Failed());
132 return;
133 }
134
135 std::vector<unsigned char> decoded_vector(decoded_string.size());
136 for (size_t i = 0; i < decoded_string.size(); ++i) {
137 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]);
138 }
139
140 ChromeContentUtilityClient::DecodeImageAndSend(decoded_vector, false);
141 }
142
143 void ExtensionsHandler::OnCheckMediaFile( 125 void ExtensionsHandler::OnCheckMediaFile(
144 int64 milliseconds_of_decoding, 126 int64 milliseconds_of_decoding,
145 const IPC::PlatformFileForTransit& media_file) { 127 const IPC::PlatformFileForTransit& media_file) {
146 media::MediaFileChecker checker( 128 media::MediaFileChecker checker(
147 IPC::PlatformFileForTransitToFile(media_file)); 129 IPC::PlatformFileForTransitToFile(media_file));
148 const bool check_success = checker.Start( 130 const bool check_success = checker.Start(
149 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); 131 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding));
150 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); 132 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success));
151 ReleaseProcessIfNeeded(); 133 ReleaseProcessIfNeeded();
152 } 134 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 208
227 std::string key_data; 209 std::string key_data;
228 std::string error; 210 std::string error;
229 wifi_service->GetKeyFromSystem(network_guid, &key_data, &error); 211 wifi_service->GetKeyFromSystem(network_guid, &key_data, &error);
230 212
231 Send(new ChromeUtilityHostMsg_GotWiFiCredentials(key_data, error.empty())); 213 Send(new ChromeUtilityHostMsg_GotWiFiCredentials(key_data, error.empty()));
232 } 214 }
233 #endif // defined(OS_WIN) 215 #endif // defined(OS_WIN)
234 216
235 } // namespace extensions 217 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/utility/extensions/extensions_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698