Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: chrome/browser/protector/protector.cc

Issue 8558020: Protector strings and bubble/SettingsChange code refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: This time it really should compile. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/protector/protector.h ('k') | chrome/browser/protector/setting_change.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/protector/protector.h ('k') | chrome/browser/protector/setting_change.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698