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

Side by Side Diff: chrome/browser/extensions/extensions_startup.cc

Issue 10824204: Move small c/b/extensions classes into extensions namespace no.2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq + nitfix Created 8 years, 4 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extensions_startup.h"
6
7 #include "base/string_util.h"
8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/simple_message_box.h"
13 #include "chrome/common/chrome_switches.h"
14
15 ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {}
16
17 void ExtensionsStartupUtil::OnPackSuccess(
18 const FilePath& crx_path,
19 const FilePath& output_private_key_path) {
20 pack_job_succeeded_ = true;
21 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Success"),
22 PackExtensionJob::StandardSuccessMessage(crx_path,
23 output_private_key_path),
24 chrome::MESSAGE_BOX_TYPE_INFORMATION);
25 }
26
27 void ExtensionsStartupUtil::OnPackFailure(
28 const std::string& error_message,
29 extensions::ExtensionCreator::ErrorType type) {
30 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Error"),
31 UTF8ToUTF16(error_message), chrome::MESSAGE_BOX_TYPE_WARNING);
32 }
33
34 bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) {
35 if (!cmd_line.HasSwitch(switches::kPackExtension))
36 return false;
37
38 // Input Paths.
39 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension);
40 FilePath private_key_path;
41 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) {
42 private_key_path = cmd_line.GetSwitchValuePath(switches::kPackExtensionKey);
43 }
44
45 // Launch a job to perform the packing on the file thread. Ignore warnings
46 // from the packing process. (e.g. Overwrite any existing crx file.)
47 pack_job_ = new PackExtensionJob(this, src_dir, private_key_path,
48 extensions::ExtensionCreator::kOverwriteCRX);
49 pack_job_->set_asynchronous(false);
50 pack_job_->Start();
51
52 return pack_job_succeeded_;
53 }
54
55 bool ExtensionsStartupUtil::UninstallExtension(const CommandLine& cmd_line,
56 Profile* profile) {
57 DCHECK(profile);
58
59 if (!cmd_line.HasSwitch(switches::kUninstallExtension))
60 return false;
61
62 ExtensionService* extension_service = profile->GetExtensionService();
63 if (!extension_service)
64 return false;
65
66 std::string extension_id = cmd_line.GetSwitchValueASCII(
67 switches::kUninstallExtension);
68 return ExtensionService::UninstallExtensionHelper(extension_service,
69 extension_id);
70 }
71
72 ExtensionsStartupUtil::~ExtensionsStartupUtil() {
73 if (pack_job_.get())
74 pack_job_->ClearClient();
75 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_startup.h ('k') | chrome/browser/extensions/navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698