Skip to content

Commit

Permalink
Reland "Extensions: Rename DictionaryBuilder::SetBooean -> Set. Same …
Browse files Browse the repository at this point in the history
…for ListBuilder."

This is a reland of fef93a8

There is no change in the reland CL, the previous attempt collided with
another CL that was reverted at 348808c


Original change's description:
> Extensions: Rename DictionaryBuilder::SetBooean -> Set. Same for ListBuilder.
>
> The overload resolution failure isn't any issue anymore after
> https://chromium.googlesource.com/chromium/src/+/723fb47254fc5f49bda577df447303dc3554beb9,
> so bool overload can be provided for DictionaryBuilder::Set and ListBuilder::Append.
>
> Bug: None
> Test: Internal only change.
> Change-Id: Id55283aeaa8868cf533f206b006c3c909a835df1
> Reviewed-on: https://chromium-review.googlesource.com/1009489
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
> Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#550475}

TBR=avi@chromium.org,lazyboy@chromium.org,rdevlin.cronin@chromium.org

Bug: None
Change-Id: I2896a13c9421b1c08076bb5f756b7630f050c404
Reviewed-on: https://chromium-review.googlesource.com/1011711
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550522}
  • Loading branch information
Istiaque Ahmed authored and Commit Bot committed Apr 13, 2018
1 parent fdada01 commit 6f87468
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ scoped_refptr<const extensions::Extension> TestKioskExtensionBuilder::Build()
}

if (kiosk_enabled_)
manifest_builder.SetBoolean("kiosk_enabled", kiosk_enabled_);
manifest_builder.Set("kiosk_enabled", kiosk_enabled_);

manifest_builder.SetBoolean("offline_enabled", offline_enabled_);
manifest_builder.Set("offline_enabled", offline_enabled_);

