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

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

Issue 22794012: Rename extension_manifest_keys namespace to extensions::manifest_keys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
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/test_extension_prefs.h" 5 #include "chrome/browser/extensions/test_extension_prefs.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/prefs/json_pref_store.h" 13 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_value_store.h" 14 #include "base/prefs/pref_value_store.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/extensions/extension_pref_store.h" 19 #include "chrome/browser/extensions/extension_pref_store.h"
20 #include "chrome/browser/extensions/extension_pref_value_map.h" 20 #include "chrome/browser/extensions/extension_pref_value_map.h"
21 #include "chrome/browser/extensions/extension_prefs.h" 21 #include "chrome/browser/extensions/extension_prefs.h"
22 #include "chrome/browser/prefs/pref_service_mock_builder.h" 22 #include "chrome/browser/prefs/pref_service_mock_builder.h"
23 #include "chrome/browser/prefs/pref_service_syncable.h" 23 #include "chrome/browser/prefs/pref_service_syncable.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/extensions/extension_manifest_constants.h"
26 #include "components/user_prefs/pref_registry_syncable.h" 25 #include "components/user_prefs/pref_registry_syncable.h"
27 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "extensions/common/manifest_constants.h"
28 #include "sync/api/string_ordinal.h" 28 #include "sync/api/string_ordinal.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 32
33 namespace extensions { 33 namespace extensions {
34 34
35 namespace { 35 namespace {
36 36
37 // A TimeProvider which returns an incrementally later time each time 37 // A TimeProvider which returns an incrementally later time each time
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 extension_pref_value_map_.get(), 115 extension_pref_value_map_.get(),
116 extensions_disabled_, 116 extensions_disabled_,
117 // Guarantee that no two extensions get the same installation time 117 // Guarantee that no two extensions get the same installation time
118 // stamp and we can reliably assert the installation order in the tests. 118 // stamp and we can reliably assert the installation order in the tests.
119 scoped_ptr<ExtensionPrefs::TimeProvider>( 119 scoped_ptr<ExtensionPrefs::TimeProvider>(
120 new IncrementalTimeProvider()))); 120 new IncrementalTimeProvider())));
121 } 121 }
122 122
123 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) { 123 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {
124 DictionaryValue dictionary; 124 DictionaryValue dictionary;
125 dictionary.SetString(extension_manifest_keys::kName, name); 125 dictionary.SetString(manifest_keys::kName, name);
126 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 126 dictionary.SetString(manifest_keys::kVersion, "0.1");
127 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); 127 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL);
128 } 128 }
129 129
130 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) { 130 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) {
131 DictionaryValue dictionary; 131 DictionaryValue dictionary;
132 dictionary.SetString(extension_manifest_keys::kName, name); 132 dictionary.SetString(manifest_keys::kName, name);
133 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 133 dictionary.SetString(manifest_keys::kVersion, "0.1");
134 dictionary.SetString(extension_manifest_keys::kApp, "true"); 134 dictionary.SetString(manifest_keys::kApp, "true");
135 dictionary.SetString(extension_manifest_keys::kLaunchWebURL, 135 dictionary.SetString(manifest_keys::kLaunchWebURL, "http://example.com");
136 "http://example.com");
137 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); 136 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL);
138 137
139 } 138 }
140 139
141 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest( 140 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest(
142 const DictionaryValue& manifest, Manifest::Location location) { 141 const DictionaryValue& manifest, Manifest::Location location) {
143 return AddExtensionWithManifestAndFlags(manifest, location, 142 return AddExtensionWithManifestAndFlags(manifest, location,
144 Extension::NO_FLAGS); 143 Extension::NO_FLAGS);
145 } 144 }
146 145
147 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags( 146 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags(
148 const DictionaryValue& manifest, 147 const DictionaryValue& manifest,
149 Manifest::Location location, 148 Manifest::Location location,
150 int extra_flags) { 149 int extra_flags) {
151 std::string name; 150 std::string name;
152 EXPECT_TRUE(manifest.GetString(extension_manifest_keys::kName, &name)); 151 EXPECT_TRUE(manifest.GetString(manifest_keys::kName, &name));
153 base::FilePath path = extensions_dir_.AppendASCII(name); 152 base::FilePath path = extensions_dir_.AppendASCII(name);
154 std::string errors; 153 std::string errors;
155 scoped_refptr<Extension> extension = Extension::Create( 154 scoped_refptr<Extension> extension = Extension::Create(
156 path, location, manifest, extra_flags, &errors); 155 path, location, manifest, extra_flags, &errors);
157 EXPECT_TRUE(extension.get()) << errors; 156 EXPECT_TRUE(extension.get()) << errors;
158 if (!extension.get()) 157 if (!extension.get())
159 return NULL; 158 return NULL;
160 159
161 EXPECT_TRUE(Extension::IdIsValid(extension->id())); 160 EXPECT_TRUE(Extension::IdIsValid(extension->id()));
162 prefs_->OnExtensionInstalled(extension.get(), 161 prefs_->OnExtensionInstalled(extension.get(),
(...skipping 11 matching lines...) Expand all
174 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { 173 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const {
175 return pref_service_->CreateIncognitoPrefService( 174 return pref_service_->CreateIncognitoPrefService(
176 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); 175 new ExtensionPrefStore(extension_pref_value_map_.get(), true));
177 } 176 }
178 177
179 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { 178 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) {
180 extensions_disabled_ = extensions_disabled; 179 extensions_disabled_ = extensions_disabled;
181 } 180 }
182 181
183 } // namespace extensions 182 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698