| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_info_generat
or.h" | 5 #include "chrome/browser/extensions/api/developer_private/extension_info_generat
or.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" | 9 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" |
| 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 blacklist_text = IDS_OPTIONS_BLACKLISTED_POTENTIALLY_UNWANTED; | 250 blacklist_text = IDS_OPTIONS_BLACKLISTED_POTENTIALLY_UNWANTED; |
| 251 break; | 251 break; |
| 252 default: | 252 default: |
| 253 break; | 253 break; |
| 254 } | 254 } |
| 255 if (blacklist_text != -1) { | 255 if (blacklist_text != -1) { |
| 256 info->blacklist_text.reset( | 256 info->blacklist_text.reset( |
| 257 new std::string(l10n_util::GetStringUTF8(blacklist_text))); | 257 new std::string(l10n_util::GetStringUTF8(blacklist_text))); |
| 258 } | 258 } |
| 259 | 259 |
| 260 Profile* profile = Profile::FromBrowserContext(browser_context_); |
| 261 |
| 262 if (Manifest::IsPolicyLocation(extension.location())) { |
| 263 info->controlled_by.reset(new std::string("policy")); |
| 264 info->controlled_by_text.reset(new std::string( |
| 265 l10n_util::GetStringUTF8(IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE))); |
| 266 } else if (util::IsExtensionSupervised(&extension, profile)) { |
| 267 if (profile->IsChild()) { |
| 268 info->controlled_by.reset(new std::string("child-custodian")); |
| 269 info->controlled_by_text.reset(new std::string(l10n_util::GetStringUTF8( |
| 270 IDS_EXTENSIONS_INSTALLED_BY_CHILD_CUSTODIAN))); |
| 271 } else { |
| 272 info->controlled_by.reset(new std::string("supervised-user-custodian")); |
| 273 info->controlled_by_text.reset(new std::string(l10n_util::GetStringUTF8( |
| 274 IDS_EXTENSIONS_INSTALLED_BY_SUPERVISED_USER_CUSTODIAN))); |
| 275 } |
| 276 } |
| 277 |
| 260 // Dependent extensions. | 278 // Dependent extensions. |
| 261 if (extension.is_shared_module()) { | 279 if (extension.is_shared_module()) { |
| 262 scoped_ptr<ExtensionSet> dependent_extensions = | 280 scoped_ptr<ExtensionSet> dependent_extensions = |
| 263 extension_system_->extension_service()-> | 281 extension_system_->extension_service()-> |
| 264 shared_module_service()->GetDependentExtensions(&extension); | 282 shared_module_service()->GetDependentExtensions(&extension); |
| 265 for (const scoped_refptr<const Extension>& dependent : | 283 for (const scoped_refptr<const Extension>& dependent : |
| 266 *dependent_extensions) | 284 *dependent_extensions) |
| 267 info->dependent_extensions.push_back(dependent->id()); | 285 info->dependent_extensions.push_back(dependent->id()); |
| 268 } | 286 } |
| 269 | 287 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 295 info->home_page.url = ManifestURL::GetHomepageURL(&extension).spec(); | 313 info->home_page.url = ManifestURL::GetHomepageURL(&extension).spec(); |
| 296 info->home_page.specified = ManifestURL::SpecifiedHomepageURL(&extension); | 314 info->home_page.specified = ManifestURL::SpecifiedHomepageURL(&extension); |
| 297 | 315 |
| 298 info->id = extension.id(); | 316 info->id = extension.id(); |
| 299 | 317 |
| 300 // Incognito access. | 318 // Incognito access. |
| 301 info->incognito_access.is_enabled = extension.can_be_incognito_enabled(); | 319 info->incognito_access.is_enabled = extension.can_be_incognito_enabled(); |
| 302 info->incognito_access.is_active = | 320 info->incognito_access.is_active = |
| 303 util::IsIncognitoEnabled(extension.id(), browser_context_); | 321 util::IsIncognitoEnabled(extension.id(), browser_context_); |
| 304 | 322 |
| 305 Profile* profile = Profile::FromBrowserContext(browser_context_); | |
| 306 info->installed_by_custodian = | |
| 307 util::IsExtensionSupervised(&extension, profile); | |
| 308 | |
| 309 // Install warnings (only if unpacked and no error console). | 323 // Install warnings (only if unpacked and no error console). |
| 310 if (!error_console_enabled && | 324 if (!error_console_enabled && |
| 311 Manifest::IsUnpackedLocation(extension.location())) { | 325 Manifest::IsUnpackedLocation(extension.location())) { |
| 312 const std::vector<InstallWarning>& install_warnings = | 326 const std::vector<InstallWarning>& install_warnings = |
| 313 extension.install_warnings(); | 327 extension.install_warnings(); |
| 314 for (const InstallWarning& warning : install_warnings) | 328 for (const InstallWarning& warning : install_warnings) |
| 315 info->install_warnings.push_back(warning.message); | 329 info->install_warnings.push_back(warning.message); |
| 316 } | 330 } |
| 317 | 331 |
| 318 // Launch url. | 332 // Launch url. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 OptionsPageInfo::GetOptionsPage(&extension).spec(); | 398 OptionsPageInfo::GetOptionsPage(&extension).spec(); |
| 385 } | 399 } |
| 386 | 400 |
| 387 // Path. | 401 // Path. |
| 388 if (Manifest::IsUnpackedLocation(extension.location())) { | 402 if (Manifest::IsUnpackedLocation(extension.location())) { |
| 389 info->path.reset(new std::string(extension.path().AsUTF8Unsafe())); | 403 info->path.reset(new std::string(extension.path().AsUTF8Unsafe())); |
| 390 info->prettified_path.reset(new std::string( | 404 info->prettified_path.reset(new std::string( |
| 391 extensions::path_util::PrettifyPath(extension.path()).AsUTF8Unsafe())); | 405 extensions::path_util::PrettifyPath(extension.path()).AsUTF8Unsafe())); |
| 392 } | 406 } |
| 393 | 407 |
| 394 if (Manifest::IsPolicyLocation(extension.location())) { | |
| 395 info->policy_text.reset(new std::string( | |
| 396 l10n_util::GetStringUTF8(IDS_OPTIONS_INSTALL_LOCATION_ENTERPRISE))); | |
| 397 } | |
| 398 | |
| 399 // Runs on all urls. | 408 // Runs on all urls. |
| 400 info->run_on_all_urls.is_enabled = | 409 info->run_on_all_urls.is_enabled = |
| 401 (FeatureSwitch::scripts_require_action()->IsEnabled() && | 410 (FeatureSwitch::scripts_require_action()->IsEnabled() && |
| 402 PermissionsData::ScriptsMayRequireActionForExtension( | 411 PermissionsData::ScriptsMayRequireActionForExtension( |
| 403 &extension, | 412 &extension, |
| 404 extension.permissions_data()->active_permissions().get())) || | 413 extension.permissions_data()->active_permissions().get())) || |
| 405 extension.permissions_data()->HasWithheldImpliedAllHosts() || | 414 extension.permissions_data()->HasWithheldImpliedAllHosts() || |
| 406 util::HasSetAllowedScriptingOnAllUrls(extension.id(), browser_context_); | 415 util::HasSetAllowedScriptingOnAllUrls(extension.id(), browser_context_); |
| 407 info->run_on_all_urls.is_active = | 416 info->run_on_all_urls.is_active = |
| 408 util::AllowedScriptingOnAllUrls(extension.id(), browser_context_); | 417 util::AllowedScriptingOnAllUrls(extension.id(), browser_context_); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // that at the end of the method, any stored refs are destroyed. | 533 // that at the end of the method, any stored refs are destroyed. |
| 525 ExtensionInfoList list; | 534 ExtensionInfoList list; |
| 526 list.swap(list_); | 535 list.swap(list_); |
| 527 ExtensionInfosCallback callback = callback_; | 536 ExtensionInfosCallback callback = callback_; |
| 528 callback_.Reset(); | 537 callback_.Reset(); |
| 529 callback.Run(list); // WARNING: |this| is possibly deleted after this line! | 538 callback.Run(list); // WARNING: |this| is possibly deleted after this line! |
| 530 } | 539 } |
| 531 } | 540 } |
| 532 | 541 |
| 533 } // namespace extensions | 542 } // namespace extensions |
| OLD | NEW |