Chromium Code Reviews| Index: chrome/browser/profile_resetter/resettable_settings_snapshot.cc |
| diff --git a/chrome/browser/profile_resetter/resettable_settings_snapshot.cc b/chrome/browser/profile_resetter/resettable_settings_snapshot.cc |
| index d108b00bbcc301e28c705cfa10cad921cbb6b202..cde145c2c08ebf9aeccb84426377a6297ee3abae 100644 |
| --- a/chrome/browser/profile_resetter/resettable_settings_snapshot.cc |
| +++ b/chrome/browser/profile_resetter/resettable_settings_snapshot.cc |
| @@ -6,13 +6,20 @@ |
| #include "base/json/json_writer.h" |
| #include "base/prefs/pref_service.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "base/values.h" |
| +#include "chrome/browser/browser_process.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/feedback/feedback_data.h" |
| #include "chrome/browser/feedback/feedback_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/template_url_service.h" |
| #include "chrome/browser/search_engines/template_url_service_factory.h" |
| +#include "chrome/common/chrome_version_info.h" |
| #include "chrome/common/pref_names.h" |
| +#include "grit/generated_resources.h" |
| +#include "grit/google_chrome_strings.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| namespace { |
| @@ -27,6 +34,13 @@ const char kHomepagePath[] = "homepage"; |
| const char kStartupTypePath[] = "startup_type"; |
| const char kStartupURLPath[] = "startup_urls"; |
| +void AddPair(ListValue* list, const string16& key, const string16& value) { |
| + DictionaryValue* results = new DictionaryValue(); |
| + results->SetString("key", key); |
| + results->SetString("value", value); |
| + list->Append(results); |
| +} |
| + |
| } // namespace |
| ResettableSettingsSnapshot::ResettableSettingsSnapshot(Profile* profile) |
| @@ -43,8 +57,10 @@ ResettableSettingsSnapshot::ResettableSettingsSnapshot(Profile* profile) |
| TemplateURLServiceFactory::GetForProfile(profile); |
| DCHECK(service); |
| TemplateURL* dse = service->GetDefaultSearchProvider(); |
| - if (dse) |
| + if (dse) { |
| dse_url_ = dse->url(); |
| + dse_host_ = TemplateURLService::GenerateSearchURL(dse).host(); |
| + } |
| ExtensionService* extension_service = profile->GetExtensionService(); |
| DCHECK(extension_service); |
| @@ -162,3 +178,80 @@ void SendSettingsFeedback(const std::string& report, Profile* profile) { |
| feedback_util::SendReport(feedback_data); |
| } |
| + |
| +ListValue* GetReadableFeedback(const ResettableSettingsSnapshot& snapshot) { |
| + ListValue* list = new ListValue; |
| + AddPair(list, l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_LOCALE), |
| + ASCIIToUTF16(g_browser_process->GetApplicationLocale())); |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_USER_AGENT), |
| + ASCIIToUTF16(content::GetUserAgent(GURL()))); |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_CATEGORY), |
| + 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.
|
| + chrome::VersionInfo version_info; |
| + std::string version = version_info.Version(); |
| + version += chrome::VersionInfo::GetVersionStringModifier(); |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| + ASCIIToUTF16(version)); |
| + |
| + // Add |snapshot| data. |
| + const std::vector<GURL>& urls = snapshot.startup_urls(); |
| + std::string startup_urls; |
| + for (std::vector<GURL>::const_iterator i = urls.begin(); |
| + i != urls.end(); ++i) { |
| + (startup_urls += i->host()) += ' '; |
| + } |
| + if (!startup_urls.empty()) { |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_STARTUP_URLS), |
| + ASCIIToUTF16(startup_urls)); |
| + } |
| + |
| + string16 startup_type; |
| + switch (snapshot.startup_type()) { |
| + case SessionStartupPref::DEFAULT: |
| + startup_type = l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_NEWTAB); |
| + break; |
| + case SessionStartupPref::LAST: |
| + startup_type = l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION); |
| + break; |
| + case SessionStartupPref::URLS: |
| + startup_type = l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_PAGES); |
| + break; |
| + default: |
| + break; |
| + } |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_STARTUP_TYPE), |
| + startup_type); |
| + if (!snapshot.homepage().empty()) { |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_HOMEPAGE), |
| + ASCIIToUTF16(snapshot.homepage())); |
| + } |
| + int is_ntp_message_id = snapshot.homepage_is_ntp() ? |
| + IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP_TRUE : |
| + IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP_FALSE; |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_HOMEPAGE_IS_NTP), |
| + l10n_util::GetStringUTF16(is_ntp_message_id)); |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_DSE), |
| + ASCIIToUTF16(snapshot.dse_host())); |
| + |
| + const std::vector<std::string>& extensions = snapshot.enabled_extensions(); |
| + std::string extension_ids; |
| + for (std::vector<std::string>::const_iterator i = extensions.begin(); |
| + i != extensions.end(); ++i) { |
| + (extension_ids += *i) += ' '; |
|
battre
2013/09/06 08:42:45
nit: two spaces before +=
vasilii
2013/09/06 12:39:22
Done.
|
| + } |
| + if (!extension_ids.empty()) { |
| + AddPair(list, |
| + l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_EXTENSIONS), |
| + ASCIIToUTF16(extension_ids)); |
| + } |
| + return list; |
| +} |