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

Side by Side Diff: extensions/utility/utility_handler.cc

Issue 864093002: Move sandboxed_unpacker.{h,cc} from chrome/ to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errors Created 5 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
« no previous file with comments | « extensions/utility/utility_handler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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 "extensions/utility/utility_handler.h" 5 #include "extensions/utility/utility_handler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
8 #include "content/public/utility/utility_thread.h" 9 #include "content/public/utility/utility_thread.h"
9 #include "extensions/common/extension.h" 10 #include "extensions/common/extension.h"
10 #include "extensions/common/extension_l10n_util.h" 11 #include "extensions/common/extension_l10n_util.h"
11 #include "extensions/common/extension_utility_messages.h" 12 #include "extensions/common/extension_utility_messages.h"
13 #include "extensions/common/extensions_client.h"
14 #include "extensions/common/manifest.h"
12 #include "extensions/common/update_manifest.h" 15 #include "extensions/common/update_manifest.h"
16 #include "extensions/utility/unpacker.h"
13 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
14 #include "ipc/ipc_message_macros.h" 18 #include "ipc/ipc_message_macros.h"
15 #include "ui/base/ui_base_switches.h" 19 #include "ui/base/ui_base_switches.h"
16 20
17 namespace extensions { 21 namespace extensions {
18 22
19 namespace { 23 namespace {
20 24
21 bool Send(IPC::Message* message) { 25 bool Send(IPC::Message* message) {
22 return content::UtilityThread::Get()->Send(message); 26 return content::UtilityThread::Get()->Send(message);
(...skipping 15 matching lines...) Expand all
38 void UtilityHandler::UtilityThreadStarted() { 42 void UtilityHandler::UtilityThreadStarted() {
39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
40 std::string lang = command_line->GetSwitchValueASCII(switches::kLang); 44 std::string lang = command_line->GetSwitchValueASCII(switches::kLang);
41 if (!lang.empty()) 45 if (!lang.empty())
42 extension_l10n_util::SetProcessLocale(lang); 46 extension_l10n_util::SetProcessLocale(lang);
43 } 47 }
44 48
45 bool UtilityHandler::OnMessageReceived(const IPC::Message& message) { 49 bool UtilityHandler::OnMessageReceived(const IPC::Message& message) {
46 bool handled = true; 50 bool handled = true;
47 IPC_BEGIN_MESSAGE_MAP(UtilityHandler, message) 51 IPC_BEGIN_MESSAGE_MAP(UtilityHandler, message)
52 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension)
48 IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest, 53 IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest,
49 OnParseUpdateManifest) 54 OnParseUpdateManifest)
50 IPC_MESSAGE_UNHANDLED(handled = false) 55 IPC_MESSAGE_UNHANDLED(handled = false)
51 IPC_END_MESSAGE_MAP() 56 IPC_END_MESSAGE_MAP()
52 return handled; 57 return handled;
53 } 58 }
54 59
55 void UtilityHandler::OnParseUpdateManifest(const std::string& xml) { 60 void UtilityHandler::OnParseUpdateManifest(const std::string& xml) {
56 UpdateManifest manifest; 61 UpdateManifest manifest;
57 if (!manifest.Parse(xml)) { 62 if (!manifest.Parse(xml)) {
58 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Failed( 63 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Failed(
59 manifest.errors())); 64 manifest.errors()));
60 } else { 65 } else {
61 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( 66 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded(
62 manifest.results())); 67 manifest.results()));
63 } 68 }
64 ReleaseProcessIfNeeded(); 69 ReleaseProcessIfNeeded();
65 } 70 }
66 71
72 void UtilityHandler::OnUnpackExtension(
73 const base::FilePath& extension_path,
74 const std::string& extension_id,
75 int location,
76 int creation_flags) {
77 CHECK_GT(location, Manifest::INVALID_LOCATION);
78 CHECK_LT(location, Manifest::NUM_LOCATIONS);
79 DCHECK(ExtensionsClient::Get());
80 Unpacker unpacker(extension_path,
81 extension_id,
82 static_cast<Manifest::Location>(location),
83 creation_flags);
84 if (unpacker.Run() && unpacker.DumpImagesToFile() &&
85 unpacker.DumpMessageCatalogsToFile()) {
86 Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded(
87 *unpacker.parsed_manifest()));
88 } else {
89 Send(new ChromeUtilityHostMsg_UnpackExtension_Failed(
90 unpacker.error_message()));
91 }
92
93 ReleaseProcessIfNeeded();
94 }
95
96
67 } // namespace extensions 97 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/utility/utility_handler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698