ui_util.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "extensions/browser/ui_util.h"
  5. #include "base/command_line.h"
  6. #include "extensions/common/extension.h"
  7. #include "extensions/common/switches.h"
  8. namespace extensions {
  9. namespace ui_util {
  10. bool ShouldDisplayInExtensionSettings(Manifest::Type type,
  11. mojom::ManifestLocation location) {
  12. // Don't show for themes since the settings UI isn't really useful for them.
  13. if (type == Manifest::TYPE_THEME)
  14. return false;
  15. // Hide component extensions because they are only extensions as an
  16. // implementation detail of Chrome.
  17. if (Manifest::IsComponentLocation(location) &&
  18. !base::CommandLine::ForCurrentProcess()->HasSwitch(
  19. switches::kShowComponentExtensionOptions)) {
  20. return false;
  21. }
  22. // Unless they are unpacked, never show hosted apps. Note: We intentionally
  23. // show packaged apps and platform apps because there are some pieces of
  24. // functionality that are only available in chrome://extensions/ but which
  25. // are needed for packaged and platform apps. For example, inspecting
  26. // background pages. See http://crbug.com/116134.
  27. if (!Manifest::IsUnpackedLocation(location) &&
  28. type == Manifest::TYPE_HOSTED_APP) {
  29. return false;
  30. }
  31. return true;
  32. }
  33. bool ShouldDisplayInExtensionSettings(const Extension& extension) {
  34. return ShouldDisplayInExtensionSettings(extension.GetType(),
  35. extension.location());
  36. }
  37. } // namespace ui_util
  38. } // namespace extensions