| Index: chrome/browser/protector/protector.cc
|
| diff --git a/chrome/browser/protector/protector.cc b/chrome/browser/protector/protector.cc
|
| index 7fe13209fa1d6e966df7e3c334be3a267b599c7b..606302c69f25fa9875dd648c01cd72ea593c63db 100644
|
| --- a/chrome/browser/protector/protector.cc
|
| +++ b/chrome/browser/protector/protector.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/protector/protector.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/protector/settings_change_global_error.h"
|
| @@ -39,38 +40,45 @@ TemplateURLService* Protector::GetTemplateURLService() {
|
| return TemplateURLServiceFactory::GetForProfile(profile_);
|
| }
|
|
|
| -void Protector::ShowChange(SettingChange* change) {
|
| +void Protector::ShowChange(BaseSettingChange* change) {
|
| DCHECK(change);
|
| - SettingChangeVector changes(1, change);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&Protector::InitAndShowChange,
|
| + base::Unretained(this), change));
|
| +}
|
|
|
| - error_.reset(new SettingsChangeGlobalError(changes, this));
|
| +void Protector::InitAndShowChange(BaseSettingChange* change) {
|
| + VLOG(1) << "Init change";
|
| + if (!change->Init(this)) {
|
| + VLOG(1) << "Error while initializing, removing ourselves";
|
| + delete change;
|
| + OnRemovedFromProfile();
|
| + return;
|
| + }
|
| + error_.reset(new SettingsChangeGlobalError(change, this));
|
| error_->ShowForProfile(profile_);
|
| }
|
|
|
| -void Protector::OnApplyChanges() {
|
| - OnChangesAction(&SettingChange::Accept);
|
| +void Protector::OnApplyChange() {
|
| + VLOG(1) << "Apply change";
|
| + error_->mutable_change()->Apply(this);
|
| }
|
|
|
| -void Protector::OnDiscardChanges() {
|
| - OnChangesAction(&SettingChange::Revert);
|
| +void Protector::OnDiscardChange() {
|
| + VLOG(1) << "Discard change";
|
| + error_->mutable_change()->Discard(this);
|
| }
|
|
|
| void Protector::OnDecisionTimeout() {
|
| - OnChangesAction(&SettingChange::DoDefault);
|
| + // TODO(ivankr): Add histogram.
|
| + VLOG(1) << "Timeout";
|
| }
|
|
|
| void Protector::OnRemovedFromProfile() {
|
| BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
|
| }
|
|
|
| -void Protector::OnChangesAction(SettingChangeAction action) {
|
| - DCHECK(error_.get());
|
| - SettingChangeVector* changes = error_->mutable_changes();
|
| - for (SettingChangeVector::iterator it = changes->begin();
|
| - it != changes->end(); ++it)
|
| - ((*it)->*action)(this);
|
| -}
|
| -
|
|
|
| std::string SignSetting(const std::string& value) {
|
| crypto::HMAC hmac(crypto::HMAC::SHA256);
|
|
|