diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 12:58:04 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 12:58:04 +0000 |
commit | 75b99eb6f4707d34457edc5293372478c2275029 (patch) | |
tree | 06ef7d109958d426b34cfbd0303de51c3a00cf0e /chrome | |
parent | 65a48e5da2047807ae49ed160833a335576b7bb9 (diff) | |
download | chromium_src-75b99eb6f4707d34457edc5293372478c2275029.zip chromium_src-75b99eb6f4707d34457edc5293372478c2275029.tar.gz chromium_src-75b99eb6f4707d34457edc5293372478c2275029.tar.bz2 |
Added histograms for default search provider protection. Removed protection
R=ivankr@chromium.org
BUG=94447
TEST=Verify that changes of default search engine in Web Data before Chrome start are not overridden but chrome://histograms shows ProtectorError.DefaultSearchProvider field.
Review URL: http://codereview.chromium.org/8393052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107336 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/webdata/keyword_table.cc | 33 | ||||
-rw-r--r-- | chrome/browser/webdata/keyword_table_unittest.cc | 3 |
2 files changed, 28 insertions, 8 deletions
diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc index e6cf033..1258f89 100644 --- a/chrome/browser/webdata/keyword_table.cc +++ b/chrome/browser/webdata/keyword_table.cc @@ -5,6 +5,7 @@ #include "chrome/browser/webdata/keyword_table.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" @@ -40,6 +41,20 @@ const char kDefaultSearchProviderBackupKey[] = const char kDefaultSearchProviderBackupSignatureKey[] = "Default Search Provider ID Backup Signature"; +// Histogram name to report protection errors for the default search +// provider. +const char kProtectorHistogramDefaultSearchProvider[] = + "Protector.DefaultSearchProvider"; + +// Protector histogram values. TODO(avayvod): Move to protector.h/cc +enum ProtectorError { + kProtectorErrorBackupInvalid, + kProtectorErrorValueChanged, + + // This is for convenience only, must always be the last. + kProtectorErrorCount +}; + void BindURLToStatement(const TemplateURL& url, sql::Statement* s) { s->BindString(0, UTF16ToUTF8(url.short_name())); s->BindString(1, UTF16ToUTF8(url.keyword())); @@ -271,14 +286,18 @@ int64 KeywordTable::GetDefaultSearchProviderID() { std::string backup_signature; meta_table_->GetValue( kDefaultSearchProviderBackupSignatureKey, &backup_signature); + // For now only track how often signature or backup is lost or value is + // changed. Don't change the value since UI is not working yet. if (!IsSearchProviderIDValid(backup_value, backup_signature)) { - // TODO(avayvod): Notify UI about the setting having been hijacked and - // the backup value lost. - return value; - } - if (value != backup_value) { - // TODO(avayvod): Notify UI about the setting having been hijacked. - return backup_value; + UMA_HISTOGRAM_ENUMERATION(kProtectorHistogramDefaultSearchProvider, + kProtectorErrorBackupInvalid, + kProtectorErrorCount); + SetDefaultSearchProviderBackupID(value); + } else if (value != backup_value) { + UMA_HISTOGRAM_ENUMERATION(kProtectorHistogramDefaultSearchProvider, + kProtectorErrorValueChanged, + kProtectorErrorCount); + SetDefaultSearchProviderBackupID(value); } return value; } diff --git a/chrome/browser/webdata/keyword_table_unittest.cc b/chrome/browser/webdata/keyword_table_unittest.cc index 884b8df..595dcb15 100644 --- a/chrome/browser/webdata/keyword_table_unittest.cc +++ b/chrome/browser/webdata/keyword_table_unittest.cc @@ -166,8 +166,9 @@ TEST_F(KeywordTableTest, DefaultSearchProviderBackup) { ASSERT_TRUE(db.GetKeywordTable()->SetDefaultSearchProviderID(10)); EXPECT_EQ(10, db.GetKeywordTable()->GetDefaultSearchProviderID()); + // Verify that backup doesn't affect the actual value for now. ASSERT_TRUE(db.GetKeywordTable()->SetDefaultSearchProviderBackupID(11)); - EXPECT_EQ(11, db.GetKeywordTable()->GetDefaultSearchProviderID()); + EXPECT_EQ(10, db.GetKeywordTable()->GetDefaultSearchProviderID()); } TEST_F(KeywordTableTest, UpdateKeyword) { |