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

Side by Side Diff: chrome/browser/profile_resetter/resettable_settings_snapshot.cc

Issue 23450021: Profile Reset dialog: the new section with detailed feedback information (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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) 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/resettable_settings_snapshot.h" 5 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/feedback/feedback_data.h" 13 #include "chrome/browser/feedback/feedback_data.h"
11 #include "chrome/browser/feedback/feedback_util.h" 14 #include "chrome/browser/feedback/feedback_util.h"
12 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service.h" 16 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
18 #include "chrome/common/chrome_version_info.h"
15 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "grit/generated_resources.h"
21 #include "grit/google_chrome_strings.h"
22 #include "ui/base/l10n/l10n_util.h"
16 23
17 namespace { 24 namespace {
18 25
19 // Feedback bucket label. 26 // Feedback bucket label.
20 const char kProfileResetFeedbackBucket[] = "ProfileResetReport"; 27 const char kProfileResetFeedbackBucket[] = "ProfileResetReport";
21 28
22 // Dictionary keys for feedback report. 29 // Dictionary keys for feedback report.
23 const char kDefaultSearchEnginePath[] = "default_search_engine"; 30 const char kDefaultSearchEnginePath[] = "default_search_engine";
24 const char kEnabledExtensions[] = "enabled_extensions"; 31 const char kEnabledExtensions[] = "enabled_extensions";
25 const char kHomepageIsNewTabPage[] = "homepage_is_ntp"; 32 const char kHomepageIsNewTabPage[] = "homepage_is_ntp";
26 const char kHomepagePath[] = "homepage"; 33 const char kHomepagePath[] = "homepage";
27 const char kStartupTypePath[] = "startup_type"; 34 const char kStartupTypePath[] = "startup_type";
28 const char kStartupURLPath[] = "startup_urls"; 35 const char kStartupURLPath[] = "startup_urls";
29 36
37 void AddPair(ListValue* list, const string16& key, const string16& value) {
38 DictionaryValue* results = new DictionaryValue();
39 results->SetString("key", key);
40 results->SetString("value", value);
41 list->Append(results);
42 }
43
30 } // namespace 44 } // namespace
31 45
32 ResettableSettingsSnapshot::ResettableSettingsSnapshot(Profile* profile) 46 ResettableSettingsSnapshot::ResettableSettingsSnapshot(Profile* profile)
33 : startup_(SessionStartupPref::GetStartupPref(profile)) { 47 : startup_(SessionStartupPref::GetStartupPref(profile)) {
34 // URLs are always stored sorted. 48 // URLs are always stored sorted.
35 std::sort(startup_.urls.begin(), startup_.urls.end()); 49 std::sort(startup_.urls.begin(), startup_.urls.end());
36 50
37 PrefService* prefs = profile->GetPrefs(); 51 PrefService* prefs = profile->GetPrefs();
38 DCHECK(prefs); 52 DCHECK(prefs);
39 homepage_ = prefs->GetString(prefs::kHomePage); 53 homepage_ = prefs->GetString(prefs::kHomePage);
40 homepage_is_ntp_ = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); 54 homepage_is_ntp_ = prefs->GetBoolean(prefs::kHomePageIsNewTabPage);
41 55
42 TemplateURLService* service = 56 TemplateURLService* service =
43 TemplateURLServiceFactory::GetForProfile(profile); 57 TemplateURLServiceFactory::GetForProfile(profile);
44 DCHECK(service); 58 DCHECK(service);
45 TemplateURL* dse = service->GetDefaultSearchProvider(); 59 TemplateURL* dse = service->GetDefaultSearchProvider();
46 if (dse) 60 if (dse) {
47 dse_url_ = dse->url(); 61 dse_url_ = dse->url();
62 dse_host_ = TemplateURLService::GenerateSearchURL(dse).host();
63 }
48 64
49 ExtensionService* extension_service = profile->GetExtensionService(); 65 ExtensionService* extension_service = profile->GetExtensionService();
50 DCHECK(extension_service); 66 DCHECK(extension_service);
51 const ExtensionSet* enabled_ext = extension_service->extensions(); 67 const ExtensionSet* enabled_ext = extension_service->extensions();
52 enabled_extensions_.reserve(enabled_ext->size()); 68 enabled_extensions_.reserve(enabled_ext->size());
53 69
54 for (ExtensionSet::const_iterator it = enabled_ext->begin(); 70 for (ExtensionSet::const_iterator it = enabled_ext->begin();
55 it != enabled_ext->end(); ++it) 71 it != enabled_ext->end(); ++it)
56 enabled_extensions_.push_back((*it)->id()); 72 enabled_extensions_.push_back((*it)->id());
57 73
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 feedback_data->set_description(report); 171 feedback_data->set_description(report);
156 172
157 feedback_data->set_image(scoped_ptr<std::string>(new std::string)); 173 feedback_data->set_image(scoped_ptr<std::string>(new std::string));
158 feedback_data->set_profile(profile); 174 feedback_data->set_profile(profile);
159 175
160 feedback_data->set_page_url(""); 176 feedback_data->set_page_url("");
161 feedback_data->set_user_email(""); 177 feedback_data->set_user_email("");
162 178
163 feedback_util::SendReport(feedback_data); 179 feedback_util::SendReport(feedback_data);
164 } 180 }
181
182 ListValue* GetReadableFeedback(const ResettableSettingsSnapshot& snapshot) {
183 ListValue* list = new ListValue;
184 AddPair(list, l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_LOCALE),
185 ASCIIToUTF16(g_browser_process->GetApplicationLocale()));
186 AddPair(list,
187 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_USER_AGENT),
188 ASCIIToUTF16(content::GetUserAgent(GURL())));
189 AddPair(list,
190 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_CATEGORY),
191 ASCIIToUTF16(kProfileResetFeedbackBucket));
battre 2013/09/06 08:42:45 I would remove this, it is a technicality.
vasilii 2013/09/06 12:39:22 Done.
192 chrome::VersionInfo version_info;
193 std::string version = version_info.Version();
194 version += chrome::VersionInfo::GetVersionStringModifier();
195 AddPair(list,
196 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
197 ASCIIToUTF16(version));
198
199 // Add |snapshot| data.
200 const std::vector<GURL>& urls = snapshot.startup_urls();
201 std::string startup_urls;
202 for (std::vector<GURL>::const_iterator i = urls.begin();
203 i != urls.end(); ++i) {
204 (startup_urls += i->host()) += ' ';
205 }
206 if (!startup_urls.empty()) {
207 AddPair(list,
208 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_STARTUP_URLS),
209 ASCIIToUTF16(startup_urls));
210 }
211
212 string16 startup_type;
213 switch (snapshot.startup_type()) {
214 case SessionStartupPref::DEFAULT:
215 startup_type = l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_NEWTAB);
216 break;
217 case SessionStartupPref::LAST:
218 startup_type = l10n_util::GetStringUTF16(
219 IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION);
220 break;
221 case SessionStartupPref::URLS:
222 startup_type = l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_PAGES);
223 break;
224 default:
225 break;
226 }
227 AddPair(list,
228 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_STARTUP_TYPE),
229 startup_type);
230 if (!snapshot.homepage().empty()) {
231 AddPair(list,
232 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_HOMEPAGE),
233 ASCIIToUTF16(snapshot.homepage()));
234 }
235 int is_ntp_message_id = snapshot.homepage_is_ntp() ?
236 IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP_TRUE :
237 IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP_FALSE;
238 AddPair(list,
239 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP),
240 l10n_util::GetStringUTF16(is_ntp_message_id));
241 AddPair(list,
242 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_DSE),
243 ASCIIToUTF16(snapshot.dse_host()));
244
245 const std::vector<std::string>& extensions = snapshot.enabled_extensions();
246 std::string extension_ids;
247 for (std::vector<std::string>::const_iterator i = extensions.begin();
248 i != extensions.end(); ++i) {
249 (extension_ids += *i) += ' ';
battre 2013/09/06 08:42:45 nit: two spaces before +=
vasilii 2013/09/06 12:39:22 Done.
250 }
251 if (!extension_ids.empty()) {
252 AddPair(list,
253 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_EXTENSIONS),
254 ASCIIToUTF16(extension_ids));
255 }
256 return list;
257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698