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

Side by Side Diff: chrome/browser/ui/webui/options/preferences_browsertest.h

Issue 2569083003: Prevent prefs_registrar unsubscribe from destroyed pref_service (Closed)
Patch Set: nit removal Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/preferences_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "components/policy/core/common/mock_configuration_policy_provider.h" 16 #include "components/policy/core/common/mock_configuration_policy_provider.h"
16 #include "components/policy/core/common/policy_types.h" 17 #include "components/policy/core/common/policy_types.h"
17 #include "components/prefs/pref_change_registrar.h" 18 #include "components/prefs/pref_change_registrar.h"
(...skipping 13 matching lines...) Expand all
31 // Tests verifying that the JavaScript Preferences class, the underlying C++ 32 // Tests verifying that the JavaScript Preferences class, the underlying C++
32 // CoreOptionsHandler and the specialized classes handling Chrome OS device and 33 // CoreOptionsHandler and the specialized classes handling Chrome OS device and
33 // proxy prefs behave correctly. 34 // proxy prefs behave correctly.
34 class PreferencesBrowserTest : public InProcessBrowserTest { 35 class PreferencesBrowserTest : public InProcessBrowserTest {
35 public: 36 public:
36 PreferencesBrowserTest(); 37 PreferencesBrowserTest();
37 ~PreferencesBrowserTest() override; 38 ~PreferencesBrowserTest() override;
38 39
39 // InProcessBrowserTest implementation: 40 // InProcessBrowserTest implementation:
40 void SetUpOnMainThread() override; 41 void SetUpOnMainThread() override;
42 void TearDownOnMainThread() override;
41 43
42 void OnPreferenceChanged(const std::string& pref_name); 44 void OnPreferenceChanged(const std::string& pref_name);
43 45
44 protected: 46 protected:
45 MOCK_METHOD1(OnCommit, void(const PrefService::Preference*)); 47 MOCK_METHOD1(OnCommit, void(const PrefService::Preference*));
46 48
49 // The pref service that holds the current pref values in the C++ backend.
50 PrefService* pref_service();
51
47 void SetUpPrefs(); 52 void SetUpPrefs();
48 53
49 // InProcessBrowserTest implementation: 54 // InProcessBrowserTest implementation:
50 void SetUpInProcessBrowserTestFixture() override; 55 void SetUpInProcessBrowserTestFixture() override;
51 56
52 // Sets user policies through the mock policy provider. 57 // Sets user policies through the mock policy provider.
53 void SetUserPolicies(const std::vector<std::string>& names, 58 void SetUserPolicies(const std::vector<std::string>& names,
54 const std::vector<base::Value*>& values, 59 const std::vector<base::Value*>& values,
55 policy::PolicyLevel level); 60 policy::PolicyLevel level);
56 // Clears user policies. 61 // Clears user policies.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 173
169 // The current tab's render view host, required to inject JavaScript code into 174 // The current tab's render view host, required to inject JavaScript code into
170 // the tab. 175 // the tab.
171 content::RenderViewHost* render_view_host_; 176 content::RenderViewHost* render_view_host_;
172 177
173 // Mock policy provider for both user and device policies. 178 // Mock policy provider for both user and device policies.
174 policy::MockConfigurationPolicyProvider policy_provider_; 179 policy::MockConfigurationPolicyProvider policy_provider_;
175 180
176 // Pref change registrar that detects changes to user-modified pref values 181 // Pref change registrar that detects changes to user-modified pref values
177 // made in the C++ backend by the JavaScript Preferences class. 182 // made in the C++ backend by the JavaScript Preferences class.
178 PrefChangeRegistrar pref_change_registrar_; 183 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
179
180 // The pref service that holds the current pref values in the C++ backend.
181 PrefService* pref_service_;
182 184
183 // The prefs and corresponding policies used by the current test. 185 // The prefs and corresponding policies used by the current test.
184 std::vector<std::string> types_; 186 std::vector<std::string> types_;
185 std::vector<std::string> pref_names_; 187 std::vector<std::string> pref_names_;
186 std::vector<std::string> policy_names_; 188 std::vector<std::string> policy_names_;
187 ScopedVector<base::Value> default_values_; 189 ScopedVector<base::Value> default_values_;
188 ScopedVector<base::Value> non_default_values_; 190 ScopedVector<base::Value> non_default_values_;
189 191
190 private: 192 private:
191 DISALLOW_COPY_AND_ASSIGN(PreferencesBrowserTest); 193 DISALLOW_COPY_AND_ASSIGN(PreferencesBrowserTest);
192 }; 194 };
193 195
194 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_ 196 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PREFERENCES_BROWSERTEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/preferences_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698