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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 150663013: Integrate ErrorConsole with Apps Dev Tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated histograms.xml Created 6 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
11 #include "apps/shell_window_registry.h" 11 #include "apps/shell_window_registry.h"
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/file_util.h" 15 #include "base/file_util.h"
15 #include "base/files/file_enumerator.h" 16 #include "base/files/file_enumerator.h"
16 #include "base/i18n/file_util_icu.h" 17 #include "base/i18n/file_util_icu.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/devtools/devtools_window.h" 22 #include "chrome/browser/devtools/devtools_window.h"
22 #include "chrome/browser/extensions/api/developer_private/developer_private_api_ factory.h" 23 #include "chrome/browser/extensions/api/developer_private/developer_private_api_ factory.h"
23 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 24 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
24 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 25 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
25 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 26 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
26 #include "chrome/browser/extensions/devtools_util.h" 27 #include "chrome/browser/extensions/devtools_util.h"
27 #include "chrome/browser/extensions/extension_disabled_ui.h" 28 #include "chrome/browser/extensions/extension_disabled_ui.h"
28 #include "chrome/browser/extensions/extension_error_reporter.h" 29 #include "chrome/browser/extensions/extension_error_reporter.h"
29 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
30 #include "chrome/browser/extensions/extension_util.h" 31 #include "chrome/browser/extensions/extension_util.h"
31 #include "chrome/browser/extensions/unpacked_installer.h" 32 #include "chrome/browser/extensions/unpacked_installer.h"
32 #include "chrome/browser/extensions/updater/extension_updater.h" 33 #include "chrome/browser/extensions/updater/extension_updater.h"
33 #include "chrome/browser/platform_util.h" 34 #include "chrome/browser/platform_util.h"
34 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi ce.h" 36 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi ce.h"
36 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 37 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
37 #include "chrome/browser/ui/chrome_select_file_policy.h" 38 #include "chrome/browser/ui/chrome_select_file_policy.h"
39 #include "chrome/browser/ui/webui/extensions/extension_error_ui_util.h"
38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
39 #include "chrome/common/extensions/api/developer_private.h" 41 #include "chrome/common/extensions/api/developer_private.h"
40 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 42 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
41 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" 43 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
42 #include "chrome/common/extensions/manifest_url_handler.h" 44 #include "chrome/common/extensions/manifest_url_handler.h"
43 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
44 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/render_process_host.h" 48 #include "content/public/browser/render_process_host.h"
47 #include "content/public/browser/render_view_host.h" 49 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/site_instance.h" 50 #include "content/public/browser/site_instance.h"
49 #include "content/public/browser/storage_partition.h" 51 #include "content/public/browser/storage_partition.h"
50 #include "content/public/browser/web_contents.h" 52 #include "content/public/browser/web_contents.h"
53 #include "extensions/browser/extension_error.h"
51 #include "extensions/browser/extension_registry.h" 54 #include "extensions/browser/extension_registry.h"
52 #include "extensions/browser/extension_system.h" 55 #include "extensions/browser/extension_system.h"
53 #include "extensions/browser/management_policy.h" 56 #include "extensions/browser/management_policy.h"
54 #include "extensions/browser/view_type_utils.h" 57 #include "extensions/browser/view_type_utils.h"
55 #include "extensions/common/constants.h" 58 #include "extensions/common/constants.h"
56 #include "extensions/common/extension_resource.h" 59 #include "extensions/common/extension_resource.h"
57 #include "extensions/common/extension_set.h" 60 #include "extensions/common/extension_set.h"
58 #include "extensions/common/install_warning.h" 61 #include "extensions/common/install_warning.h"
59 #include "extensions/common/manifest_handlers/background_info.h" 62 #include "extensions/common/manifest_handlers/background_info.h"
60 #include "extensions/common/manifest_handlers/incognito_info.h" 63 #include "extensions/common/manifest_handlers/incognito_info.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 151
149 DeveloperPrivateAPI* DeveloperPrivateAPI::Get(Profile* profile) { 152 DeveloperPrivateAPI* DeveloperPrivateAPI::Get(Profile* profile) {
150 return DeveloperPrivateAPIFactory::GetForProfile(profile); 153 return DeveloperPrivateAPIFactory::GetForProfile(profile);
151 } 154 }
152 155
153 DeveloperPrivateAPI::DeveloperPrivateAPI(Profile* profile) : profile_(profile) { 156 DeveloperPrivateAPI::DeveloperPrivateAPI(Profile* profile) : profile_(profile) {
154 RegisterNotifications(); 157 RegisterNotifications();
155 } 158 }
156 159
157 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) 160 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile)
158 : profile_(profile) { 161 : profile_(profile) {
159 int types[] = { 162 int types[] = {
160 chrome::NOTIFICATION_EXTENSION_INSTALLED, 163 chrome::NOTIFICATION_EXTENSION_INSTALLED,
161 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 164 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
162 chrome::NOTIFICATION_EXTENSION_LOADED, 165 chrome::NOTIFICATION_EXTENSION_LOADED,
163 chrome::NOTIFICATION_EXTENSION_UNLOADED, 166 chrome::NOTIFICATION_EXTENSION_UNLOADED,
164 chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED, 167 chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED,
165 chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED 168 chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED
166 }; 169 };
167 170
168 CHECK(registrar_.IsEmpty()); 171 CHECK(registrar_.IsEmpty());
169 for (size_t i = 0; i < arraysize(types); ++i) { 172 for (size_t i = 0; i < arraysize(types); ++i) {
170 registrar_.Add(this, 173 registrar_.Add(this,
171 types[i], 174 types[i],
172 content::Source<Profile>(profile_)); 175 content::Source<Profile>(profile_));
173 } 176 }
177
178 ErrorConsole::Get(profile)->AddObserver(this);
174 } 179 }
175 180
181 DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() {
182 ErrorConsole::Get(profile_)->RemoveObserver(this);
183 }
176 184
177 DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() {} 185 void DeveloperPrivateEventRouter::AddExtensionId(
186 const std::string& extension_id) {
187 extension_ids_.insert(extension_id);
188 }
189
190 void DeveloperPrivateEventRouter::RemoveExtensionId(
191 const std::string& extension_id) {
192 extension_ids_.erase(extension_id);
193 }
178 194
179 void DeveloperPrivateEventRouter::Observe( 195 void DeveloperPrivateEventRouter::Observe(
180 int type, 196 int type,
181 const content::NotificationSource& source, 197 const content::NotificationSource& source,
182 const content::NotificationDetails& details) { 198 const content::NotificationDetails& details) {
183 const char* event_name = NULL; 199 const char* event_name = NULL;
184 Profile* profile = content::Source<Profile>(source).ptr(); 200 Profile* profile = content::Source<Profile>(source).ptr();
185 CHECK(profile); 201 CHECK(profile);
186 CHECK(profile_->IsSameProfile(profile)); 202 CHECK(profile_->IsSameProfile(profile));
187 developer::EventData event_data; 203 developer::EventData event_data;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 event_data.item_id = extension->id(); 241 event_data.item_id = extension->id();
226 242
227 scoped_ptr<base::ListValue> args(new base::ListValue()); 243 scoped_ptr<base::ListValue> args(new base::ListValue());
228 args->Append(event_data.ToValue().release()); 244 args->Append(event_data.ToValue().release());
229 245
230 event_name = developer_private::OnItemStateChanged::kEventName; 246 event_name = developer_private::OnItemStateChanged::kEventName;
231 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 247 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
232 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); 248 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
233 } 249 }
234 250
251 void DeveloperPrivateEventRouter::OnErrorAdded(const ExtensionError* error) {
252 // We don't want to handle errors thrown by extensions subscribed to these
253 // events (currently only the Apps Developer Tool), because doing so risks
254 // entering a loop.
255 if (extension_ids_.find(error->extension_id()) != extension_ids_.end())
256 return;
257
258 developer::EventData event_data;
259 event_data.event_type = developer::EVENT_TYPE_ERROR_ADDED;
260 event_data.item_id = error->extension_id();
261
262 scoped_ptr<base::ListValue> args(new base::ListValue);
263 args->Append(event_data.ToValue().release());
264
265 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
266 scoped_ptr<Event>(new Event(
267 developer_private::OnItemStateChanged::kEventName, args.Pass())));
268 }
269
235 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { 270 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) {
236 last_unpacked_directory_ = path; 271 last_unpacked_directory_ = path;
237 } 272 }
238 273
239 void DeveloperPrivateAPI::RegisterNotifications() { 274 void DeveloperPrivateAPI::RegisterNotifications() {
240 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( 275 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
241 this, developer_private::OnItemStateChanged::kEventName); 276 this, developer_private::OnItemStateChanged::kEventName);
242 } 277 }
243 278
244 DeveloperPrivateAPI::~DeveloperPrivateAPI() {} 279 DeveloperPrivateAPI::~DeveloperPrivateAPI() {}
245 280
246 void DeveloperPrivateAPI::Shutdown() {} 281 void DeveloperPrivateAPI::Shutdown() {}
247 282
248 void DeveloperPrivateAPI::OnListenerAdded( 283 void DeveloperPrivateAPI::OnListenerAdded(
249 const EventListenerInfo& details) { 284 const EventListenerInfo& details) {
250 if (!developer_private_event_router_) 285 if (!developer_private_event_router_) {
251 developer_private_event_router_.reset( 286 developer_private_event_router_.reset(
252 new DeveloperPrivateEventRouter(profile_)); 287 new DeveloperPrivateEventRouter(profile_));
288 }
289
290 developer_private_event_router_->AddExtensionId(details.extension_id);
253 } 291 }
254 292
255 void DeveloperPrivateAPI::OnListenerRemoved( 293 void DeveloperPrivateAPI::OnListenerRemoved(
256 const EventListenerInfo& details) { 294 const EventListenerInfo& details) {
257 if (!ExtensionSystem::Get(profile_)->event_router()->HasEventListener( 295 if (!ExtensionSystem::Get(profile_)->event_router()->HasEventListener(
258 developer_private::OnItemStateChanged::kEventName)) 296 developer_private::OnItemStateChanged::kEventName)) {
259 developer_private_event_router_.reset(NULL); 297 developer_private_event_router_.reset(NULL);
298 } else {
299 developer_private_event_router_->RemoveExtensionId(details.extension_id);
300 }
260 } 301 }
261 302
262 namespace api { 303 namespace api {
263 304
264 bool DeveloperPrivateAutoUpdateFunction::RunImpl() { 305 bool DeveloperPrivateAutoUpdateFunction::RunImpl() {
265 ExtensionUpdater* updater = GetExtensionUpdater(GetProfile()); 306 ExtensionUpdater* updater = GetExtensionUpdater(GetProfile());
266 if (updater) 307 if (updater)
267 updater->CheckNow(ExtensionUpdater::CheckParams()); 308 updater->CheckNow(ExtensionUpdater::CheckParams());
268 SetResult(new base::FundamentalValue(true)); 309 SetResult(new base::FundamentalValue(true));
269 return true; 310 return true;
270 } 311 }
271 312
272 DeveloperPrivateAutoUpdateFunction::~DeveloperPrivateAutoUpdateFunction() {} 313 DeveloperPrivateAutoUpdateFunction::~DeveloperPrivateAutoUpdateFunction() {}
273 314
274 scoped_ptr<developer::ItemInfo> 315 scoped_ptr<developer::ItemInfo>
275 DeveloperPrivateGetItemsInfoFunction::CreateItemInfo( 316 DeveloperPrivateGetItemsInfoFunction::CreateItemInfo(const Extension& item,
276 const Extension& item, 317 bool item_is_enabled) {
277 bool item_is_enabled) {
278 scoped_ptr<developer::ItemInfo> info(new developer::ItemInfo()); 318 scoped_ptr<developer::ItemInfo> info(new developer::ItemInfo());
279 319
280 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); 320 ExtensionSystem* system = ExtensionSystem::Get(GetProfile());
281 ExtensionService* service = system->extension_service(); 321 ExtensionService* service = system->extension_service();
282 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); 322 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
283 323
284 info->id = item.id(); 324 info->id = item.id();
285 info->name = item.name(); 325 info->name = item.name();
286 info->enabled = service->IsExtensionEnabled(info->id); 326 info->enabled = service->IsExtensionEnabled(info->id);
287 info->offline_enabled = OfflineEnabledInfo::IsOfflineEnabled(&item); 327 info->offline_enabled = OfflineEnabledInfo::IsOfflineEnabled(&item);
(...skipping 13 matching lines...) Expand all
301 info->type = developer::ITEM_TYPE_THEME; 341 info->type = developer::ITEM_TYPE_THEME;
302 } else if (item.is_extension()) { 342 } else if (item.is_extension()) {
303 info->type = developer::ITEM_TYPE_EXTENSION; 343 info->type = developer::ITEM_TYPE_EXTENSION;
304 } else { 344 } else {
305 NOTREACHED(); 345 NOTREACHED();
306 } 346 }
307 347
308 if (Manifest::IsUnpackedLocation(item.location())) { 348 if (Manifest::IsUnpackedLocation(item.location())) {
309 info->path.reset( 349 info->path.reset(
310 new std::string(base::UTF16ToUTF8(item.path().LossyDisplayName()))); 350 new std::string(base::UTF16ToUTF8(item.path().LossyDisplayName())));
311 for (std::vector<extensions::InstallWarning>::const_iterator it = 351 // If the ErrorConsole is enabled, get the errors for the extension and add
312 item.install_warnings().begin(); 352 // them to the list. Otherwise, use the install warnings (using both is
313 it != item.install_warnings().end(); ++it) { 353 // redundant).
314 developer::InstallWarning* warning = new developer::InstallWarning(); 354 ErrorConsole* error_console = ErrorConsole::Get(GetProfile());
315 warning->message = it->message; 355 if (error_console->enabled()) {
316 info->install_warnings.push_back(make_linked_ptr(warning)); 356 const ErrorList& errors = error_console->GetErrorsForExtension(item.id());
357 if (!errors.empty()) {
358 for (ErrorList::const_iterator iter = errors.begin();
359 iter != errors.end();
360 ++iter) {
361 switch ((*iter)->type()) {
362 case ExtensionError::MANIFEST_ERROR:
363 info->manifest_errors.push_back(
364 make_linked_ptr((*iter)->ToValue().release()));
365 case ExtensionError::RUNTIME_ERROR: {
366 const RuntimeError* error =
367 static_cast<const RuntimeError*>(*iter);
368 scoped_ptr<base::DictionaryValue> value = error->ToValue();
369 bool can_inspect = content::RenderViewHost::FromID(
370 error->render_process_id(),
371 error->render_view_id()) != NULL;
372 value->SetBoolean("canInspect", can_inspect);
373 info->runtime_errors.push_back(make_linked_ptr(value.release()));
374 }
375 }
376 }
377 }
378 } else {
379 for (std::vector<extensions::InstallWarning>::const_iterator it =
380 item.install_warnings().begin();
381 it != item.install_warnings().end();
382 ++it) {
383 scoped_ptr<developer::InstallWarning> warning(
384 new developer::InstallWarning);
385 warning->message = it->message;
386 info->install_warnings.push_back(make_linked_ptr(warning.release()));
387 }
317 } 388 }
318 } 389 }
319 390
320 info->incognito_enabled = util::IsIncognitoEnabled(item.id(), GetProfile()); 391 info->incognito_enabled = util::IsIncognitoEnabled(item.id(), GetProfile());
321 info->wants_file_access = item.wants_file_access(); 392 info->wants_file_access = item.wants_file_access();
322 info->allow_file_access = util::AllowFileAccess(item.id(), GetProfile()); 393 info->allow_file_access = util::AllowFileAccess(item.id(), GetProfile());
323 info->allow_reload = Manifest::IsUnpackedLocation(item.location()); 394 info->allow_reload = Manifest::IsUnpackedLocation(item.location());
324 info->is_unpacked = Manifest::IsUnpackedLocation(item.location()); 395 info->is_unpacked = Manifest::IsUnpackedLocation(item.location());
325 info->terminated = registry->terminated_extensions().Contains(item.id()); 396 info->terminated = registry->terminated_extensions().Contains(item.id());
326 info->allow_incognito = item.can_be_incognito_enabled(); 397 info->allow_incognito = item.can_be_incognito_enabled();
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 Release(); 1271 Release();
1201 } 1272 }
1202 1273
1203 void DeveloperPrivateChoosePathFunction::FileSelectionCanceled() { 1274 void DeveloperPrivateChoosePathFunction::FileSelectionCanceled() {
1204 SendResponse(false); 1275 SendResponse(false);
1205 Release(); 1276 Release();
1206 } 1277 }
1207 1278
1208 DeveloperPrivateChoosePathFunction::~DeveloperPrivateChoosePathFunction() {} 1279 DeveloperPrivateChoosePathFunction::~DeveloperPrivateChoosePathFunction() {}
1209 1280
1210 bool DeveloperPrivateGetStringsFunction::RunImpl() {
1211 base::DictionaryValue* dict = new base::DictionaryValue();
1212 SetResult(dict);
1213
1214 webui::SetFontAndTextDirection(dict);
1215
1216 #define SET_STRING(id, idr) \
1217 dict->SetString(id, l10n_util::GetStringUTF16(idr))
1218 SET_STRING("extensionSettings", IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE);
1219
1220 SET_STRING("appsDevtoolSearch", IDS_APPS_DEVTOOL_SEARCH);
1221 SET_STRING("appsDevtoolApps", IDS_APPS_DEVTOOL_APPS_INSTALLED);
1222 SET_STRING("appsDevtoolExtensions", IDS_APPS_DEVTOOL_EXTENSIONS_INSTALLED);
1223 SET_STRING("appsDevtoolNoExtensions", IDS_EXTENSIONS_NONE_INSTALLED);
1224 SET_STRING("appsDevtoolUnpacked", IDS_APPS_DEVTOOL_UNPACKED_INSTALLED);
1225 SET_STRING("appsDevtoolInstalled", IDS_APPS_DEVTOOL_INSTALLED);
1226 SET_STRING("appsDevtoolNoPackedApps", IDS_APPS_DEVTOOL_NO_PACKED_APPS);
1227 SET_STRING("appsDevtoolNoUnpackedApps", IDS_APPS_DEVTOOL_NO_UNPACKED_APPS);
1228 SET_STRING("appsDevtoolNoPackedExtensions",
1229 IDS_APPS_DEVTOOL_NO_PACKED_EXTENSIONS);
1230 SET_STRING("appsDevtoolNoUnpackedExtensions",
1231 IDS_APPS_DEVTOOL_NO_UNPACKED_EXTENSIONS);
1232 SET_STRING("appsDevtoolUpdating", IDS_APPS_DEVTOOL_UPDATING);
1233 SET_STRING("extensionSettingsGetMoreExtensions", IDS_GET_MORE_EXTENSIONS);
1234 SET_STRING("extensionSettingsExtensionId", IDS_EXTENSIONS_ID);
1235 SET_STRING("extensionSettingsExtensionPath", IDS_EXTENSIONS_PATH);
1236 SET_STRING("extensionSettingsInspectViews", IDS_EXTENSIONS_INSPECT_VIEWS);
1237 SET_STRING("extensionSettingsInstallWarnings",
1238 IDS_EXTENSIONS_INSTALL_WARNINGS);
1239 SET_STRING("viewIncognito", IDS_EXTENSIONS_VIEW_INCOGNITO);
1240 SET_STRING("viewInactive", IDS_EXTENSIONS_VIEW_INACTIVE);
1241 SET_STRING("backgroundPage", IDS_EXTENSIONS_BACKGROUND_PAGE);
1242 SET_STRING("extensionSettingsEnable", IDS_EXTENSIONS_ENABLE);
1243 SET_STRING("extensionSettingsEnabled", IDS_EXTENSIONS_ENABLED);
1244 SET_STRING("extensionSettingsRemove", IDS_EXTENSIONS_REMOVE);
1245 SET_STRING("extensionSettingsEnableIncognito",
1246 IDS_EXTENSIONS_ENABLE_INCOGNITO);
1247 SET_STRING("extensionSettingsAllowFileAccess",
1248 IDS_EXTENSIONS_ALLOW_FILE_ACCESS);
1249 SET_STRING("extensionSettingsReloadTerminated",
1250 IDS_EXTENSIONS_RELOAD_TERMINATED);
1251 SET_STRING("extensionSettingsReloadUnpacked",
1252 IDS_APPS_DEV_TOOLS_RELOAD_UNPACKED);
1253 SET_STRING("extensionSettingsLaunch", IDS_EXTENSIONS_LAUNCH);
1254 SET_STRING("extensionSettingsOptions", IDS_EXTENSIONS_OPTIONS_LINK);
1255 SET_STRING("extensionSettingsPermissions", IDS_EXTENSIONS_PERMISSIONS_LINK);
1256 SET_STRING("extensionSettingsVisitWebsite", IDS_EXTENSIONS_VISIT_WEBSITE);
1257 SET_STRING("extensionSettingsVisitWebStore", IDS_EXTENSIONS_VISIT_WEBSTORE);
1258 SET_STRING("extensionSettingsPolicyControlled",
1259 IDS_EXTENSIONS_POLICY_CONTROLLED);
1260 SET_STRING("extensionSettingsManagedMode",
1261 IDS_EXTENSIONS_LOCKED_MANAGED_USER);
1262 SET_STRING("extensionSettingsShowButton", IDS_EXTENSIONS_SHOW_BUTTON);
1263 SET_STRING("appsDevtoolLoadUnpackedButton",
1264 IDS_APPS_DEVTOOL_LOAD_UNPACKED_BUTTON);
1265 SET_STRING("appsDevtoolPackButton", IDS_APPS_DEVTOOL_PACK_BUTTON);
1266 SET_STRING("extensionSettingsCommandsLink",
1267 IDS_EXTENSIONS_COMMANDS_CONFIGURE);
1268 SET_STRING("appsDevtoolUpdateButton", IDS_APPS_DEVTOOL_UPDATE_BUTTON);
1269 SET_STRING("extensionSettingsWarningsTitle", IDS_EXTENSION_WARNINGS_TITLE);
1270 SET_STRING("extensionSettingsShowDetails", IDS_EXTENSIONS_SHOW_DETAILS);
1271 SET_STRING("extensionSettingsHideDetails", IDS_EXTENSIONS_HIDE_DETAILS);
1272 SET_STRING("extensionUninstall", IDS_EXTENSIONS_UNINSTALL);
1273 SET_STRING("extensionsPermissionsHeading",
1274 IDS_EXTENSIONS_PERMISSIONS_HEADING);
1275 SET_STRING("extensionsPermissionsClose", IDS_EXTENSIONS_PERMISSIONS_CLOSE);
1276 SET_STRING("extensionDisabled", IDS_EXTENSIONS_DISABLED);
1277 SET_STRING("extensionSettingsShowLogsButton", IDS_EXTENSIONS_SHOW_LOGS);
1278 SET_STRING("extensionSettingsMoreDetailsButton", IDS_EXTENSIONS_MORE_DETAILS);
1279 SET_STRING("extensionSettingsVersion", IDS_EXTENSIONS_VERSION);
1280 SET_STRING("extensionSettingsDelete", IDS_EXTENSIONS_ADT_DELETE);
1281 SET_STRING("extensionSettingsPack", IDS_EXTENSIONS_PACK);
1282
1283 // Pack Extension strings
1284 SET_STRING("packExtensionOverlay", IDS_EXTENSION_PACK_DIALOG_TITLE);
1285 SET_STRING("packExtensionHeading", IDS_EXTENSION_ADT_PACK_DIALOG_HEADING);
1286 SET_STRING("packButton", IDS_EXTENSION_ADT_PACK_BUTTON);
1287 SET_STRING("ok", IDS_OK);
1288 SET_STRING("cancel", IDS_CANCEL);
1289 SET_STRING("packExtensionRootDir",
1290 IDS_EXTENSION_PACK_DIALOG_ROOT_DIRECTORY_LABEL);
1291 SET_STRING("packExtensionPrivateKey",
1292 IDS_EXTENSION_PACK_DIALOG_PRIVATE_KEY_LABEL);
1293 SET_STRING("packExtensionBrowseButton", IDS_EXTENSION_PACK_DIALOG_BROWSE);
1294 SET_STRING("packExtensionProceedAnyway", IDS_EXTENSION_PROCEED_ANYWAY);
1295 SET_STRING("packExtensionWarningTitle", IDS_EXTENSION_PACK_WARNING_TITLE);
1296 SET_STRING("packExtensionErrorTitle", IDS_EXTENSION_PACK_ERROR_TITLE);
1297 SET_STRING("packAppOverlay", IDS_EXTENSION_PACK_APP_DIALOG_TITLE);
1298 SET_STRING("packAppHeading", IDS_EXTENSION_ADT_PACK_APP_DIALOG_HEADING);
1299
1300 // Delete confirmation dialog.
1301 SET_STRING("deleteConfirmationDeleteButton",
1302 IDS_APPS_DEVTOOL_DELETE_CONFIRMATION_BUTTON);
1303 SET_STRING("deleteConfirmationTitle",
1304 IDS_APPS_DEVTOOL_DELETE_CONFIRMATION_TITLE);
1305 SET_STRING("deleteConfirmationMessageApp",
1306 IDS_APPS_DEVTOOL_DELETE_CONFIRMATION_MESSAGE_APP);
1307 SET_STRING("deleteConfirmationMessageExtension",
1308 IDS_APPS_DEVTOOL_DELETE_CONFIRMATION_MESSAGE_EXTENSION);
1309
1310 // Dialog when profile is managed.
1311 SET_STRING("managedProfileDialogCloseButton",
1312 IDS_APPS_DEVTOOL_MANAGED_PROFILE_DIALOG_CLOSE_BUTTON);
1313 SET_STRING("managedProfileDialogTitle",
1314 IDS_APPS_DEVTOOL_MANAGED_PROFILE_DIALOG_TITLE);
1315 SET_STRING("managedProfileDialogDescription",
1316 IDS_APPS_DEVTOOL_MANAGED_PROFILE_DIALOG_DESCRIPTION);
1317
1318 #undef SET_STRING
1319 return true;
1320 }
1321
1322 DeveloperPrivateGetStringsFunction::~DeveloperPrivateGetStringsFunction() {}
1323
1324 bool DeveloperPrivateIsProfileManagedFunction::RunImpl() { 1281 bool DeveloperPrivateIsProfileManagedFunction::RunImpl() {
1325 SetResult(new base::FundamentalValue(GetProfile()->IsManaged())); 1282 SetResult(new base::FundamentalValue(GetProfile()->IsManaged()));
1326 return true; 1283 return true;
1327 } 1284 }
1328 1285
1329 DeveloperPrivateIsProfileManagedFunction:: 1286 DeveloperPrivateIsProfileManagedFunction::
1330 ~DeveloperPrivateIsProfileManagedFunction() { 1287 ~DeveloperPrivateIsProfileManagedFunction() {
1331 } 1288 }
1332 1289
1290 DeveloperPrivateRequestFileSourceFunction::
1291 DeveloperPrivateRequestFileSourceFunction() {}
1292
1293 DeveloperPrivateRequestFileSourceFunction::
1294 ~DeveloperPrivateRequestFileSourceFunction() {}
1295
1296 bool DeveloperPrivateRequestFileSourceFunction::RunImpl() {
1297 scoped_ptr<developer::RequestFileSource::Params> params(
1298 developer::RequestFileSource::Params::Create(*args_));
1299 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
1300
1301 base::DictionaryValue* dict = NULL;
1302 if (!params->dict->GetAsDictionary(&dict)) {
1303 NOTREACHED();
1304 return false;
1305 }
1306
1307 AddRef(); // Balanced in LaunchCallback().
1308 error_ui_util::HandleRequestFileSource(
1309 dict,
1310 GetProfile(),
1311 base::Bind(&DeveloperPrivateRequestFileSourceFunction::LaunchCallback,
1312 base::Unretained(this)));
1313 return true;
1314 }
1315
1316 void DeveloperPrivateRequestFileSourceFunction::LaunchCallback(
1317 const base::DictionaryValue& results) {
1318 SetResult(results.DeepCopy());
1319 SendResponse(true);
1320 Release(); // Balanced in RunImpl().
1321 }
1322
1323 DeveloperPrivateOpenDevToolsFunction::DeveloperPrivateOpenDevToolsFunction() {}
1324 DeveloperPrivateOpenDevToolsFunction::~DeveloperPrivateOpenDevToolsFunction() {}
1325
1326 bool DeveloperPrivateOpenDevToolsFunction::RunImpl() {
1327 scoped_ptr<developer::OpenDevTools::Params> params(
1328 developer::OpenDevTools::Params::Create(*args_));
1329 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
1330
1331 base::DictionaryValue* dict = NULL;
1332 if (!params->dict->GetAsDictionary(&dict)) {
1333 NOTREACHED();
1334 return false;
1335 }
1336
1337 error_ui_util::HandleOpenDevTools(dict);
1338
1339 return true;
1340 }
1341
1333 } // namespace api 1342 } // namespace api
1334 1343
1335 } // namespace extensions 1344 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698