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

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

Issue 2663603002: Convert utility process ImageWriter IPC to mojo (Closed)
Patch Set: Review comments. Created 3 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "chrome/common/chrome_utility_messages.h" 13 #include "chrome/common/chrome_utility_messages.h"
13 #include "chrome/common/extensions/chrome_extensions_client.h" 14 #include "chrome/common/extensions/chrome_extensions_client.h"
14 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" 15 #include "chrome/common/extensions/chrome_utility_extensions_messages.h"
15 #include "chrome/common/extensions/media_parser.mojom.h" 16 #include "chrome/common/extensions/media_parser.mojom.h"
17 #include "chrome/common/extensions/removable_storage_writer.mojom.h"
16 #include "chrome/common/media_galleries/metadata_types.h" 18 #include "chrome/common/media_galleries/metadata_types.h"
17 #include "chrome/utility/chrome_content_utility_client.h" 19 #include "chrome/utility/chrome_content_utility_client.h"
20 #include "chrome/utility/image_writer/image_writer_handler.h"
18 #include "chrome/utility/media_galleries/ipc_data_source.h" 21 #include "chrome/utility/media_galleries/ipc_data_source.h"
19 #include "chrome/utility/media_galleries/media_metadata_parser.h" 22 #include "chrome/utility/media_galleries/media_metadata_parser.h"
20 #include "content/public/common/content_paths.h" 23 #include "content/public/common/content_paths.h"
21 #include "content/public/utility/utility_thread.h" 24 #include "content/public/utility/utility_thread.h"
22 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
23 #include "extensions/common/extension_utility_messages.h" 26 #include "extensions/common/extension_utility_messages.h"
24 #include "extensions/utility/unpacker.h" 27 #include "extensions/utility/unpacker.h"
25 #include "media/base/media.h" 28 #include "media/base/media.h"
26 #include "mojo/public/cpp/bindings/strong_binding.h" 29 #include "mojo/public/cpp/bindings/strong_binding.h"
27 #include "services/service_manager/public/cpp/interface_registry.h" 30 #include "services/service_manager/public/cpp/interface_registry.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #else 99 #else
97 callback.Run(false); 100 callback.Run(false);
98 #endif 101 #endif
99 } 102 }
100 103
101 ChromeContentUtilityClient* const utility_client_; 104 ChromeContentUtilityClient* const utility_client_;
102 105
103 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl); 106 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl);
104 }; 107 };
105 108
109 class RemovableStorageWriterImpl
110 : public extensions::mojom::RemovableStorageWriter {
111 public:
112 RemovableStorageWriterImpl() = default;
113 ~RemovableStorageWriterImpl() override = default;
114
115 static void Create(extensions::mojom::RemovableStorageWriterRequest request) {
116 mojo::MakeStrongBinding(base::MakeUnique<RemovableStorageWriterImpl>(),
117 std::move(request));
118 }
119
120 private:
121 void Write(
122 const base::FilePath& source,
123 const base::FilePath& target,
124 extensions::mojom::RemovableStorageWriterClientPtr client) override {
125 writer_.Write(source, target, std::move(client));
126 }
127
128 void Verify(
129 const base::FilePath& source,
130 const base::FilePath& target,
131 extensions::mojom::RemovableStorageWriterClientPtr client) override {
132 writer_.Verify(source, target, std::move(client));
133 }
134
135 image_writer::ImageWriterHandler writer_;
136
137 DISALLOW_COPY_AND_ASSIGN(RemovableStorageWriterImpl);
138 };
139
106 #if defined(OS_WIN) 140 #if defined(OS_WIN)
107 class WiFiCredentialsGetterImpl 141 class WiFiCredentialsGetterImpl
108 : public extensions::mojom::WiFiCredentialsGetter { 142 : public extensions::mojom::WiFiCredentialsGetter {
109 public: 143 public:
110 WiFiCredentialsGetterImpl() = default; 144 WiFiCredentialsGetterImpl() = default;
111 ~WiFiCredentialsGetterImpl() override = default; 145 ~WiFiCredentialsGetterImpl() override = default;
112 146
113 static void Create(extensions::mojom::WiFiCredentialsGetterRequest request) { 147 static void Create(extensions::mojom::WiFiCredentialsGetterRequest request) {
114 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(), 148 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(),
115 std::move(request)); 149 std::move(request));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 196
163 // static 197 // static
164 void ExtensionsHandler::ExposeInterfacesToBrowser( 198 void ExtensionsHandler::ExposeInterfacesToBrowser(
165 service_manager::InterfaceRegistry* registry, 199 service_manager::InterfaceRegistry* registry,
166 ChromeContentUtilityClient* utility_client, 200 ChromeContentUtilityClient* utility_client,
167 bool running_elevated) { 201 bool running_elevated) {
168 // If our process runs with elevated privileges, only add elevated Mojo 202 // If our process runs with elevated privileges, only add elevated Mojo
169 // services to the interface registry. 203 // services to the interface registry.
170 if (running_elevated) { 204 if (running_elevated) {
171 #if defined(OS_WIN) 205 #if defined(OS_WIN)
206 registry->AddInterface(base::Bind(&RemovableStorageWriterImpl::Create));
172 registry->AddInterface(base::Bind(&WiFiCredentialsGetterImpl::Create)); 207 registry->AddInterface(base::Bind(&WiFiCredentialsGetterImpl::Create));
173 #endif 208 #endif
174 return; 209 return;
175 } 210 }
176 211
177 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client)); 212 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client));
213 #if !defined(OS_WIN)
214 registry->AddInterface(base::Bind(&RemovableStorageWriterImpl::Create));
dcheng 2017/02/06 05:52:02 Out of curiosity, why can't this just talk to Imag
Noel Gordon 2017/02/07 11:31:09 Maybe it could, but the goal here was not to have
215 #endif
178 } 216 }
179 217
180 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { 218 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
181 bool handled = true; 219 bool handled = true;
182 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) 220 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
183 #if defined(OS_WIN) 221 #if defined(OS_WIN)
184 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 222 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
185 OnParseITunesPrefXml) 223 OnParseITunesPrefXml)
186 #endif // defined(OS_WIN) 224 #endif // defined(OS_WIN)
187 225
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 picasa::PicasaAlbumsIndexer indexer(album_uids); 292 picasa::PicasaAlbumsIndexer indexer(album_uids);
255 indexer.ParseFolderINI(folders_inis); 293 indexer.ParseFolderINI(folders_inis);
256 content::UtilityThread::Get()->Send( 294 content::UtilityThread::Get()->Send(
257 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 295 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
258 indexer.albums_images())); 296 indexer.albums_images()));
259 ReleaseProcessIfNeeded(); 297 ReleaseProcessIfNeeded();
260 } 298 }
261 #endif // defined(OS_WIN) || defined(OS_MACOSX) 299 #endif // defined(OS_WIN) || defined(OS_MACOSX)
262 300
263 } // namespace extensions 301 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698