Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/extensions/extension_context_menu_model_unittest.cc

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extension_context_menu_model.h" 5 #include "chrome/browser/extensions/extension_context_menu_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 const Extension* ExtensionContextMenuModelTest::AddExtensionWithHostPermission( 154 const Extension* ExtensionContextMenuModelTest::AddExtensionWithHostPermission(
155 const std::string& name, 155 const std::string& name,
156 const char* action_key, 156 const char* action_key,
157 Manifest::Location location, 157 Manifest::Location location,
158 const std::string& host_permission) { 158 const std::string& host_permission) {
159 DictionaryBuilder manifest; 159 DictionaryBuilder manifest;
160 manifest.Set("name", name) 160 manifest.Set("name", name)
161 .Set("version", "1") 161 .Set("version", "1")
162 .Set("manifest_version", 2) 162 .Set("manifest_version", 2)
163 .Set(action_key, DictionaryBuilder()); 163 .Set(action_key, DictionaryBuilder().Build());
164 if (!host_permission.empty()) 164 if (!host_permission.empty())
165 manifest.Set("permissions", 165 manifest.Set("permissions", ListBuilder().Append(host_permission).Build());
166 std::move(ListBuilder().Append(host_permission)));
167 scoped_refptr<const Extension> extension = 166 scoped_refptr<const Extension> extension =
168 ExtensionBuilder() 167 ExtensionBuilder()
169 .SetManifest(std::move(manifest)) 168 .SetManifest(manifest.Build())
170 .SetID(crx_file::id_util::GenerateId(name)) 169 .SetID(crx_file::id_util::GenerateId(name))
171 .SetLocation(location) 170 .SetLocation(location)
172 .Build(); 171 .Build();
173 if (!extension.get()) 172 if (!extension.get())
174 ADD_FAILURE(); 173 ADD_FAILURE();
175 service()->AddExtension(extension.get()); 174 service()->AddExtension(extension.get());
176 return extension.get(); 175 return extension.get();
177 } 176 }
178 177
179 Browser* ExtensionContextMenuModelTest::GetBrowser() { 178 Browser* ExtensionContextMenuModelTest::GetBrowser() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Tests the context menu for a component extension. 226 // Tests the context menu for a component extension.
228 TEST_F(ExtensionContextMenuModelTest, ComponentExtensionContextMenu) { 227 TEST_F(ExtensionContextMenuModelTest, ComponentExtensionContextMenu) {
229 InitializeEmptyExtensionService(); 228 InitializeEmptyExtensionService();
230 229
231 std::string name("component"); 230 std::string name("component");
232 scoped_ptr<base::DictionaryValue> manifest = 231 scoped_ptr<base::DictionaryValue> manifest =
233 DictionaryBuilder() 232 DictionaryBuilder()
234 .Set("name", name) 233 .Set("name", name)
235 .Set("version", "1") 234 .Set("version", "1")
236 .Set("manifest_version", 2) 235 .Set("manifest_version", 2)
237 .Set("browser_action", DictionaryBuilder()) 236 .Set("browser_action", DictionaryBuilder().Build())
238 .Build(); 237 .Build();
239 238
240 { 239 {
241 scoped_refptr<const Extension> extension = 240 scoped_refptr<const Extension> extension =
242 ExtensionBuilder() 241 ExtensionBuilder()
243 .SetManifest(make_scoped_ptr(manifest->DeepCopy())) 242 .SetManifest(make_scoped_ptr(manifest->DeepCopy()))
244 .SetID(crx_file::id_util::GenerateId("component")) 243 .SetID(crx_file::id_util::GenerateId("component"))
245 .SetLocation(Manifest::COMPONENT) 244 .SetLocation(Manifest::COMPONENT)
246 .Build(); 245 .Build();
247 service()->AddExtension(extension.get()); 246 service()->AddExtension(extension.get());
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 "feature_disabled_extension", manifest_keys::kBrowserAction, 651 "feature_disabled_extension", manifest_keys::kBrowserAction,
653 Manifest::INTERNAL, "http://www.google.com/*"); 652 Manifest::INTERNAL, "http://www.google.com/*");
654 ExtensionContextMenuModel feature_disabled_menu( 653 ExtensionContextMenuModel feature_disabled_menu(
655 feature_disabled_extension, GetBrowser(), 654 feature_disabled_extension, GetBrowser(),
656 ExtensionContextMenuModel::VISIBLE, nullptr); 655 ExtensionContextMenuModel::VISIBLE, nullptr);
657 EXPECT_EQ(-1, feature_disabled_menu.GetIndexOfCommandId( 656 EXPECT_EQ(-1, feature_disabled_menu.GetIndexOfCommandId(
658 ExtensionContextMenuModel::PAGE_ACCESS_SUBMENU)); 657 ExtensionContextMenuModel::PAGE_ACCESS_SUBMENU));
659 } 658 }
660 659
661 } // namespace extensions 660 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698