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

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

Issue 3353015: Implement gallery install API (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: erik comments Created 10 years, 3 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/extensions/extension_management_api.h" 5 #include "chrome/browser/extensions/extension_management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h"
13 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
14 #include "chrome/browser/extensions/extension_event_names.h" 15 #include "chrome/browser/extensions/extension_event_names.h"
15 #include "chrome/browser/extensions/extension_message_service.h" 16 #include "chrome/browser/extensions/extension_message_service.h"
17 #include "chrome/browser/extensions/extension_updater.h"
16 #include "chrome/browser/extensions/extensions_service.h" 18 #include "chrome/browser/extensions/extensions_service.h"
17 #include "chrome/browser/profile.h" 19 #include "chrome/browser/profile.h"
20 #include "chrome/common/extensions/extension_constants.h"
18 #include "chrome/common/extensions/extension_error_utils.h" 21 #include "chrome/common/extensions/extension_error_utils.h"
19 #include "chrome/common/notification_service.h" 22 #include "chrome/common/notification_service.h"
20 #include "chrome/common/notification_type.h" 23 #include "chrome/common/notification_type.h"
21 24
22 using base::IntToString; 25 using base::IntToString;
23 namespace events = extension_event_names; 26 namespace events = extension_event_names;
24 27
28 namespace {
29
25 const char kAppLaunchUrlKey[] = "appLaunchUrl"; 30 const char kAppLaunchUrlKey[] = "appLaunchUrl";
26 const char kEnabledKey[] = "enabled"; 31 const char kEnabledKey[] = "enabled";
27 const char kIconsKey[] = "icons"; 32 const char kIconsKey[] = "icons";
28 const char kIdKey[] = "id"; 33 const char kIdKey[] = "id";
29 const char kIsAppKey[] = "isApp"; 34 const char kIsAppKey[] = "isApp";
30 const char kNameKey[] = "name"; 35 const char kNameKey[] = "name";
31 const char kOptionsUrlKey[] = "optionsUrl"; 36 const char kOptionsUrlKey[] = "optionsUrl";
32 const char kSizeKey[] = "size"; 37 const char kSizeKey[] = "size";
33 const char kUrlKey[] = "url"; 38 const char kUrlKey[] = "url";
34 39
35 const char kNoExtensionError[] = "No extension with id *"; 40 const char kNoExtensionError[] = "No extension with id *";
36 41
42 }
43
37 ExtensionsService* ExtensionManagementFunction::service() { 44 ExtensionsService* ExtensionManagementFunction::service() {
38 return profile()->GetExtensionsService(); 45 return profile()->GetExtensionsService();
39 } 46 }
40 47
41 static DictionaryValue* CreateExtensionInfo(const Extension& extension, 48 static DictionaryValue* CreateExtensionInfo(const Extension& extension,
42 bool enabled) { 49 bool enabled) {
43 DictionaryValue* info = new DictionaryValue(); 50 DictionaryValue* info = new DictionaryValue();
44 info->SetString(kIdKey, extension.id()); 51 info->SetString(kIdKey, extension.id());
45 info->SetBoolean(kIsAppKey, extension.is_app()); 52 info->SetBoolean(kIsAppKey, extension.is_app());
46 info->SetString(kNameKey, extension.name()); 53 info->SetString(kNameKey, extension.name());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 117
111 if (state == Extension::DISABLED && enable) { 118 if (state == Extension::DISABLED && enable) {
112 service()->EnableExtension(extension_id); 119 service()->EnableExtension(extension_id);
113 } else if (state == Extension::ENABLED && !enable) { 120 } else if (state == Extension::ENABLED && !enable) {
114 service()->DisableExtension(extension_id); 121 service()->DisableExtension(extension_id);
115 } 122 }
116 123
117 return true; 124 return true;
118 } 125 }
119 126
120 bool InstallFunction::RunImpl() {
121 NOTIMPLEMENTED();
122 return false;
123 }
124
125 bool UninstallFunction::RunImpl() { 127 bool UninstallFunction::RunImpl() {
126 std::string extension_id; 128 std::string extension_id;
127 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id)); 129 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id));
128 130
129 if (!service()->GetExtensionById(extension_id, true)) { 131 if (!service()->GetExtensionById(extension_id, true)) {
130 error_ = ExtensionErrorUtils::FormatErrorMessage( 132 error_ = ExtensionErrorUtils::FormatErrorMessage(
131 kNoExtensionError, extension_id); 133 kNoExtensionError, extension_id);
132 return false; 134 return false;
133 } 135 }
134 136
135 service()->UninstallExtension(extension_id, false /* external_uninstall */); 137 service()->UninstallExtension(extension_id, false /* external_uninstall */);
136 return true; 138 return true;
137 } 139 }
138 140
139
140 // static 141 // static
141 ExtensionManagementEventRouter* ExtensionManagementEventRouter::GetInstance() { 142 ExtensionManagementEventRouter* ExtensionManagementEventRouter::GetInstance() {
142 return Singleton<ExtensionManagementEventRouter>::get(); 143 return Singleton<ExtensionManagementEventRouter>::get();
143 } 144 }
144 145
145 ExtensionManagementEventRouter::ExtensionManagementEventRouter() {} 146 ExtensionManagementEventRouter::ExtensionManagementEventRouter() {}
146 147
147 ExtensionManagementEventRouter::~ExtensionManagementEventRouter() {} 148 ExtensionManagementEventRouter::~ExtensionManagementEventRouter() {}
148 149
149 void ExtensionManagementEventRouter::Init() { 150 void ExtensionManagementEventRouter::Init() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 std::string args_json; 198 std::string args_json;
198 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); 199 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json);
199 200
200 ExtensionMessageService* message_service = 201 ExtensionMessageService* message_service =
201 profile->GetExtensionMessageService(); 202 profile->GetExtensionMessageService();
202 message_service->DispatchEventToRenderers(event_name, 203 message_service->DispatchEventToRenderers(event_name,
203 args_json, 204 args_json,
204 profile, 205 profile,
205 GURL()); 206 GURL());
206 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_management_api.h ('k') | chrome/browser/extensions/extension_webstore_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698