| Index: chrome/browser/webdata/keyword_table.cc
|
| diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc
|
| index e6cf033cb81f01baedb7b5ac05fc21a098a9b59a..84d6bd57362f30d6ab91405604375fcdfa37dac7 100644
|
| --- a/chrome/browser/webdata/keyword_table.cc
|
| +++ b/chrome/browser/webdata/keyword_table.cc
|
| @@ -10,8 +10,8 @@
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/history/history_database.h"
|
| +#include "chrome/browser/protector/protector.h"
|
| #include "chrome/browser/search_engines/template_url.h"
|
| -#include "crypto/hmac.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "sql/statement.h"
|
|
|
| @@ -26,11 +26,6 @@ const int kUrlIdPosition = 18;
|
| const char kDefaultSearchProviderKey[] = "Default Search Provider ID";
|
| const char kBuiltinKeywordVersion[] = "Builtin Keyword Version";
|
|
|
| -// Key for signing the default search provider backup.
|
| -// TOOD(avayvod): Add key for Google Chrome to internal repository.
|
| -const char kDefaultSearchProviderBackupSigningKey[] =
|
| - "Please, don't change default search engine!";
|
| -
|
| // Meta table key to store backup value for the default search provider.
|
| const char kDefaultSearchProviderBackupKey[] =
|
| "Default Search Provider ID Backup";
|
| @@ -76,14 +71,7 @@ void BindURLToStatement(const TemplateURL& url, sql::Statement* s) {
|
|
|
| // Signs search provider id and returns its signature.
|
| std::string GetSearchProviderIDSignature(int64 id) {
|
| - crypto::HMAC hmac(crypto::HMAC::SHA256);
|
| - DCHECK(hmac.Init(kDefaultSearchProviderBackupSigningKey));
|
| -
|
| - std::string id_to_sign(base::Int64ToString(id));
|
| - std::vector<unsigned char> digest(hmac.DigestLength());
|
| - DCHECK(hmac.Sign(id_to_sign, &digest[0], digest.size()));
|
| -
|
| - return std::string(&digest[0], &digest[0] + digest.size());
|
| + return protector::SignSetting(base::Int64ToString(id));
|
| }
|
|
|
| // Checks if signature for search provider id is correct and returns the
|
| @@ -266,21 +254,30 @@ bool KeywordTable::SetDefaultSearchProviderID(int64 id) {
|
| int64 KeywordTable::GetDefaultSearchProviderID() {
|
| int64 value = 0;
|
| meta_table_->GetValue(kDefaultSearchProviderKey, &value);
|
| + return value;
|
| +}
|
| +
|
| +int64 KeywordTable::GetDefaultSearchProviderIDBackup() {
|
| int64 backup_value = 0;
|
| meta_table_->GetValue(kDefaultSearchProviderBackupKey, &backup_value);
|
| std::string backup_signature;
|
| meta_table_->GetValue(
|
| kDefaultSearchProviderBackupSignatureKey, &backup_signature);
|
| - 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;
|
| - }
|
| - return value;
|
| + if (!IsSearchProviderIDValid(backup_value, backup_signature))
|
| + return 0;
|
| + return backup_value;
|
| +}
|
| +
|
| +bool KeywordTable::DidDefaultSearchProviderChange() {
|
| + int64 backup_value = 0;
|
| + meta_table_->GetValue(kDefaultSearchProviderBackupKey, &backup_value);
|
| + std::string backup_signature;
|
| + meta_table_->GetValue(
|
| + kDefaultSearchProviderBackupSignatureKey, &backup_signature);
|
| + if (IsSearchProviderIDValid(backup_value, backup_signature) &&
|
| + backup_value == GetDefaultSearchProviderID())
|
| + return false;
|
| + return true;
|
| }
|
|
|
| bool KeywordTable::SetBuiltinKeywordVersion(int version) {
|
|
|