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

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: -- Created 8 years, 8 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"
8 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
7 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_pref_value_map.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/prefs/scoped_user_pref_update.h" 12 #include "chrome/browser/prefs/scoped_user_pref_update.h"
12 #include "chrome/browser/protector/protected_prefs_watcher.h" 13 #include "chrome/browser/protector/protected_prefs_watcher.h"
13 #include "chrome/browser/protector/protector_service_factory.h" 14 #include "chrome/browser/protector/protector_service_factory.h"
14 #include "chrome/browser/protector/protector_service.h" 15 #include "chrome/browser/protector/protector_service.h"
15 #include "chrome/common/extensions/extension_constants.h" 16 #include "chrome/common/extensions/extension_constants.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
18 #include "content/test/test_browser_thread.h" 19 #include "content/test/test_browser_thread.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 TEST_F(ProtectedPrefsWatcherTest, ExtensionPrefChange) { 100 TEST_F(ProtectedPrefsWatcherTest, ExtensionPrefChange) {
100 // Changes to extensions data (but not to extension IDs) do not update 101 // Changes to extensions data (but not to extension IDs) do not update
101 // the backup and its signature. 102 // the backup and its signature.
102 MessageLoopForUI message_loop; 103 MessageLoopForUI message_loop;
103 content::TestBrowserThread ui_thread(content::BrowserThread::UI, 104 content::TestBrowserThread ui_thread(content::BrowserThread::UI,
104 &message_loop); 105 &message_loop);
105 106
106 FilePath extensions_install_dir = 107 FilePath extensions_install_dir =
107 profile_.GetPath().AppendASCII(ExtensionService::kInstallDirectoryName); 108 profile_.GetPath().AppendASCII(ExtensionService::kInstallDirectoryName);
108 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_(
109 new ExtensionPrefValueMap);
110 scoped_ptr<ExtensionPrefs> extension_prefs( 109 scoped_ptr<ExtensionPrefs> extension_prefs(
111 new ExtensionPrefs(profile_.GetPrefs(), 110 new ExtensionPrefs(profile_.GetPrefs(),
112 extensions_install_dir, 111 extensions_install_dir,
113 extension_pref_value_map_.get())); 112 ExtensionPrefValueMapFactory::GetForProfile(
113 &profile_)));
114 std::string sample_id = extension_misc::kWebStoreAppId; 114 std::string sample_id = extension_misc::kWebStoreAppId;
115 extension_prefs->Init(false); 115 extension_prefs->Init(false);
116 // Flip a pref value of an extension (this will actually add it to the list). 116 // Flip a pref value of an extension (this will actually add it to the list).
117 extension_prefs->SetAppNotificationDisabled( 117 extension_prefs->SetAppNotificationDisabled(
118 sample_id, !extension_prefs->IsAppNotificationDisabled(sample_id)); 118 sample_id, !extension_prefs->IsAppNotificationDisabled(sample_id));
119 119
120 // Backup is still valid. 120 // Backup is still valid.
121 EXPECT_TRUE(prefs_watcher_->is_backup_valid()); 121 EXPECT_TRUE(prefs_watcher_->is_backup_valid());
122 122
123 // Make signature invalid by changing it directly. 123 // Make signature invalid by changing it directly.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Now the backup should be valid and "pinned_tabs" is added back. 183 // Now the backup should be valid and "pinned_tabs" is added back.
184 EXPECT_TRUE(prefs_watcher_->is_backup_valid()); 184 EXPECT_TRUE(prefs_watcher_->is_backup_valid());
185 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList("backup.pinned_tabs"))); 185 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList("backup.pinned_tabs")));
186 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList(prefs::kPinnedTabs))); 186 EXPECT_TRUE(pinned_tabs_copy->Equals(prefs_->GetList(prefs::kPinnedTabs)));
187 EXPECT_FALSE(prefs_watcher_->DidPrefChange(prefs::kPinnedTabs)); 187 EXPECT_FALSE(prefs_watcher_->DidPrefChange(prefs::kPinnedTabs));
188 EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber, 188 EXPECT_EQ(ProtectedPrefsWatcher::kCurrentVersionNumber,
189 prefs_->GetInteger("backup._version")); 189 prefs_->GetInteger("backup._version"));
190 } 190 }
191 191
192 } // namespace protector 192 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698