| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // These tests make sure SettingsOverridePermission values are set correctly. | 5 // These tests make sure SettingsOverridePermission values are set correctly. |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 15 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" |
| 15 #include "components/version_info/version_info.h" | 16 #include "components/version_info/version_info.h" |
| 16 #include "extensions/common/features/feature_channel.h" | 17 #include "extensions/common/features/feature_channel.h" |
| 17 #include "extensions/common/manifest_constants.h" | 18 #include "extensions/common/manifest_constants.h" |
| 18 #include "extensions/common/permissions/permission_message_test_util.h" | 19 #include "extensions/common/permissions/permission_message_test_util.h" |
| 19 #include "extensions/common/permissions/permission_set.h" | 20 #include "extensions/common/permissions/permission_set.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 ext_manifest.SetString(manifest_keys::kVersion, "0.1"); | 47 ext_manifest.SetString(manifest_keys::kVersion, "0.1"); |
| 47 ext_manifest.SetInteger(manifest_keys::kManifestVersion, 2); | 48 ext_manifest.SetInteger(manifest_keys::kManifestVersion, 2); |
| 48 | 49 |
| 49 std::unique_ptr<base::DictionaryValue> settings_override( | 50 std::unique_ptr<base::DictionaryValue> settings_override( |
| 50 new base::DictionaryValue); | 51 new base::DictionaryValue); |
| 51 if (flags & kHomepage) | 52 if (flags & kHomepage) |
| 52 settings_override->SetString("homepage", "http://www.google.com/home"); | 53 settings_override->SetString("homepage", "http://www.google.com/home"); |
| 53 if (flags & kStartupPages) { | 54 if (flags & kStartupPages) { |
| 54 std::unique_ptr<base::ListValue> startup_pages(new base::ListValue); | 55 std::unique_ptr<base::ListValue> startup_pages(new base::ListValue); |
| 55 startup_pages->AppendString("http://startup.com/startup.html"); | 56 startup_pages->AppendString("http://startup.com/startup.html"); |
| 56 settings_override->Set("startup_pages", startup_pages.release()); | 57 settings_override->Set("startup_pages", std::move(startup_pages)); |
| 57 } | 58 } |
| 58 if (flags & kSearchProvider) { | 59 if (flags & kSearchProvider) { |
| 59 std::unique_ptr<base::DictionaryValue> search_provider( | 60 std::unique_ptr<base::DictionaryValue> search_provider( |
| 60 new base::DictionaryValue); | 61 new base::DictionaryValue); |
| 61 search_provider->SetString("search_url", "http://google.com/search.html"); | 62 search_provider->SetString("search_url", "http://google.com/search.html"); |
| 62 search_provider->SetString("name", "test"); | 63 search_provider->SetString("name", "test"); |
| 63 search_provider->SetString("keyword", "lock"); | 64 search_provider->SetString("keyword", "lock"); |
| 64 search_provider->SetString("encoding", "UTF-8"); | 65 search_provider->SetString("encoding", "UTF-8"); |
| 65 search_provider->SetBoolean("is_default", true); | 66 search_provider->SetBoolean("is_default", true); |
| 66 search_provider->SetString("favicon_url", | 67 search_provider->SetString("favicon_url", |
| 67 "http://wikipedia.org/wiki/Favicon"); | 68 "http://wikipedia.org/wiki/Favicon"); |
| 68 settings_override->Set("search_provider", search_provider.release()); | 69 settings_override->Set("search_provider", std::move(search_provider)); |
| 69 } | 70 } |
| 70 ext_manifest.Set( | 71 ext_manifest.Set(manifest_keys::kSettingsOverride, |
| 71 manifest_keys::kSettingsOverride, settings_override.release()); | 72 std::move(settings_override)); |
| 72 | 73 |
| 73 ManifestData manifest(&ext_manifest, "test"); | 74 ManifestData manifest(&ext_manifest, "test"); |
| 74 return LoadAndExpectSuccess(manifest); | 75 return LoadAndExpectSuccess(manifest); |
| 75 } | 76 } |
| 76 | 77 |
| 77 #if defined(OS_MACOSX) | 78 #if defined(OS_MACOSX) |
| 78 // On Mac, this API is limited to trunk. | 79 // On Mac, this API is limited to trunk. |
| 79 extensions::ScopedCurrentChannel scoped_channel_; | 80 extensions::ScopedCurrentChannel scoped_channel_; |
| 80 #endif // OS_MACOSX | 81 #endif // OS_MACOSX |
| 81 }; | 82 }; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kHomepage)); | 162 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kHomepage)); |
| 162 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kSearchProvider)); | 163 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kSearchProvider)); |
| 163 #endif | 164 #endif |
| 164 | 165 |
| 165 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kStartupPages)); | 166 EXPECT_FALSE(permission_set.HasAPIPermission(APIPermission::kStartupPages)); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace | 169 } // namespace |
| 169 | 170 |
| 170 } // namespace extensions | 171 } // namespace extensions |
| OLD | NEW |