OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
11 #include "base/synchronization/cancellation_flag.h" | 11 #include "base/synchronization/cancellation_flag.h" |
12 #include "chrome/browser/browser_process.h" | |
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/google/google_url_tracker_factory.h" | 15 #include "chrome/browser/google/google_url_tracker_factory.h" |
17 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" | 16 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_iterator.h" | 20 #include "chrome/browser/ui/browser_iterator.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "chrome/installer/util/browser_distribution.h" | 23 #include "chrome/installer/util/browser_distribution.h" |
25 #include "components/google/core/browser/google_pref_names.h" | 24 #include "components/google/core/browser/google_pref_names.h" |
26 #include "components/google/core/browser/google_url_tracker.h" | 25 #include "components/google/core/browser/google_url_tracker.h" |
27 #include "components/search_engines/search_engines_pref_names.h" | 26 #include "components/search_engines/search_engines_pref_names.h" |
28 #include "components/search_engines/template_url_prepopulate_data.h" | 27 #include "components/search_engines/template_url_prepopulate_data.h" |
29 #include "components/search_engines/template_url_service.h" | 28 #include "components/search_engines/template_url_service.h" |
30 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
31 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
32 #include "extensions/browser/management_policy.h" | 31 #include "extensions/browser/management_policy.h" |
33 | 32 |
34 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
35 #include "base/base_paths.h" | 34 #include "base/base_paths.h" |
36 #include "base/path_service.h" | 35 #include "base/path_service.h" |
37 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" | |
38 #include "chrome/installer/util/shell_util.h" | 36 #include "chrome/installer/util/shell_util.h" |
39 | 37 |
40 namespace { | 38 namespace { |
41 | 39 |
42 void ResetShortcutsOnFileThread() { | 40 void ResetShortcutsOnFileThread() { |
43 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
44 // Get full path of chrome. | 42 // Get full path of chrome. |
45 base::FilePath chrome_exe; | 43 base::FilePath chrome_exe; |
46 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) | 44 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
47 return; | 45 return; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }; | 117 }; |
120 | 118 |
121 ResettableFlags reset_triggered_for_flags = 0; | 119 ResettableFlags reset_triggered_for_flags = 0; |
122 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(flagToMethod); ++i) { | 120 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(flagToMethod); ++i) { |
123 if (resettable_flags & flagToMethod[i].flag) { | 121 if (resettable_flags & flagToMethod[i].flag) { |
124 reset_triggered_for_flags |= flagToMethod[i].flag; | 122 reset_triggered_for_flags |= flagToMethod[i].flag; |
125 (this->*flagToMethod[i].method)(); | 123 (this->*flagToMethod[i].method)(); |
126 } | 124 } |
127 } | 125 } |
128 | 126 |
129 // When the user resets any of their settings on Windows and agreed to sending | |
130 // feedback, run the software reporter tool to see if it could find the reason | |
131 // why the user wanted a reset. | |
132 #if defined(OS_WIN) | |
133 // The browser process and / or local_state can be NULL when running tests. | |
134 if (accepted_send_feedback && g_browser_process && | |
135 g_browser_process->local_state() && | |
136 g_browser_process->local_state()->GetBoolean( | |
137 prefs::kMetricsReportingEnabled)) { | |
138 ExecuteSwReporter(g_browser_process->component_updater(), | |
139 g_browser_process->local_state()); | |
140 } | |
141 #endif | |
142 | |
143 DCHECK_EQ(resettable_flags, reset_triggered_for_flags); | 127 DCHECK_EQ(resettable_flags, reset_triggered_for_flags); |
144 } | 128 } |
145 | 129 |
146 bool ProfileResetter::IsActive() const { | 130 bool ProfileResetter::IsActive() const { |
147 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 131 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
148 return pending_reset_flags_ != 0; | 132 return pending_reset_flags_ != 0; |
149 } | 133 } |
150 | 134 |
151 void ProfileResetter::MarkAsDone(Resettable resettable) { | 135 void ProfileResetter::MarkAsDone(Resettable resettable) { |
152 DCHECK(CalledOnValidThread()); | 136 DCHECK(CalledOnValidThread()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 chrome_exe, | 348 chrome_exe, |
365 false, | 349 false, |
366 cancel, | 350 cancel, |
367 &shortcuts); | 351 &shortcuts); |
368 } | 352 } |
369 return shortcuts; | 353 return shortcuts; |
370 #else | 354 #else |
371 return std::vector<ShortcutCommand>(); | 355 return std::vector<ShortcutCommand>(); |
372 #endif | 356 #endif |
373 } | 357 } |
OLD | NEW |