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

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

Issue 989813002: [Extensions] Make a chrome.developerPrivate.getExtensionsInfo function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/saved_files_service.h" 8 #include "apps/saved_files_service.h"
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_enumerator.h"
13 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
14 #include "base/i18n/file_util_icu.h"
15 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
16 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 17 #include "base/values.h"
20 #include "chrome/browser/devtools/devtools_window.h" 18 #include "chrome/browser/devtools/devtools_window.h"
19 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h"
21 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 20 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
21 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find er.h"
22 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 22 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
23 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 23 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
24 #include "chrome/browser/extensions/chrome_requirements_checker.h" 24 #include "chrome/browser/extensions/chrome_requirements_checker.h"
25 #include "chrome/browser/extensions/devtools_util.h" 25 #include "chrome/browser/extensions/devtools_util.h"
26 #include "chrome/browser/extensions/extension_disabled_ui.h"
27 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_service.h" 26 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_ui_util.h" 27 #include "chrome/browser/extensions/extension_ui_util.h"
30 #include "chrome/browser/extensions/extension_util.h" 28 #include "chrome/browser/extensions/extension_util.h"
29 #include "chrome/browser/extensions/path_util.h"
30 #include "chrome/browser/extensions/shared_module_service.h"
31 #include "chrome/browser/extensions/unpacked_installer.h" 31 #include "chrome/browser/extensions/unpacked_installer.h"
32 #include "chrome/browser/extensions/updater/extension_updater.h" 32 #include "chrome/browser/extensions/updater/extension_updater.h"
33 #include "chrome/browser/platform_util.h" 33 #include "chrome/browser/platform_util.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
36 #include "chrome/browser/ui/browser_finder.h" 35 #include "chrome/browser/ui/browser_finder.h"
37 #include "chrome/browser/ui/chrome_select_file_policy.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 36 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 37 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
40 #include "chrome/common/extensions/api/developer_private.h" 38 #include "chrome/common/extensions/api/developer_private.h"
41 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 39 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
42 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
43 #include "chrome/grit/generated_resources.h" 41 #include "chrome/grit/generated_resources.h"
44 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
47 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/site_instance.h" 46 #include "content/public/browser/site_instance.h"
49 #include "content/public/browser/storage_partition.h" 47 #include "content/public/browser/storage_partition.h"
50 #include "content/public/browser/web_contents.h" 48 #include "content/public/browser/web_contents.h"
51 #include "extensions/browser/api/device_permissions_manager.h" 49 #include "extensions/browser/api/device_permissions_manager.h"
52 #include "extensions/browser/app_window/app_window.h" 50 #include "extensions/browser/app_window/app_window.h"
53 #include "extensions/browser/app_window/app_window_registry.h" 51 #include "extensions/browser/app_window/app_window_registry.h"
54 #include "extensions/browser/extension_error.h" 52 #include "extensions/browser/extension_error.h"
55 #include "extensions/browser/extension_prefs.h" 53 #include "extensions/browser/extension_prefs.h"
56 #include "extensions/browser/extension_registry.h" 54 #include "extensions/browser/extension_registry.h"
57 #include "extensions/browser/extension_system.h" 55 #include "extensions/browser/extension_system.h"
58 #include "extensions/browser/file_highlighter.h" 56 #include "extensions/browser/file_highlighter.h"
59 #include "extensions/browser/management_policy.h" 57 #include "extensions/browser/management_policy.h"
60 #include "extensions/browser/notification_types.h" 58 #include "extensions/browser/notification_types.h"
61 #include "extensions/browser/view_type_utils.h" 59 #include "extensions/browser/warning_service.h"
62 #include "extensions/common/constants.h" 60 #include "extensions/common/constants.h"
63 #include "extensions/common/extension_resource.h" 61 #include "extensions/common/extension_resource.h"
64 #include "extensions/common/extension_set.h" 62 #include "extensions/common/extension_set.h"
63 #include "extensions/common/feature_switch.h"
65 #include "extensions/common/install_warning.h" 64 #include "extensions/common/install_warning.h"
66 #include "extensions/common/manifest.h" 65 #include "extensions/common/manifest.h"
67 #include "extensions/common/manifest_handlers/background_info.h" 66 #include "extensions/common/manifest_handlers/background_info.h"
68 #include "extensions/common/manifest_handlers/icons_handler.h" 67 #include "extensions/common/manifest_handlers/icons_handler.h"
69 #include "extensions/common/manifest_handlers/incognito_info.h" 68 #include "extensions/common/manifest_handlers/incognito_info.h"
70 #include "extensions/common/manifest_handlers/offline_enabled_info.h" 69 #include "extensions/common/manifest_handlers/offline_enabled_info.h"
71 #include "extensions/common/manifest_handlers/options_page_info.h" 70 #include "extensions/common/manifest_handlers/options_page_info.h"
72 #include "extensions/common/manifest_url_handlers.h" 71 #include "extensions/common/manifest_url_handlers.h"
73 #include "extensions/common/permissions/permissions_data.h" 72 #include "extensions/common/permissions/permissions_data.h"
74 #include "extensions/common/switches.h" 73 #include "extensions/common/switches.h"
75 #include "extensions/grit/extensions_browser_resources.h" 74 #include "extensions/grit/extensions_browser_resources.h"
76 #include "net/base/net_util.h" 75 #include "net/base/net_util.h"
77 #include "storage/browser/blob/shareable_file_reference.h"
78 #include "storage/browser/fileapi/external_mount_points.h" 76 #include "storage/browser/fileapi/external_mount_points.h"
79 #include "storage/browser/fileapi/file_system_context.h" 77 #include "storage/browser/fileapi/file_system_context.h"
80 #include "storage/browser/fileapi/file_system_operation.h" 78 #include "storage/browser/fileapi/file_system_operation.h"
81 #include "storage/browser/fileapi/file_system_operation_runner.h" 79 #include "storage/browser/fileapi/file_system_operation_runner.h"
82 #include "storage/browser/fileapi/isolated_context.h" 80 #include "storage/browser/fileapi/isolated_context.h"
83 #include "ui/base/l10n/l10n_util.h" 81 #include "ui/base/l10n/l10n_util.h"
84 #include "ui/base/resource/resource_bundle.h" 82 #include "ui/base/resource/resource_bundle.h"
85 #include "ui/base/webui/web_ui_util.h" 83 #include "ui/base/webui/web_ui_util.h"
86 84
87 using content::RenderViewHost;
88
89 namespace extensions { 85 namespace extensions {
90 86
91 namespace developer_private = api::developer_private; 87 namespace developer_private = api::developer_private;
92 88
93 namespace { 89 namespace {
94 90
95 const char kNoSuchExtensionError[] = "No such extension."; 91 const char kNoSuchExtensionError[] = "No such extension.";
96 const char kSupervisedUserError[] = 92 const char kSupervisedUserError[] =
97 "Supervised users cannot modify extension settings."; 93 "Supervised users cannot modify extension settings.";
98 const char kCannotModifyPolicyExtensionError[] = 94 const char kCannotModifyPolicyExtensionError[] =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // extensions::ImageLoader. Also a resize should be performed to avoid 146 // extensions::ImageLoader. Also a resize should be performed to avoid
151 // potential huge URLs: crbug/297298. 147 // potential huge URLs: crbug/297298.
152 GURL ToDataURL(const base::FilePath& path, developer_private::ItemType type) { 148 GURL ToDataURL(const base::FilePath& path, developer_private::ItemType type) {
153 std::string contents; 149 std::string contents;
154 if (path.empty() || !base::ReadFileToString(path, &contents)) 150 if (path.empty() || !base::ReadFileToString(path, &contents))
155 return GetDefaultImageURL(type); 151 return GetDefaultImageURL(type);
156 152
157 return GetImageURLFromData(contents); 153 return GetImageURLFromData(contents);
158 } 154 }
159 155
160 std::string GetExtensionID(const RenderViewHost* render_view_host) { 156 std::string GetExtensionID(const content::RenderViewHost* render_view_host) {
161 if (!render_view_host->GetSiteInstance()) 157 if (!render_view_host->GetSiteInstance())
162 return std::string(); 158 return std::string();
163 159
164 return render_view_host->GetSiteInstance()->GetSiteURL().host(); 160 return render_view_host->GetSiteInstance()->GetSiteURL().host();
165 } 161 }
166 162
167 void BroadcastItemStateChanged(content::BrowserContext* browser_context, 163 void BroadcastItemStateChanged(content::BrowserContext* browser_context,
168 developer::EventType event_type, 164 developer::EventType event_type,
169 const std::string& item_id) { 165 const std::string& item_id) {
170 developer::EventData event_data; 166 developer::EventData event_data;
171 event_data.event_type = event_type; 167 event_data.event_type = event_type;
172 event_data.item_id = item_id; 168 event_data.item_id = item_id;
173 169
174 scoped_ptr<base::ListValue> args(new base::ListValue()); 170 scoped_ptr<base::ListValue> args(new base::ListValue());
175 args->Append(event_data.ToValue().release()); 171 args->Append(event_data.ToValue().release());
176 scoped_ptr<Event> event(new Event( 172 scoped_ptr<Event> event(new Event(
177 developer_private::OnItemStateChanged::kEventName, args.Pass())); 173 developer_private::OnItemStateChanged::kEventName, args.Pass()));
178 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); 174 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass());
179 } 175 }
180 176
181 std::string ReadFileToString(const base::FilePath& path) { 177 std::string ReadFileToString(const base::FilePath& path) {
182 std::string data; 178 std::string data;
183 ignore_result(base::ReadFileToString(path, &data)); 179 ignore_result(base::ReadFileToString(path, &data));
184 return data; 180 return data;
185 } 181 }
186 182
183 // Populates the common fields of an extension error.
184 void PopulateErrorBase(const ExtensionError& error,
185 developer::ErrorBase* base) {
186 base->type = error.type() == ExtensionError::MANIFEST_ERROR ?
187 developer::ERROR_TYPE_MANIFEST : developer::ERROR_TYPE_RUNTIME;
188 base->extension_id = error.extension_id();
189 base->from_incognito = error.from_incognito();
190 base->source = base::UTF16ToUTF8(error.source());
191 base->message = base::UTF16ToUTF8(error.message());
192 }
193
194 // Given a ManifestError object, converts it into its developer_private
195 // counterpart.
196 linked_ptr<developer::ManifestError> ConstructManifestError(
197 const ManifestError& error) {
198 linked_ptr<developer::ManifestError> result(new developer::ManifestError());
199 PopulateErrorBase(error, &result->base);
200 result->manifest_key = base::UTF16ToUTF8(error.manifest_key());
201 if (!error.manifest_specific().empty()) {
202 result->manifest_specific.reset(
203 new std::string(base::UTF16ToUTF8(error.manifest_specific())));
204 }
205 return result;
206 }
207
208 // Given a RuntimeError object, converts it into its developer_private
209 // counterpart.
210 linked_ptr<developer::RuntimeError> ConstructRuntimeError(
211 const RuntimeError& error) {
212 linked_ptr<developer::RuntimeError> result(new developer::RuntimeError());
213 PopulateErrorBase(error, &result->base);
214 switch (error.level()) {
215 case logging::LOG_INFO:
216 result->severity = developer::ERROR_SEVERITY_LOG;
217 break;
218 case logging::LOG_WARNING:
219 result->severity = developer::ERROR_SEVERITY_WARN;
220 break;
221 case logging::LOG_ERROR:
222 result->severity = developer::ERROR_SEVERITY_ERROR;
223 break;
224 default:
225 NOTREACHED();
226 }
227 result->occurrences = error.occurrences();
228 result->render_view_id = error.render_view_id();
229 result->render_process_id = error.render_process_id();
230 result->can_inspect =
231 content::RenderViewHost::FromID(error.render_process_id(),
232 error.render_view_id()) != nullptr;
233 for (const StackFrame& f : error.stack_trace()) {
234 linked_ptr<developer::StackFrame> frame(new developer::StackFrame());
235 frame->line_number = f.line_number;
236 frame->column_number = f.column_number;
237 frame->source = base::UTF16ToUTF8(f.source);
238 frame->function = base::UTF16ToUTF8(f.function);
239 result->stack_trace.push_back(frame);
240 }
241 return result;
242 }
243
244 // Given a Manifest::Type, converts it into its developer_private
245 // counterpart.
246 developer::ExtensionType GetExtensionType(Manifest::Type manifest_type) {
247 developer::ExtensionType type = developer::EXTENSION_TYPE_EXTENSION;
248 switch (manifest_type) {
249 case Manifest::TYPE_EXTENSION:
250 type = developer::EXTENSION_TYPE_EXTENSION;
251 break;
252 case Manifest::TYPE_THEME:
253 type = developer::EXTENSION_TYPE_THEME;
254 break;
255 case Manifest::TYPE_HOSTED_APP:
256 type = developer::EXTENSION_TYPE_HOSTED_APP;
257 break;
258 case Manifest::TYPE_LEGACY_PACKAGED_APP:
259 type = developer::EXTENSION_TYPE_LEGACY_PACKAGED_APP;
260 break;
261 case Manifest::TYPE_PLATFORM_APP:
262 type = developer::EXTENSION_TYPE_PLATFORM_APP;
263 break;
264 case Manifest::TYPE_SHARED_MODULE:
265 type = developer::EXTENSION_TYPE_SHARED_MODULE;
266 break;
267 default:
268 NOTREACHED();
269 }
270 return type;
271 }
272
273 // Constructs information about a given |extension|.
274 scoped_ptr<developer::ExtensionInfo> CreateExtensionInfo(
275 const Extension& extension,
276 developer::ExtensionState state,
277 content::BrowserContext* browser_context) {
278 scoped_ptr<developer::ExtensionInfo> info(new developer::ExtensionInfo());
279
280 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context);
281 // Don't consider the button hidden with the redesign, because "hidden"
282 // buttons are now just hidden in the wrench menu.
283 info->action_button_hidden =
284 !ExtensionActionAPI::GetBrowserActionVisibility(prefs, extension.id()) &&
285 !FeatureSwitch::extension_action_redesign()->IsEnabled();
286
287 // Blacklist text.
288 int blacklist_text = -1;
289 switch (prefs->GetExtensionBlacklistState(extension.id())) {
290 case BLACKLISTED_SECURITY_VULNERABILITY:
291 blacklist_text = IDS_OPTIONS_BLACKLISTED_SECURITY_VULNERABILITY;
292 break;
293 case BLACKLISTED_CWS_POLICY_VIOLATION:
294 blacklist_text = IDS_OPTIONS_BLACKLISTED_CWS_POLICY_VIOLATION;
295 break;
296 case BLACKLISTED_POTENTIALLY_UNWANTED:
297 blacklist_text = IDS_OPTIONS_BLACKLISTED_POTENTIALLY_UNWANTED;
298 break;
299 default:
300 break;
301 }
302 if (blacklist_text != -1) {
303 info->blacklist_text.reset(
304 new std::string(l10n_util::GetStringUTF8(blacklist_text)));
305 }
306
307 // Dependent extensions.
308 if (extension.is_shared_module()) {
309 scoped_ptr<ExtensionSet> dependent_extensions =
310 ExtensionSystem::Get(browser_context)->extension_service()->
311 shared_module_service()->GetDependentExtensions(&extension);
312 for (const scoped_refptr<const Extension>& dependent :
313 *dependent_extensions)
314 info->dependent_extensions.push_back(dependent->id());
315 }
316
317 info->description = extension.description();
318
319 // Disable reasons.
320 int disable_reasons = prefs->GetDisableReasons(extension.id());
321 info->disable_reasons.suspicious_install =
322 (disable_reasons & Extension::DISABLE_NOT_VERIFIED) != 0;
323 info->disable_reasons.corrupt_install =
324 (disable_reasons & Extension::DISABLE_CORRUPTED) != 0;
325 info->disable_reasons.update_required =
326 (disable_reasons & Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY) != 0;
327
328 // Error collection.
329 Profile* profile = Profile::FromBrowserContext(browser_context);
330 ErrorConsole* error_console = ErrorConsole::Get(profile);
331 bool error_console_enabled =
332 error_console->IsEnabledForChromeExtensionsPage();
333 info->error_collection.is_enabled = error_console_enabled;
334 info->error_collection.is_active =
335 error_console_enabled &&
336 error_console->IsReportingEnabledForExtension(extension.id());
337
338 // File access.
339 info->file_access.is_enabled = extension.wants_file_access();
340 info->file_access.is_active =
341 util::AllowFileAccess(extension.id(), browser_context);
342
343 // Home page.
344 info->home_page.url = ManifestURL::GetHomepageURL(&extension).spec();
345 info->home_page.specified = ManifestURL::SpecifiedHomepageURL(&extension);
346
347 bool is_enabled = state == developer::EXTENSION_STATE_ENABLED;
348
349 // TODO(devlin): This won't work with apps (CORS).
not at google - send to devlin 2015/03/11 17:43:05 We should convert to data URLs.
Devlin 2015/03/11 21:45:53 Yep, I know. Updated the TODO to be more specific.
350 info->icon_url =
351 ExtensionIconSource::GetIconURL(&extension,
352 extension_misc::EXTENSION_ICON_MEDIUM,
353 ExtensionIconSet::MATCH_BIGGER,
354 !is_enabled,
355 nullptr).spec();
356
357 info->id = extension.id();
358
359 // Incognito access.
360 info->incognito_access.is_enabled = extension.can_be_incognito_enabled();
361 info->incognito_access.is_active =
362 util::IsIncognitoEnabled(extension.id(), browser_context);
363
364 info->installed_by_custodian =
365 util::IsExtensionSupervised(&extension, profile);
366
367 // Install warnings (only if unpacked and no error console).
368 if (!error_console_enabled &&
369 Manifest::IsUnpackedLocation(extension.location())) {
370 const std::vector<InstallWarning>& install_warnings =
371 extension.install_warnings();
372 for (const InstallWarning& warning : install_warnings)
373 info->install_warnings.push_back(warning.message);
374 }
375
376 // Launch url.
377 if (extension.is_app()) {
378 info->launch_url.reset(
379 new std::string(AppLaunchInfo::GetFullLaunchURL(&extension).spec()));
380 }
381
382 // Location.
383 if (extension.location() == Manifest::INTERNAL &&
384 ManifestURL::UpdatesFromGallery(&extension)) {
385 info->location = developer::LOCATION_FROM_STORE;
386 } else if (Manifest::IsUnpackedLocation(extension.location())) {
387 info->location = developer::LOCATION_UNPACKED;
388 } else {
389 info->location = developer::LOCATION_UNKNOWN;
390 }
391
392 // Location text.
393 int location_text = -1;
394 if (info->location == developer::LOCATION_UNKNOWN)
395 location_text = IDS_OPTIONS_INSTALL_LOCATION_UNKNOWN;
396 else if (extension.location() == Manifest::EXTERNAL_REGISTRY)
397 location_text = IDS_OPTIONS_INSTALL_LOCATION_3RD_PARTY;
398 else if (extension.is_shared_module())
399 location_text = IDS_OPTIONS_INSTALL_LOCATION_SHARED_MODULE;
400 if (location_text != -1) {
401 info->location_text.reset(
402 new std::string(l10n_util::GetStringUTF8(location_text)));
403 }
404
405 // Runtime/Manifest errors.
406 if (error_console_enabled) {
407 const ErrorList& errors =
408 error_console->GetErrorsForExtension(extension.id());
409 for (const ExtensionError* error : errors) {
410 switch (error->type()) {
411 case ExtensionError::MANIFEST_ERROR:
412 info->manifest_errors.push_back(ConstructManifestError(
413 static_cast<const ManifestError&>(*error)));
414 break;
415 case ExtensionError::RUNTIME_ERROR:
416 info->runtime_errors.push_back(ConstructRuntimeError(
417 static_cast<const RuntimeError&>(*error)));
418 break;
419 case ExtensionError::NUM_ERROR_TYPES:
420 NOTREACHED();
421 break;
422 }
423 }
424 }
425
426 ManagementPolicy* management_policy =
427 ExtensionSystem::Get(browser_context)->management_policy();
428 info->must_remain_installed =
429 management_policy->MustRemainInstalled(&extension, nullptr);
430
431 info->name = extension.name();
432 info->offline_enabled = OfflineEnabledInfo::IsOfflineEnabled(&extension);
433
434 // Options page.
435 if (OptionsPageInfo::HasOptionsPage(&extension)) {
436 info->options_page.reset(new developer::OptionsPage());
437 info->options_page->open_in_tab =
438 OptionsPageInfo::ShouldOpenInTab(&extension);
439 info->options_page->url =
440 OptionsPageInfo::GetOptionsPage(&extension).spec();
441 }
442
443 // Path.
444 if (Manifest::IsUnpackedLocation(extension.location())) {
445 info->path.reset(new std::string(extension.path().AsUTF8Unsafe()));
446 info->prettified_path.reset(new std::string(
447 extensions::path_util::PrettifyPath(extension.path()).AsUTF8Unsafe()));
448 }
449
450 if (Manifest::IsPolicyLocation(extension.location())) {
451 info->policy_text.reset(new std::string(
452 l10n_util::GetStringUTF8(IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE)));
453 }
454
455 // Runs on all urls.
456 info->run_on_all_urls.is_enabled =
457 (FeatureSwitch::scripts_require_action()->IsEnabled() &&
458 PermissionsData::ScriptsMayRequireActionForExtension(
459 &extension,
460 extension.permissions_data()->active_permissions().get())) ||
461 extension.permissions_data()->HasWithheldImpliedAllHosts() ||
462 util::HasSetAllowedScriptingOnAllUrls(extension.id(), browser_context);
463 info->run_on_all_urls.is_active =
464 util::AllowedScriptingOnAllUrls(extension.id(), browser_context);
465
466 // Runtime warnings.
467 WarningService* warning_service = WarningService::Get(profile);
468 std::vector<std::string> warnings =
469 warning_service->GetWarningMessagesForExtension(extension.id());
470 for (const std::string& warning : warnings)
471 info->runtime_warnings.push_back(warning);
472
473 info->state = state;
474
475 info->type = GetExtensionType(extension.manifest()->type());
476
477 info->update_url = ManifestURL::GetUpdateURL(&extension).spec();
478
479 info->user_may_modify =
480 management_policy->UserMayModifySettings(&extension, nullptr);
481
482 info->version = extension.GetVersionForDisplay();
483
484 if (state != developer::EXTENSION_STATE_TERMINATED) {
485 info->views = InspectableViewsFinder(profile, nullptr).
486 GetViewsForExtension(extension, is_enabled);
487 }
488 return info.Pass();
489 }
490
491 std::vector<linked_ptr<developer::ExtensionInfo>> GetExtensionsInfo(
492 content::BrowserContext* context,
493 bool include_disabled,
494 bool include_terminated) {
495 std::vector<linked_ptr<developer::ExtensionInfo>> list;
496 auto add_to_list = [&list, context](const ExtensionSet& extensions,
497 developer::ExtensionState state) {
498 for (const scoped_refptr<const Extension>& extension : extensions) {
499 if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), context)) {
500 scoped_ptr<developer::ExtensionInfo> info =
501 CreateExtensionInfo(*extension, state, context);
502 list.push_back(make_linked_ptr(info.release()));
503 }
504 }
505 };
506
507 ExtensionRegistry* registry = ExtensionRegistry::Get(context);
508 add_to_list(registry->enabled_extensions(),
509 developer::EXTENSION_STATE_ENABLED);
510 if (include_disabled) {
511 add_to_list(registry->disabled_extensions(),
512 developer::EXTENSION_STATE_DISABLED);
513 }
514 if (include_terminated) {
515 add_to_list(registry->terminated_extensions(),
516 developer::EXTENSION_STATE_TERMINATED);
517 }
518
519 return list;
520 }
521
187 } // namespace 522 } // namespace
188 523
189 namespace AllowFileAccess = api::developer_private::AllowFileAccess; 524 namespace AllowFileAccess = api::developer_private::AllowFileAccess;
190 namespace AllowIncognito = api::developer_private::AllowIncognito; 525 namespace AllowIncognito = api::developer_private::AllowIncognito;
191 namespace ChoosePath = api::developer_private::ChoosePath; 526 namespace ChoosePath = api::developer_private::ChoosePath;
192 namespace GetItemsInfo = api::developer_private::GetItemsInfo; 527 namespace GetItemsInfo = api::developer_private::GetItemsInfo;
193 namespace Inspect = api::developer_private::Inspect; 528 namespace Inspect = api::developer_private::Inspect;
194 namespace PackDirectory = api::developer_private::PackDirectory; 529 namespace PackDirectory = api::developer_private::PackDirectory;
195 namespace Reload = api::developer_private::Reload; 530 namespace Reload = api::developer_private::Reload;
196 531
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const content::NotificationDetails& details) { 584 const content::NotificationDetails& details) {
250 Profile* profile = content::Source<Profile>(source).ptr(); 585 Profile* profile = content::Source<Profile>(source).ptr();
251 CHECK(profile); 586 CHECK(profile);
252 CHECK(profile_->IsSameProfile(profile)); 587 CHECK(profile_->IsSameProfile(profile));
253 developer::EventData event_data; 588 developer::EventData event_data;
254 589
255 switch (type) { 590 switch (type) {
256 case extensions::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED: { 591 case extensions::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED: {
257 event_data.event_type = developer::EVENT_TYPE_VIEW_UNREGISTERED; 592 event_data.event_type = developer::EVENT_TYPE_VIEW_UNREGISTERED;
258 event_data.item_id = GetExtensionID( 593 event_data.item_id = GetExtensionID(
259 content::Details<const RenderViewHost>(details).ptr()); 594 content::Details<const content::RenderViewHost>(details).ptr());
260 break; 595 break;
261 } 596 }
262 case extensions::NOTIFICATION_EXTENSION_VIEW_REGISTERED: { 597 case extensions::NOTIFICATION_EXTENSION_VIEW_REGISTERED: {
263 event_data.event_type = developer::EVENT_TYPE_VIEW_REGISTERED; 598 event_data.event_type = developer::EVENT_TYPE_VIEW_REGISTERED;
264 event_data.item_id = GetExtensionID( 599 event_data.item_id = GetExtensionID(
265 content::Details<const RenderViewHost>(details).ptr()); 600 content::Details<const content::RenderViewHost>(details).ptr());
266 break; 601 break;
267 } 602 }
268 default: 603 default:
269 NOTREACHED(); 604 NOTREACHED();
270 return; 605 return;
271 } 606 }
272 607
273 BroadcastItemStateChanged(profile, event_data.event_type, event_data.item_id); 608 BroadcastItemStateChanged(profile, event_data.event_type, event_data.item_id);
274 } 609 }
275 610
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 bool DeveloperPrivateAutoUpdateFunction::RunSync() { 703 bool DeveloperPrivateAutoUpdateFunction::RunSync() {
369 ExtensionUpdater* updater = GetExtensionUpdater(GetProfile()); 704 ExtensionUpdater* updater = GetExtensionUpdater(GetProfile());
370 if (updater) 705 if (updater)
371 updater->CheckNow(ExtensionUpdater::CheckParams()); 706 updater->CheckNow(ExtensionUpdater::CheckParams());
372 SetResult(new base::FundamentalValue(true)); 707 SetResult(new base::FundamentalValue(true));
373 return true; 708 return true;
374 } 709 }
375 710
376 DeveloperPrivateAutoUpdateFunction::~DeveloperPrivateAutoUpdateFunction() {} 711 DeveloperPrivateAutoUpdateFunction::~DeveloperPrivateAutoUpdateFunction() {}
377 712
378 scoped_ptr<developer::ItemInfo> 713 DeveloperPrivateGetExtensionsInfoFunction::
379 DeveloperPrivateGetItemsInfoFunction::CreateItemInfo(const Extension& item, 714 ~DeveloperPrivateGetExtensionsInfoFunction() {
380 bool item_is_enabled) { 715 }
381 scoped_ptr<developer::ItemInfo> info(new developer::ItemInfo());
382 716
383 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); 717 ExtensionFunction::ResponseAction
384 ExtensionService* service = system->extension_service(); 718 DeveloperPrivateGetExtensionsInfoFunction::Run() {
385 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); 719 scoped_ptr<developer::GetExtensionsInfo::Params> params(
720 developer::GetExtensionsInfo::Params::Create(*args_));
721 EXTENSION_FUNCTION_VALIDATE(params);
386 722
387 info->id = item.id(); 723 bool include_disabled = true;
388 info->name = item.name(); 724 bool include_terminated = true;
389 info->enabled = service->IsExtensionEnabled(info->id); 725 if (params->options) {
390 info->offline_enabled = OfflineEnabledInfo::IsOfflineEnabled(&item); 726 if (params->options->include_disabled)
391 info->version = item.VersionString(); 727 include_disabled = *params->options->include_disabled;
392 info->description = item.description(); 728 if (params->options->include_terminated)
393 729 include_terminated = *params->options->include_terminated;
394 if (item.is_app()) {
395 if (item.is_legacy_packaged_app())
396 info->type = developer::ITEM_TYPE_LEGACY_PACKAGED_APP;
397 else if (item.is_hosted_app())
398 info->type = developer::ITEM_TYPE_HOSTED_APP;
399 else if (item.is_platform_app())
400 info->type = developer::ITEM_TYPE_PACKAGED_APP;
401 else
402 NOTREACHED();
403 } else if (item.is_theme()) {
404 info->type = developer::ITEM_TYPE_THEME;
405 } else if (item.is_extension()) {
406 info->type = developer::ITEM_TYPE_EXTENSION;
407 } else {
408 NOTREACHED();
409 } 730 }
410 731
411 if (Manifest::IsUnpackedLocation(item.location())) { 732 std::vector<linked_ptr<developer::ExtensionInfo>> list =
412 info->path.reset( 733 GetExtensionsInfo(browser_context(),
413 new std::string(base::UTF16ToUTF8(item.path().LossyDisplayName()))); 734 include_disabled,
414 // If the ErrorConsole is enabled and the extension is unpacked, use the 735 include_terminated);
415 // more detailed errors from the ErrorConsole. Otherwise, use the install 736
416 // warnings (using both is redundant). 737 return RespondNow(ArgumentList(
417 ErrorConsole* error_console = ErrorConsole::Get(GetProfile()); 738 developer::GetExtensionsInfo::Results::Create(list)));
418 if (error_console->IsEnabledForAppsDeveloperTools() && 739 }
419 item.location() == Manifest::UNPACKED) { 740
420 const ErrorList& errors = error_console->GetErrorsForExtension(item.id()); 741 DeveloperPrivateGetExtensionInfoFunction::
421 if (!errors.empty()) { 742 ~DeveloperPrivateGetExtensionInfoFunction() {
422 for (ErrorList::const_iterator iter = errors.begin(); 743 }
423 iter != errors.end(); 744
424 ++iter) { 745 ExtensionFunction::ResponseAction
425 switch ((*iter)->type()) { 746 DeveloperPrivateGetExtensionInfoFunction::Run() {
426 case ExtensionError::MANIFEST_ERROR: 747 scoped_ptr<developer::GetExtensionInfo::Params> params(
427 info->manifest_errors.push_back( 748 developer::GetExtensionInfo::Params::Create(*args_));
428 make_linked_ptr((*iter)->ToValue().release())); 749 EXTENSION_FUNCTION_VALIDATE(params);
429 break; 750
430 case ExtensionError::RUNTIME_ERROR: { 751 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
431 const RuntimeError* error = 752 developer::ExtensionState state = developer::EXTENSION_STATE_ENABLED;
432 static_cast<const RuntimeError*>(*iter); 753 const Extension* extension =
433 scoped_ptr<base::DictionaryValue> value = error->ToValue(); 754 registry->enabled_extensions().GetByID(params->id);
434 bool can_inspect = content::RenderViewHost::FromID( 755 if (!extension &&
435 error->render_process_id(), 756 (extension = registry->disabled_extensions().GetByID(params->id))) {
436 error->render_view_id()) != NULL; 757 state = developer::EXTENSION_STATE_DISABLED;
437 value->SetBoolean("canInspect", can_inspect); 758 } else if (!extension &&
438 info->runtime_errors.push_back(make_linked_ptr(value.release())); 759 (extension =
439 break; 760 registry->terminated_extensions().GetByID(params->id))) {
440 } 761 state = developer::EXTENSION_STATE_TERMINATED;
441 case ExtensionError::NUM_ERROR_TYPES: 762 } else {
442 NOTREACHED(); 763 return RespondNow(Error(kNoSuchExtensionError));
443 break; 764 }
444 } 765
445 } 766 return RespondNow(OneArgument(CreateExtensionInfo(
446 } 767 *extension, state, browser_context())->ToValue().release()));
447 } else { 768 }
448 for (std::vector<InstallWarning>::const_iterator it = 769
449 item.install_warnings().begin(); 770 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {}
450 it != item.install_warnings().end(); 771 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {}
451 ++it) { 772
452 scoped_ptr<developer::InstallWarning> warning( 773 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() {
453 new developer::InstallWarning); 774 scoped_ptr<developer::GetItemsInfo::Params> params(
454 warning->message = it->message; 775 developer::GetItemsInfo::Params::Create(*args_));
455 info->install_warnings.push_back(make_linked_ptr(warning.release())); 776 EXTENSION_FUNCTION_VALIDATE(params);
456 } 777
778 ExtensionSet items;
779 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
780 items.InsertAll(registry->enabled_extensions());
781
782 if (params->include_disabled)
783 items.InsertAll(registry->disabled_extensions());
784 if (params->include_terminated)
785 items.InsertAll(registry->terminated_extensions());
786
787 std::map<std::string, ExtensionResource> resource_map;
788 for (const scoped_refptr<const Extension>& item : items) {
789 // Don't show component extensions and invisible apps.
790 if (ui_util::ShouldDisplayInExtensionSettings(item.get(),
791 browser_context())) {
792 resource_map[item->id()] =
793 IconsInfo::GetIconResource(item.get(),
794 extension_misc::EXTENSION_ICON_MEDIUM,
795 ExtensionIconSet::MATCH_BIGGER);
not at google - send to devlin 2015/03/11 17:43:05 All of this data population is... incredibly hard
Devlin 2015/03/11 21:45:53 Yeah, I had the same dilemma when writing it.
457 } 796 }
458 } 797 }
459 798
460 info->incognito_enabled = util::IsIncognitoEnabled(item.id(), GetProfile()); 799 std::vector<linked_ptr<developer::ExtensionInfo>> list =
461 info->wants_file_access = item.wants_file_access(); 800 GetExtensionsInfo(browser_context(),
462 info->allow_file_access = util::AllowFileAccess(item.id(), GetProfile()); 801 params->include_disabled,
463 info->allow_reload = Manifest::IsUnpackedLocation(item.location()); 802 params->include_terminated);
464 info->is_unpacked = Manifest::IsUnpackedLocation(item.location());
465 info->terminated = registry->terminated_extensions().Contains(item.id());
466 info->allow_incognito = item.can_be_incognito_enabled();
467 803
468 info->homepage_url.reset(new std::string( 804 for (const linked_ptr<developer::ExtensionInfo>& info : list)
469 ManifestURL::GetHomepageURL(&item).spec())); 805 item_list_.push_back(developer_private_mangle::MangleExtensionInfo(*info));
470 if (!OptionsPageInfo::GetOptionsPage(&item).is_empty()) {
471 info->options_url.reset(
472 new std::string(OptionsPageInfo::GetOptionsPage(&item).spec()));
473 }
474 806
475 if (!ManifestURL::GetUpdateURL(&item).is_empty()) { 807 content::BrowserThread::PostTask(
476 info->update_url.reset( 808 content::BrowserThread::FILE,
477 new std::string(ManifestURL::GetUpdateURL(&item).spec())); 809 FROM_HERE,
478 } 810 base::Bind(&DeveloperPrivateGetItemsInfoFunction::GetIconsOnFileThread,
811 this,
812 resource_map));
479 813
480 if (item.is_app()) { 814 return RespondLater();
481 info->app_launch_url.reset(
482 new std::string(AppLaunchInfo::GetFullLaunchURL(&item).spec()));
483 }
484
485 info->may_disable = system->management_policy()->
486 UserMayModifySettings(&item, NULL);
487 info->is_app = item.is_app();
488 info->views = GetInspectablePagesForExtension(&item, item_is_enabled);
489
490 return info.Pass();
491 } 815 }
492 816
493 void DeveloperPrivateGetItemsInfoFunction::GetIconsOnFileThread( 817 void DeveloperPrivateGetItemsInfoFunction::GetIconsOnFileThread(
494 ItemInfoList item_list, 818 const std::map<std::string, ExtensionResource> resource_map) {
495 const std::map<std::string, ExtensionResource> idToIcon) { 819 for (const linked_ptr<developer::ItemInfo>& item : item_list_) {
496 for (ItemInfoList::iterator iter = item_list.begin(); 820 auto resource = resource_map.find(item->id);
497 iter != item_list.end(); ++iter) { 821 if (resource != resource_map.end()) {
498 developer_private::ItemInfo* info = iter->get(); 822 item->icon_url = ToDataURL(resource->second.GetFilePath(),
499 std::map<std::string, ExtensionResource>::const_iterator resource_ptr 823 item->type).spec();
500 = idToIcon.find(info->id);
501 if (resource_ptr != idToIcon.end()) {
502 info->icon_url =
503 ToDataURL(resource_ptr->second.GetFilePath(), info->type).spec();
504 } 824 }
505 } 825 }
506 826
507 results_ = developer::GetItemsInfo::Results::Create(item_list); 827 content::BrowserThread::PostTask(
508 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 828 content::BrowserThread::UI,
509 base::Bind(&DeveloperPrivateGetItemsInfoFunction::SendResponse, 829 FROM_HERE,
510 this, 830 base::Bind(&DeveloperPrivateGetItemsInfoFunction::Finish, this));
511 true));
512 } 831 }
513 832
514 void DeveloperPrivateGetItemsInfoFunction:: 833 void DeveloperPrivateGetItemsInfoFunction::Finish() {
515 GetInspectablePagesForExtensionProcess( 834 Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list_)));
516 const Extension* extension,
517 const std::set<content::RenderViewHost*>& views,
518 ItemInspectViewList* result) {
519 bool has_generated_background_page =
520 BackgroundInfo::HasGeneratedBackgroundPage(extension);
521 for (std::set<content::RenderViewHost*>::const_iterator iter = views.begin();
522 iter != views.end(); ++iter) {
523 content::RenderViewHost* host = *iter;
524 content::WebContents* web_contents =
525 content::WebContents::FromRenderViewHost(host);
526 ViewType host_type = GetViewType(web_contents);
527 if (VIEW_TYPE_EXTENSION_POPUP == host_type ||
528 VIEW_TYPE_EXTENSION_DIALOG == host_type)
529 continue;
530
531 content::RenderProcessHost* process = host->GetProcess();
532 bool is_background_page =
533 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension));
534 result->push_back(constructInspectView(
535 web_contents->GetURL(),
536 process->GetID(),
537 host->GetRoutingID(),
538 process->GetBrowserContext()->IsOffTheRecord(),
539 is_background_page && has_generated_background_page));
540 }
541 } 835 }
542 836
543 void DeveloperPrivateGetItemsInfoFunction::GetAppWindowPagesForExtensionProfile(
544 const Extension* extension,
545 ItemInspectViewList* result) {
546 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile());
547 if (!registry) return;
548
549 const AppWindowRegistry::AppWindowList windows =
550 registry->GetAppWindowsForApp(extension->id());
551
552 bool has_generated_background_page =
553 BackgroundInfo::HasGeneratedBackgroundPage(extension);
554 for (AppWindowRegistry::const_iterator it = windows.begin();
555 it != windows.end();
556 ++it) {
557 content::WebContents* web_contents = (*it)->web_contents();
558 RenderViewHost* host = web_contents->GetRenderViewHost();
559 content::RenderProcessHost* process = host->GetProcess();
560 bool is_background_page =
561 (web_contents->GetURL() == BackgroundInfo::GetBackgroundURL(extension));
562 result->push_back(constructInspectView(
563 web_contents->GetURL(),
564 process->GetID(),
565 host->GetRoutingID(),
566 process->GetBrowserContext()->IsOffTheRecord(),
567 is_background_page && has_generated_background_page));
568 }
569 }
570
571 linked_ptr<developer::ItemInspectView> DeveloperPrivateGetItemsInfoFunction::
572 constructInspectView(
573 const GURL& url,
574 int render_process_id,
575 int render_view_id,
576 bool incognito,
577 bool generated_background_page) {
578 linked_ptr<developer::ItemInspectView> view(new developer::ItemInspectView());
579
580 if (url.scheme() == kExtensionScheme) {
581 // No leading slash.
582 view->path = url.path().substr(1);
583 } else {
584 // For live pages, use the full URL.
585 view->path = url.spec();
586 }
587
588 view->render_process_id = render_process_id;
589 view->render_view_id = render_view_id;
590 view->incognito = incognito;
591 view->generated_background_page = generated_background_page;
592 return view;
593 }
594
595 ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
596 GetInspectablePagesForExtension(
597 const Extension* extension,
598 bool extension_is_enabled) {
599 ItemInspectViewList result;
600 // Get the extension process's active views.
601 ProcessManager* process_manager = ProcessManager::Get(GetProfile());
602 GetInspectablePagesForExtensionProcess(
603 extension,
604 process_manager->GetRenderViewHostsForExtension(extension->id()),
605 &result);
606
607 // Get app window views.
608 GetAppWindowPagesForExtensionProfile(extension, &result);
609
610 // Include a link to start the lazy background page, if applicable.
611 if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
612 extension_is_enabled &&
613 !process_manager->GetBackgroundHostForExtension(extension->id())) {
614 result.push_back(constructInspectView(
615 BackgroundInfo::GetBackgroundURL(extension),
616 -1,
617 -1,
618 false,
619 BackgroundInfo::HasGeneratedBackgroundPage(extension)));
620 }
621
622 ExtensionService* service = GetExtensionService(GetProfile());
623 // Repeat for the incognito process, if applicable. Don't try to get
624 // app windows for incognito process.
625 if (service->profile()->HasOffTheRecordProfile() &&
626 IncognitoInfo::IsSplitMode(extension)) {
627 process_manager =
628 ProcessManager::Get(service->profile()->GetOffTheRecordProfile());
629 GetInspectablePagesForExtensionProcess(
630 extension,
631 process_manager->GetRenderViewHostsForExtension(extension->id()),
632 &result);
633
634 if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
635 extension_is_enabled &&
636 !process_manager->GetBackgroundHostForExtension(extension->id())) {
637 result.push_back(constructInspectView(
638 BackgroundInfo::GetBackgroundURL(extension),
639 -1,
640 -1,
641 false,
642 BackgroundInfo::HasGeneratedBackgroundPage(extension)));
643 }
644 }
645
646 return result;
647 }
648
649 bool DeveloperPrivateGetItemsInfoFunction::RunAsync() {
650 scoped_ptr<developer::GetItemsInfo::Params> params(
651 developer::GetItemsInfo::Params::Create(*args_));
652 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
653
654 bool include_disabled = params->include_disabled;
655 bool include_terminated = params->include_terminated;
656
657 ExtensionSet items;
658
659 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
660
661 items.InsertAll(registry->enabled_extensions());
662
663 if (include_disabled) {
664 items.InsertAll(registry->disabled_extensions());
665 }
666
667 if (include_terminated) {
668 items.InsertAll(registry->terminated_extensions());
669 }
670
671 ExtensionService* service =
672 ExtensionSystem::Get(GetProfile())->extension_service();
673 std::map<std::string, ExtensionResource> id_to_icon;
674 ItemInfoList item_list;
675
676 for (ExtensionSet::const_iterator iter = items.begin(); iter != items.end();
677 ++iter) {
678 const Extension& item = *iter->get();
679
680 ExtensionResource item_resource =
681 IconsInfo::GetIconResource(&item,
682 extension_misc::EXTENSION_ICON_MEDIUM,
683 ExtensionIconSet::MATCH_BIGGER);
684 id_to_icon[item.id()] = item_resource;
685
686 // Don't show component extensions and invisible apps.
687 if (ui_util::ShouldNotBeVisible(&item, GetProfile()))
688 continue;
689
690 item_list.push_back(make_linked_ptr<developer::ItemInfo>(
691 CreateItemInfo(
692 item, service->IsExtensionEnabled(item.id())).release()));
693 }
694
695 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
696 base::Bind(&DeveloperPrivateGetItemsInfoFunction::GetIconsOnFileThread,
697 this,
698 item_list,
699 id_to_icon));
700
701 return true;
702 }
703
704 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {}
705
706 ExtensionFunction::ResponseAction 837 ExtensionFunction::ResponseAction
707 DeveloperPrivateAllowFileAccessFunction::Run() { 838 DeveloperPrivateAllowFileAccessFunction::Run() {
708 scoped_ptr<AllowFileAccess::Params> params( 839 scoped_ptr<AllowFileAccess::Params> params(
709 AllowFileAccess::Params::Create(*args_)); 840 AllowFileAccess::Params::Create(*args_));
710 EXTENSION_FUNCTION_VALIDATE(params.get()); 841 EXTENSION_FUNCTION_VALIDATE(params.get());
711 842
712 const Extension* extension = GetExtensionById(params->extension_id); 843 const Extension* extension = GetExtensionById(params->extension_id);
713 844
714 if (!extension) 845 if (!extension)
715 return RespondNow(Error(kNoSuchExtensionError)); 846 return RespondNow(Error(kNoSuchExtensionError));
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 1593
1463 TabStripModel* tab_strip = browser->tab_strip_model(); 1594 TabStripModel* tab_strip = browser->tab_strip_model();
1464 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), 1595 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents),
1465 false); // Not through direct user gesture. 1596 false); // Not through direct user gesture.
1466 return RespondNow(NoArguments()); 1597 return RespondNow(NoArguments());
1467 } 1598 }
1468 1599
1469 } // namespace api 1600 } // namespace api
1470 1601
1471 } // namespace extensions 1602 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698