[Extensions Cleanup] Constify ExtensionBuiler::Build()
In practice, Extension objects are pretty much always const. Update
ExtensionBuilder::Build() to return a const Extension object, rather
than a mutable one.
[email protected] (c/b/apps, c/b/ui, c/b/web_applications)
[email protected] (c/b/chromeos, c/b/notifications)
[email protected] (c/b/media)
[email protected] (c/b/metrics)
[email protected] (c/b/safe_browsing)
[email protected] (c/b/supervised_user)
[email protected] (c/c/pepper_permission_util_unittest.cc)
Bug: 889925
Change-Id: I7da674b29e209540803acfd40576c7daba3da2a3
Reviewed-on: https://chromium-review.googlesource.com/c/1256167
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Cr-Commit-Position: refs/heads/master@{#596434}
diff --git a/extensions/browser/renderer_startup_helper_unittest.cc b/extensions/browser/renderer_startup_helper_unittest.cc
index 54f3de6..7afa40f 100644
--- a/extensions/browser/renderer_startup_helper_unittest.cc
+++ b/extensions/browser/renderer_startup_helper_unittest.cc
@@ -59,7 +59,7 @@
content::NotificationService::NoDetails());
}
- scoped_refptr<Extension> CreateExtension(const std::string& id_input) {
+ scoped_refptr<const Extension> CreateExtension(const std::string& id_input) {
std::unique_ptr<base::DictionaryValue> manifest =
DictionaryBuilder()
.Set("name", "extension")
@@ -70,7 +70,7 @@
return CreateExtension(id_input, std::move(manifest));
}
- scoped_refptr<Extension> CreateTheme(const std::string& id_input) {
+ scoped_refptr<const Extension> CreateTheme(const std::string& id_input) {
std::unique_ptr<base::DictionaryValue> manifest =
DictionaryBuilder()
.Set("name", "theme")
@@ -82,7 +82,8 @@
return CreateExtension(id_input, std::move(manifest));
}
- scoped_refptr<Extension> CreatePlatformApp(const std::string& id_input) {
+ scoped_refptr<const Extension> CreatePlatformApp(
+ const std::string& id_input) {
std::unique_ptr<base::Value> background =
DictionaryBuilder()
.Set("scripts", ListBuilder().Append("background.js").Build())
@@ -100,11 +101,11 @@
return CreateExtension(id_input, std::move(manifest));
}
- void AddExtensionToRegistry(scoped_refptr<Extension> extension) {
+ void AddExtensionToRegistry(scoped_refptr<const Extension> extension) {
registry_->AddEnabled(extension);
}
- void RemoveExtensionFromRegistry(scoped_refptr<Extension> extension) {
+ void RemoveExtensionFromRegistry(scoped_refptr<const Extension> extension) {
registry_->RemoveEnabled(extension->id());
}
@@ -135,10 +136,10 @@
std::unique_ptr<content::MockRenderProcessHost> render_process_host_;
std::unique_ptr<content::MockRenderProcessHost>
incognito_render_process_host_;
- scoped_refptr<Extension> extension_;
+ scoped_refptr<const Extension> extension_;
private:
- scoped_refptr<Extension> CreateExtension(
+ scoped_refptr<const Extension> CreateExtension(
const std::string& id_input,
std::unique_ptr<base::DictionaryValue> manifest) {
return ExtensionBuilder()
@@ -251,7 +252,7 @@
SimulateRenderProcessCreated(render_process_host_.get());
EXPECT_TRUE(IsProcessInitialized(render_process_host_.get()));
- scoped_refptr<Extension> extension(CreateTheme("theme"));
+ scoped_refptr<const Extension> extension(CreateTheme("theme"));
ASSERT_TRUE(extension->is_theme());
IPC::TestSink& sink = render_process_host_->sink();
@@ -352,7 +353,8 @@
IPC::TestSink& incognito_sink = incognito_render_process_host_->sink();
- scoped_refptr<Extension> platform_app(CreatePlatformApp("platform_app"));
+ scoped_refptr<const Extension> platform_app(
+ CreatePlatformApp("platform_app"));
ASSERT_TRUE(platform_app->is_platform_app());
EXPECT_FALSE(util::IsIncognitoEnabled(platform_app->id(), browser_context()));
EXPECT_FALSE(util::CanBeIncognitoEnabled(platform_app.get()));