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

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

Issue 8060017: Ensure that --disable-extensions disables extension prefs from being enacted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split ExtensionPrefs constructor into constructor and Init function Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 30 matching lines...) Expand all
41 mutable base::Time currentTime; 41 mutable base::Time currentTime;
42 42
43 virtual base::Time GetCurrentTime() const { 43 virtual base::Time GetCurrentTime() const {
44 currentTime += base::TimeDelta::FromSeconds(10); 44 currentTime += base::TimeDelta::FromSeconds(10);
45 return currentTime; 45 return currentTime;
46 } 46 }
47 }; 47 };
48 48
49 } // namespace 49 } // namespace
50 50
51 TestExtensionPrefs::TestExtensionPrefs() : pref_service_(NULL) { 51 TestExtensionPrefs::TestExtensionPrefs()
52 : pref_service_(NULL),
53 extensions_disabled_(false) {
52 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 54 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
53 preferences_file_ = temp_dir_.path().AppendASCII("Preferences"); 55 preferences_file_ = temp_dir_.path().AppendASCII("Preferences");
54 extensions_dir_ = temp_dir_.path().AppendASCII("Extensions"); 56 extensions_dir_ = temp_dir_.path().AppendASCII("Extensions");
55 EXPECT_TRUE(file_util::CreateDirectory(extensions_dir_)); 57 EXPECT_TRUE(file_util::CreateDirectory(extensions_dir_));
56 58
57 RecreateExtensionPrefs(); 59 RecreateExtensionPrefs();
58 } 60 }
59 61
60 TestExtensionPrefs::~TestExtensionPrefs() {} 62 TestExtensionPrefs::~TestExtensionPrefs() {}
61 63
(...skipping 23 matching lines...) Expand all
85 PrefServiceMockBuilder builder; 87 PrefServiceMockBuilder builder;
86 builder.WithUserFilePrefs(preferences_file_); 88 builder.WithUserFilePrefs(preferences_file_);
87 builder.WithExtensionPrefs( 89 builder.WithExtensionPrefs(
88 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); 90 new ExtensionPrefStore(extension_pref_value_map_.get(), false));
89 pref_service_.reset(builder.Create()); 91 pref_service_.reset(builder.Create());
90 ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); 92 ExtensionPrefs::RegisterUserPrefs(pref_service_.get());
91 93
92 prefs_.reset(new MockExtensionPrefs(pref_service_.get(), 94 prefs_.reset(new MockExtensionPrefs(pref_service_.get(),
93 temp_dir_.path(), 95 temp_dir_.path(),
94 extension_pref_value_map_.get())); 96 extension_pref_value_map_.get()));
97 prefs_->Init(extensions_disabled_);
95 } 98 }
96 99
97 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) { 100 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {
98 DictionaryValue dictionary; 101 DictionaryValue dictionary;
99 dictionary.SetString(extension_manifest_keys::kName, name); 102 dictionary.SetString(extension_manifest_keys::kName, name);
100 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 103 dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
101 return AddExtensionWithManifest(dictionary, Extension::INTERNAL); 104 return AddExtensionWithManifest(dictionary, Extension::INTERNAL);
102 } 105 }
103 106
104 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) { 107 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { 144 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) {
142 scoped_refptr<Extension> extension(AddExtension(name)); 145 scoped_refptr<Extension> extension(AddExtension(name));
143 return extension->id(); 146 return extension->id();
144 } 147 }
145 148
146 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { 149 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const {
147 return pref_service_->CreateIncognitoPrefService( 150 return pref_service_->CreateIncognitoPrefService(
148 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); 151 new ExtensionPrefStore(extension_pref_value_map_.get(), true));
149 } 152 }
153
154 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) {
155 extensions_disabled_ = extensions_disabled;
156 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/test_extension_prefs.h ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698