| 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 <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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 callback.Run(false); | 100 callback.Run(false); |
| 98 #endif | 101 #endif |
| 99 ReleaseProcessIfNeeded(); | 102 ReleaseProcessIfNeeded(); |
| 100 } | 103 } |
| 101 | 104 |
| 102 ChromeContentUtilityClient* const utility_client_; | 105 ChromeContentUtilityClient* const utility_client_; |
| 103 | 106 |
| 104 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl); | 107 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl); |
| 105 }; | 108 }; |
| 106 | 109 |
| 110 class RemovableStorageWriterImpl |
| 111 : public extensions::mojom::RemovableStorageWriter { |
| 112 public: |
| 113 RemovableStorageWriterImpl() = default; |
| 114 ~RemovableStorageWriterImpl() override = default; |
| 115 |
| 116 static void Create(extensions::mojom::RemovableStorageWriterRequest request) { |
| 117 mojo::MakeStrongBinding(base::MakeUnique<RemovableStorageWriterImpl>(), |
| 118 std::move(request)); |
| 119 } |
| 120 |
| 121 private: |
| 122 void Write( |
| 123 const base::FilePath& source, |
| 124 const base::FilePath& target, |
| 125 extensions::mojom::RemovableStorageWriterClientPtr client) override { |
| 126 writer_.Write(source, target, std::move(client)); |
| 127 } |
| 128 |
| 129 void Verify( |
| 130 const base::FilePath& source, |
| 131 const base::FilePath& target, |
| 132 extensions::mojom::RemovableStorageWriterClientPtr client) override { |
| 133 writer_.Verify(source, target, std::move(client)); |
| 134 } |
| 135 |
| 136 image_writer::ImageWriterHandler writer_; |
| 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(RemovableStorageWriterImpl); |
| 139 }; |
| 140 |
| 107 #if defined(OS_WIN) | 141 #if defined(OS_WIN) |
| 108 class WiFiCredentialsGetterImpl | 142 class WiFiCredentialsGetterImpl |
| 109 : public extensions::mojom::WiFiCredentialsGetter { | 143 : public extensions::mojom::WiFiCredentialsGetter { |
| 110 public: | 144 public: |
| 111 WiFiCredentialsGetterImpl() = default; | 145 WiFiCredentialsGetterImpl() = default; |
| 112 ~WiFiCredentialsGetterImpl() override = default; | 146 ~WiFiCredentialsGetterImpl() override = default; |
| 113 | 147 |
| 114 static void Create(extensions::mojom::WiFiCredentialsGetterRequest request) { | 148 static void Create(extensions::mojom::WiFiCredentialsGetterRequest request) { |
| 115 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(), | 149 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(), |
| 116 std::move(request)); | 150 std::move(request)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 197 |
| 164 // static | 198 // static |
| 165 void ExtensionsHandler::ExposeInterfacesToBrowser( | 199 void ExtensionsHandler::ExposeInterfacesToBrowser( |
| 166 service_manager::InterfaceRegistry* registry, | 200 service_manager::InterfaceRegistry* registry, |
| 167 ChromeContentUtilityClient* utility_client, | 201 ChromeContentUtilityClient* utility_client, |
| 168 bool running_elevated) { | 202 bool running_elevated) { |
| 169 // If our process runs with elevated privileges, only add elevated Mojo | 203 // If our process runs with elevated privileges, only add elevated Mojo |
| 170 // services to the interface registry. | 204 // services to the interface registry. |
| 171 if (running_elevated) { | 205 if (running_elevated) { |
| 172 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
| 207 registry->AddInterface(base::Bind(&RemovableStorageWriterImpl::Create)); |
| 173 registry->AddInterface(base::Bind(&WiFiCredentialsGetterImpl::Create)); | 208 registry->AddInterface(base::Bind(&WiFiCredentialsGetterImpl::Create)); |
| 174 #endif | 209 #endif |
| 175 return; | 210 return; |
| 176 } | 211 } |
| 177 | 212 |
| 178 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client)); | 213 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client)); |
| 214 #if !defined(OS_WIN) |
| 215 registry->AddInterface(base::Bind(&RemovableStorageWriterImpl::Create)); |
| 216 #endif |
| 179 } | 217 } |
| 180 | 218 |
| 181 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { | 219 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { |
| 182 bool handled = true; | 220 bool handled = true; |
| 183 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) | 221 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) |
| 184 #if defined(OS_WIN) | 222 #if defined(OS_WIN) |
| 185 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, | 223 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, |
| 186 OnParseITunesPrefXml) | 224 OnParseITunesPrefXml) |
| 187 #endif // defined(OS_WIN) | 225 #endif // defined(OS_WIN) |
| 188 | 226 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 picasa::PicasaAlbumsIndexer indexer(album_uids); | 293 picasa::PicasaAlbumsIndexer indexer(album_uids); |
| 256 indexer.ParseFolderINI(folders_inis); | 294 indexer.ParseFolderINI(folders_inis); |
| 257 content::UtilityThread::Get()->Send( | 295 content::UtilityThread::Get()->Send( |
| 258 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 296 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
| 259 indexer.albums_images())); | 297 indexer.albums_images())); |
| 260 ReleaseProcessIfNeeded(); | 298 ReleaseProcessIfNeeded(); |
| 261 } | 299 } |
| 262 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 300 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 263 | 301 |
| 264 } // namespace extensions | 302 } // namespace extensions |
| OLD | NEW |