if (!secondary_extensions_.empty()) {
ListBuilder secondary_extension_list_builder;
for (const auto& secondary_extension : secondary_extensions_) {
DictionaryBuilder secondary_extension_builder;
secondary_extension_builder.Set("id", secondary_extension.id);
if (secondary_extension.enabled_on_launch.has_value()) {
secondary_extension_builder.SetBoolean(
secondary_extension_builder.Set(
"enabled_on_launch", secondary_extension.enabled_on_launch.value());
}
secondary_extension_list_builder.Append(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) {
extensions::DictionaryBuilder()
.Set("text",
extensions::DictionaryBuilder()
.SetBoolean("include_directories", true)
.Set("include_directories", true)
.Set("extensions",
extensions::ListBuilder().Append("txt").Build())
.Build())
Expand Down Expand Up @@ -1153,7 +1153,7 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) {
.Build())
.Set("any_with_directories",
extensions::DictionaryBuilder()
.SetBoolean("include_directories", true)
.Set("include_directories", true)
.Set("types",
extensions::ListBuilder().Append("*").Build())
.Set("verb", "pack_with")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@ class LockScreenAppManagerImplTest
.Build();
std::unique_ptr<base::ListValue> action_handlers =
ListBuilder()
.Append(
DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", supports_lock_screen)
.Build())
.Append(DictionaryBuilder()
.Set("action", "new_note")
.Set("enabled_on_lock_screen", supports_lock_screen)
.Build())
.Build();

DictionaryBuilder manifest_builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class LockScreenProfileCreatorImplTest : public testing::Test {
ListBuilder()
.Append(DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build())
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ scoped_refptr<extensions::Extension> CreateTestNoteTakingApp(
ListBuilder action_handlers;
action_handlers.Append(DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build());
DictionaryBuilder background;
background.Set("scripts", ListBuilder().Append("background.js").Build());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/note_taking_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class NoteTakingHelperTest : public BrowserWithTestWindowTest,
.Append(extensions::DictionaryBuilder()
.Set("action", app_runtime::ToString(
app_runtime::ACTION_TYPE_NEW_NOTE))
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build())
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ void DeveloperPrivateApiUnitTest::UpdateProfileConfigurationDevMode(
new api::DeveloperPrivateUpdateProfileConfigurationFunction());
std::unique_ptr<base::ListValue> args =
ListBuilder()
.Append(DictionaryBuilder()
.SetBoolean("inDeveloperMode", dev_mode)
.Build())
.Append(DictionaryBuilder().Set("inDeveloperMode", dev_mode).Build())
.Build();
EXPECT_TRUE(RunFunction(function, *args)) << function->GetError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) {
scoped_refptr<Extension> auto_launch_kiosk_app(
ExtensionBuilder("Test", ExtensionBuilder::Type::PLATFORM_APP)
.MergeManifest(DictionaryBuilder()
.SetBoolean("kiosk_enabled", true)
.SetBoolean("kiosk_only", true)
.Set("kiosk_enabled", true)
.Set("kiosk_only", true)
.Build())
.Build());
user_manager_->AddKioskAppUser(
Expand Down Expand Up @@ -212,8 +212,8 @@ TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) {
scoped_refptr<Extension> manual_launch_kiosk_app(
ExtensionBuilder("Test", ExtensionBuilder::Type::PLATFORM_APP)
.MergeManifest(DictionaryBuilder()
.SetBoolean("kiosk_enabled", true)
.SetBoolean("kiosk_only", true)
.Set("kiosk_enabled", true)
.Set("kiosk_only", true)
.Build())
.Build());
user_manager::User* const manual_kiosk_app_user =
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/api/storage/settings_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorage) {
.Set("string-policy", "value")
.Set("int-policy", -123)
.Set("double-policy", 456e7)
.SetBoolean("boolean-policy", true)
.Set("boolean-policy", true)
.Set("list-policy", extensions::ListBuilder()
.Append("one")
.Append("two")
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/update_install_gate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ scoped_refptr<Extension> CreateExtension(const std::string& extension_id,
.Set("manifest_version", 2)
.Set("background", DictionaryBuilder()
.Set("page", "background.html")
.SetBoolean("persistent", persistent)
.Set("persistent", persistent)
.Build())
.Build())
.SetID(extension_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ TEST_F(ExtensionMetricsProviderInstallsTest, TestProtoConstruction) {
{
// Test that event pages are reported correctly.
DictionaryBuilder background;
background.SetBoolean("persistent", false)
background.Set("persistent", false)
.Set("scripts", extensions::ListBuilder().Append("script.js").Build());
scoped_refptr<const Extension> extension =
ExtensionBuilder("event_page")
Expand All @@ -337,7 +337,7 @@ TEST_F(ExtensionMetricsProviderInstallsTest, TestProtoConstruction) {
{
// Test that persistent background pages are reported correctly.
DictionaryBuilder background;
background.SetBoolean("persistent", true)
background.Set("persistent", true)
.Set("scripts", extensions::ListBuilder().Append("script.js").Build());
scoped_refptr<const Extension> extension =
ExtensionBuilder("persisent_background")
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ui/location_bar/location_bar_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ IN_PROC_BROWSER_TEST_F(LocationBarBrowserTest,

// Create and install an extension that overrides the bookmark star.
extensions::DictionaryBuilder chrome_ui_overrides;
chrome_ui_overrides.Set("bookmarks_ui", extensions::DictionaryBuilder()
.SetBoolean("remove_button", true)
.Build());
chrome_ui_overrides.Set(
"bookmarks_ui",
extensions::DictionaryBuilder().Set("remove_button", true).Build());
scoped_refptr<const extensions::Extension> extension =
extensions::ExtensionBuilder()
.SetManifest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ TEST_F(ToolbarActionsModelUnitTest, AddUserScriptExtension) {
extensions::ExtensionBuilder("a")
.SetLocation(extensions::Manifest::INTERNAL)
.MergeManifest(extensions::DictionaryBuilder()
.SetBoolean("converted_from_user_script", true)
.Set("converted_from_user_script", true)
.Build())
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void ExtensionPrinterHandler::OnUsbDevicesEnumerated(
device->product_string(), base::string16(), false))
.Set("extensionId", extension->id())
.Set("extensionName", extension->name())
.SetBoolean("provisional", true)
.Set("provisional", true)
.Build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
.Set("name", "USB Printer")
.Set("extensionName", "Provider 1")
.Set("extensionId", extension_1->id())
.SetBoolean("provisional", true)
.Set("provisional", true)
.Build());
std::unique_ptr<base::DictionaryValue> extension_2_entry(
DictionaryBuilder()
Expand All @@ -605,7 +605,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
.Set("name", "USB Printer")
.Set("extensionName", "Provider 2")
.Set("extensionId", extension_2->id())
.SetBoolean("provisional", true)
.Set("provisional", true)
.Build());
EXPECT_TRUE(printers->Find(*extension_1_entry) != printers->end());
EXPECT_TRUE(printers->Find(*extension_2_entry) != printers->end());
Expand Down
13 changes: 6 additions & 7 deletions chrome/renderer/extensions/extension_hooks_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,12 @@ TEST_F(ExtensionHooksDelegateTest, SendRequestDisabled) {
// TODO(devlin): Add a SetBackgroundPage() to ExtensionBuilder?
scoped_refptr<Extension> extension =
ExtensionBuilder("foo")
.MergeManifest(
DictionaryBuilder()
.Set("background", DictionaryBuilder()
.SetBoolean("persistent", false)
.Set("page", "page.html")
.Build())
.Build())
.MergeManifest(DictionaryBuilder()
.Set("background", DictionaryBuilder()
.Set("persistent", false)
.Set("page", "page.html")
.Build())
.Build())
.SetLocation(Manifest::UNPACKED)
.Build();
RegisterExtension(extension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST_F(BluetoothSocketApiUnittest, CreateThenClose) {
.Set("name", "bluetooth app")
.Set("version", "1.0")
.Set("bluetooth",
DictionaryBuilder().SetBoolean("socket", true).Build())
DictionaryBuilder().Set("socket", true).Build())
.Set("app",
DictionaryBuilder()
.Set("background",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class DataItemTest : public testing::Test {
ListBuilder app_handlers_builder;
app_handlers_builder.Append(DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build());
scoped_refptr<const Extension> extension =
ExtensionBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class LockScreenItemStorageTest : public ExtensionsTest {
ListBuilder app_handlers_builder;
app_handlers_builder.Append(DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build());
scoped_refptr<const Extension> extension =
ExtensionBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class LockScreenValueStoreMigratorImplTest : public testing::Test {
ListBuilder app_handlers_builder;
app_handlers_builder.Append(DictionaryBuilder()
.Set("action", "new_note")
.SetBoolean("enabled_on_lock_screen", true)
.Set("enabled_on_lock_screen", true)
.Build());
scoped_refptr<const Extension> extension =
ExtensionBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,8 +1081,8 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) {
DictionaryBuilder()
.Set("Cellular",
DictionaryBuilder()
.SetBoolean("AllowRoaming", false)
.SetBoolean("AutoConnect", true)
.Set("AllowRoaming", false)
.Set("AutoConnect", true)
.Set("Carrier", "Cellular1_Carrier")
.Set("Family", "GSM")
.Set("HomeProvider", DictionaryBuilder()
Expand All @@ -1093,7 +1093,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularProperties) {
.Set("ModelID", "test_model_id")
.Set("NetworkTechnology", "GSM")
.Set("RoamingState", "Home")
.SetBoolean("Scanning", false)
.Set("Scanning", false)
.Build())
.Set("ConnectionState", "Connected")
.Set("GUID", "cellular_guid")
Expand Down Expand Up @@ -1128,8 +1128,8 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) {
DictionaryBuilder()
.Set("Cellular",
DictionaryBuilder()
.SetBoolean("AllowRoaming", false)
.SetBoolean("AutoConnect", true)
.Set("AllowRoaming", false)
.Set("AutoConnect", true)
.Set("Carrier", "Cellular1_Carrier")
.Set("ESN", "test_esn")
.Set("Family", "GSM")
Expand All @@ -1147,7 +1147,7 @@ TEST_F(NetworkingPrivateApiTest, GetCellularPropertiesFromWebUi) {
.Set("MIN", "test_min")
.Set("NetworkTechnology", "GSM")
.Set("RoamingState", "Home")
.SetBoolean("Scanning", false)
.Set("Scanning", false)
.Set("APNList", ListBuilder()
.Append(expected_apn->CreateDeepCopy())
.Build())
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/lazy_background_task_queue_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class LazyBackgroundTaskQueueTest : public ExtensionsTest {
.Set("manifest_version", 2)
.Set("background", DictionaryBuilder()
.Set("page", "background.html")
.SetBoolean("persistent", false)
.Set("persistent", false)
.Build())
.Build())
.SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
Expand Down
30 changes: 15 additions & 15 deletions extensions/common/value_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@ std::string DictionaryBuilder::ToJSON() const {
}

DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
const char* in_value) {
return Set(path, std::string(in_value));
int in_value) {
dict_->SetWithoutPathExpansion(path, std::make_unique<base::Value>(in_value));
return *this;
}

DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
int in_value) {
double in_value) {
dict_->SetWithoutPathExpansion(path, std::make_unique<base::Value>(in_value));
return *this;
}

DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
double in_value) {
bool in_value) {
dict_->SetWithoutPathExpansion(path, std::make_unique<base::Value>(in_value));
return *this;
}

DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
const char* in_value) {
return Set(path, std::string(in_value));
}

DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
const std::string& in_value) {
dict_->SetWithoutPathExpansion(path, std::make_unique<base::Value>(in_value));
Expand All @@ -63,12 +69,6 @@ DictionaryBuilder& DictionaryBuilder::Set(
return *this;
}

DictionaryBuilder& DictionaryBuilder::SetBoolean(
const std::string& path, bool in_value) {
dict_->SetWithoutPathExpansion(path, std::make_unique<base::Value>(in_value));
return *this;
}

// ListBuilder

ListBuilder::ListBuilder() : list_(new base::ListValue) {}
Expand All @@ -86,6 +86,11 @@ ListBuilder& ListBuilder::Append(double in_value) {
return *this;
}

ListBuilder& ListBuilder::Append(bool in_value) {
list_->AppendBoolean(in_value);
return *this;
}

ListBuilder& ListBuilder::Append(const char* in_value) {
return Append(std::string(in_value));
}
Expand All @@ -105,9 +110,4 @@ ListBuilder& ListBuilder::Append(std::unique_ptr<base::Value> in_value) {
return *this;
}

ListBuilder& ListBuilder::AppendBoolean(bool in_value) {
list_->AppendBoolean(in_value);
return *this;
}

} // namespace extensions
Loading

0 comments on commit 6f87468

Please sign in to comment.