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

Side by Side Diff: chrome/browser/protector/protected_prefs_watcher_unittest.cc

Issue 9764006: Make ExtensionPrefValueMap a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: includes Created 8 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 | 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/extensions/extension_pref_value_map.h" 7 #include "chrome/browser/extensions/extension_pref_value_map.h"
8 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
8 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/protector/protected_prefs_watcher.h" 12 #include "chrome/browser/protector/protected_prefs_watcher.h"
12 #include "chrome/browser/protector/protector_service.h" 13 #include "chrome/browser/protector/protector_service.h"
13 #include "chrome/browser/protector/protector_service_factory.h" 14 #include "chrome/browser/protector/protector_service_factory.h"
14 #include "chrome/common/extensions/extension_constants.h" 15 #include "chrome/common/extensions/extension_constants.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "content/test/test_browser_thread.h" 18 #include "content/test/test_browser_thread.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 TEST_F(ProtectedPrefsWatcherTest, ExtensionPrefChange) { 97 TEST_F(ProtectedPrefsWatcherTest, ExtensionPrefChange) {
97 // Changes to extensions data (but not to extension IDs) do not update 98 // Changes to extensions data (but not to extension IDs) do not update
98 // the backup and its signature. 99 // the backup and its signature.
99 MessageLoopForUI message_loop; 100 MessageLoopForUI message_loop;
100 content::TestBrowserThread ui_thread(content::BrowserThread::UI, 101 content::TestBrowserThread ui_thread(content::BrowserThread::UI,
101 &message_loop); 102 &message_loop);
102 103
103 FilePath extensions_install_dir = 104 FilePath extensions_install_dir =
104 profile_.GetPath().AppendASCII(ExtensionService::kInstallDirectoryName); 105 profile_.GetPath().AppendASCII(ExtensionService::kInstallDirectoryName);
105 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_(
106 new ExtensionPrefValueMap);
107 scoped_ptr<ExtensionPrefs> extension_prefs( 106 scoped_ptr<ExtensionPrefs> extension_prefs(
108 new ExtensionPrefs(profile_.GetPrefs(), 107 new ExtensionPrefs(profile_.GetPrefs(),
109 extensions_install_dir, 108 extensions_install_dir,
110 extension_pref_value_map_.get())); 109 ExtensionPrefValueMapFactory::GetForProfile(
110 &profile_)));
111 std::string sample_id = extension_misc::kWebStoreAppId; 111 std::string sample_id = extension_misc::kWebStoreAppId;
112 extension_prefs->Init(false); 112 extension_prefs->Init(false);
113 // Flip a pref value of an extension (this will actually add it to the list). 113 // Flip a pref value of an extension (this will actually add it to the list).
114 extension_prefs->SetAppNotificationDisabled( 114 extension_prefs->SetAppNotificationDisabled(
115 sample_id, !extension_prefs->IsAppNotificationDisabled(sample_id)); 115 sample_id, !extension_prefs->IsAppNotificationDisabled(sample_id));
116 116
117 // Backup is still valid. 117 // Backup is still valid.
118 EXPECT_TRUE(IsSignatureValid()); 118 EXPECT_TRUE(IsSignatureValid());
119 EXPECT_TRUE(prefs_watcher_->is_backup_valid()); 119 EXPECT_TRUE(prefs_watcher_->is_backup_valid());
120 120
(...skipping 11 matching lines...) Expand all
132 132
133 // Blacklisting the extension does update the backup and signature. 133 // Blacklisting the extension does update the backup and signature.
134 std::set<std::string> blacklist; 134 std::set<std::string> blacklist;
135 blacklist.insert(sample_id); 135 blacklist.insert(sample_id);
136 extension_prefs->UpdateBlacklist(blacklist); 136 extension_prefs->UpdateBlacklist(blacklist);
137 137
138 EXPECT_TRUE(IsSignatureValid()); 138 EXPECT_TRUE(IsSignatureValid());
139 } 139 }
140 140
141 } // namespace protector 141 } // namespace protector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698