summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profile_resetter
diff options
context:
space:
mode:
authorvasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 11:52:13 +0000
committervasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 11:52:13 +0000
commit2ed8e5562ae013380a94b7ce34135438d3b99628 (patch)
tree770140456215746cc8acc649ebe373a0ec6c29b1 /chrome/browser/profile_resetter
parentaea7a676cf7d25f6427e6164a52dce986227df2e (diff)
downloadchromium_src-2ed8e5562ae013380a94b7ce34135438d3b99628.zip
chromium_src-2ed8e5562ae013380a94b7ce34135438d3b99628.tar.gz
chromium_src-2ed8e5562ae013380a94b7ce34135438d3b99628.tar.bz2
Profile Reset dialog: the new section with detailed feedback information.
BUG=266354 Review URL: https://chromiumcodereview.appspot.com/23450021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile_resetter')
-rw-r--r--chrome/browser/profile_resetter/profile_resetter_unittest.cc8
-rw-r--r--chrome/browser/profile_resetter/resettable_settings_snapshot.cc119
-rw-r--r--chrome/browser/profile_resetter/resettable_settings_snapshot.h17
3 files changed, 132 insertions, 12 deletions
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index 34b6110..1e6d0a0 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -726,7 +726,8 @@ TEST_F(ProfileResetterTest, CheckSnapshots) {
EXPECT_TRUE(empty_snap.homepage().empty());
EXPECT_TRUE(empty_snap.homepage_is_ntp());
EXPECT_NE(std::string::npos, empty_snap.dse_url().find("{google:baseURL}"));
- EXPECT_EQ(std::vector<std::string>(), empty_snap.enabled_extensions());
+ EXPECT_EQ(ResettableSettingsSnapshot::ExtensionList(),
+ empty_snap.enabled_extensions());
// Reset to organic defaults.
ResetAndWait(ProfileResetter::DEFAULT_SEARCH_ENGINE |
@@ -745,8 +746,9 @@ TEST_F(ProfileResetterTest, CheckSnapshots) {
EXPECT_EQ("http://www.foo.com", nonorganic_snap.homepage());
EXPECT_FALSE(nonorganic_snap.homepage_is_ntp());
EXPECT_EQ("http://www.foo.com/s?q={searchTerms}", nonorganic_snap.dse_url());
- EXPECT_EQ(std::vector<std::string>(1, ext_id),
- nonorganic_snap.enabled_extensions());
+ EXPECT_EQ(ResettableSettingsSnapshot::ExtensionList(
+ 1, std::make_pair(ext_id, "example")),
+ nonorganic_snap.enabled_extensions());
}
TEST_F(ProfileResetterTest, FeedbackSerializtionTest) {
diff --git a/chrome/browser/profile_resetter/resettable_settings_snapshot.cc b/chrome/browser/profile_resetter/resettable_settings_snapshot.cc
index d108b00..00cc474 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)
@@ -53,7 +67,7 @@ ResettableSettingsSnapshot::ResettableSettingsSnapshot(Profile* profile)
for (ExtensionSet::const_iterator it = enabled_ext->begin();
it != enabled_ext->end(); ++it)
- enabled_extensions_.push_back((*it)->id());
+ enabled_extensions_.push_back(std::make_pair((*it)->id(), (*it)->name()));
// ExtensionSet is sorted but it seems to be an implementation detail.
std::sort(enabled_extensions_.begin(), enabled_extensions_.end());
@@ -70,7 +84,7 @@ void ResettableSettingsSnapshot::Subtract(
std::back_inserter(urls));
startup_.urls.swap(urls);
- std::vector<std::string> extensions;
+ ExtensionList extensions;
std::set_difference(enabled_extensions_.begin(), enabled_extensions_.end(),
snapshot.enabled_extensions_.begin(),
snapshot.enabled_extensions_.end(),
@@ -134,10 +148,15 @@ std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot,
if (field_mask & ResettableSettingsSnapshot::EXTENSIONS) {
ListValue* list = new ListValue;
- const std::vector<std::string>& extensions = snapshot.enabled_extensions();
- for (std::vector<std::string>::const_iterator i = extensions.begin();
- i != extensions.end(); ++i)
- list->AppendString(*i);
+ const ResettableSettingsSnapshot::ExtensionList& extensions =
+ snapshot.enabled_extensions();
+ for (ResettableSettingsSnapshot::ExtensionList::const_iterator i =
+ extensions.begin(); i != extensions.end(); ++i) {
+ // Replace "\"" to simplify server-side analysis.
+ std::string ext_name;
+ ReplaceChars(i->second, "\"", "\'", &ext_name);
+ list->AppendString(i->first + ";" + ext_name);
+ }
dict.Set(kEnabledExtensions, list);
}
@@ -162,3 +181,91 @@ void SendSettingsFeedback(const std::string& report, Profile* profile) {
feedback_util::SendReport(feedback_data);
}
+
+ListValue* GetReadableFeedback(Profile* profile) {
+ DCHECK(profile);
+ 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())));
+ 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.
+ ResettableSettingsSnapshot snapshot(profile);
+ 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()) {
+ startup_urls.erase(startup_urls.end() - 1);
+ 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));
+
+ TemplateURLService* service =
+ TemplateURLServiceFactory::GetForProfile(profile);
+ DCHECK(service);
+ TemplateURL* dse = service->GetDefaultSearchProvider();
+ if (dse) {
+ AddPair(list,
+ l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_DSE),
+ ASCIIToUTF16(TemplateURLService::GenerateSearchURL(dse).host()));
+ }
+
+ const ResettableSettingsSnapshot::ExtensionList& extensions =
+ snapshot.enabled_extensions();
+ std::string extension_ids;
+ for (ResettableSettingsSnapshot::ExtensionList::const_iterator i =
+ extensions.begin(); i != extensions.end(); ++i) {
+ (extension_ids += i->second) += '\n';
+ }
+ if (!extension_ids.empty()) {
+ extension_ids.erase(extension_ids.end() - 1);
+ AddPair(list,
+ l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_EXTENSIONS),
+ ASCIIToUTF16(extension_ids));
+ }
+ return list;
+}
diff --git a/chrome/browser/profile_resetter/resettable_settings_snapshot.h b/chrome/browser/profile_resetter/resettable_settings_snapshot.h
index 9fcf1cb..c142d49 100644
--- a/chrome/browser/profile_resetter/resettable_settings_snapshot.h
+++ b/chrome/browser/profile_resetter/resettable_settings_snapshot.h
@@ -8,10 +8,17 @@
#include "base/basictypes.h"
#include "chrome/browser/prefs/session_startup_pref.h"
+namespace base {
+class ListValue;
+}
+
// ResettableSettingsSnapshot captures some settings values at constructor. It
// can calculate the difference between two snapshots. That is, modified fields.
class ResettableSettingsSnapshot {
public:
+ // ExtensionList is a vector of pairs. The first component is the extension
+ // id, the second is the name.
+ typedef std::vector<std::pair<std::string, std::string> > ExtensionList;
// All types of settings handled by this class.
enum Field {
STARTUP_URLS = 1 << 0,
@@ -39,7 +46,7 @@ class ResettableSettingsSnapshot {
const std::string& dse_url() const { return dse_url_; }
- const std::vector<std::string>& enabled_extensions() const {
+ const ExtensionList& enabled_extensions() const {
return enabled_extensions_;
}
@@ -65,8 +72,8 @@ class ResettableSettingsSnapshot {
// Default search engine.
std::string dse_url_;
- // Enabled extension ids. Always sorted.
- std::vector<std::string> enabled_extensions_;
+ // List of pairs [id, name] for enabled extensions. Always sorted.
+ ExtensionList enabled_extensions_;
DISALLOW_COPY_AND_ASSIGN(ResettableSettingsSnapshot);
};
@@ -80,4 +87,8 @@ std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot,
// SerializeSettingsReport().
void SendSettingsFeedback(const std::string& report, Profile* profile);
+// Returns list of key/value pairs for all reported information from the
+// |profile| and some additional fields.
+base::ListValue* GetReadableFeedback(Profile* profile);
+
#endif // CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_