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

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

Issue 8342049: Added Protector, hooked up DSE verification with error bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved histograms to protector folder Created 9 years, 2 months 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
new file mode 100644
index 0000000000000000000000000000000000000000..f3acacabad63f29f393c37bb108ccdad0fce94d2
--- /dev/null
+++ b/chrome/browser/protector/protector.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/protector/protector.h"
+
+#include "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/protector/settings_change_global_error.h"
+#include "chrome/browser/protector/keys.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/browser/browser_thread.h"
+#include "content/public/browser/notification_source.h"
+#include "crypto/hmac.h"
+
+namespace protector {
+
+Protector::Protector(Profile* profile)
+ : profile_(profile) {
+}
+
+Protector::~Protector() {
+}
+
+void Protector::OpenTab(const GURL& url) {
+ if (!error_.get() || !error_->browser()) {
+ LOG(WARNING) << "Don't have browser to show tab in.";
+ return;
+ }
+ error_->browser()->ShowSingletonTab(url);
+}
+
+TemplateURLService* Protector::GetTemplateURLService() {
+ return TemplateURLServiceFactory::GetForProfile(profile_);
+}
+
+void Protector::ShowChange(SettingChange* change) {
+ DCHECK(change);
+ SettingChangeVector changes(1, change);
+
+ error_.reset(new SettingsChangeGlobalError(changes, this));
+ error_->ShowForProfile(profile_);
+}
+
+void Protector::OnApplyChanges() {
+ OnChangesAction(&SettingChange::Accept);
+}
+
+void Protector::OnDiscardChanges() {
+ OnChangesAction(&SettingChange::Revert);
+}
+
+void Protector::OnDecisionTimeout() {
+ OnChangesAction(&SettingChange::DoDefault);
+}
+
+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);
+ BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
+}
+
+
+std::string SignSetting(const std::string& value) {
+ crypto::HMAC hmac(crypto::HMAC::SHA256);
+ DCHECK(hmac.Init(kProtectorSigningKey));
+
+ std::vector<unsigned char> digest(hmac.DigestLength());
+ DCHECK(hmac.Sign(value, &digest[0], digest.size()));
+
+ return std::string(&digest[0], &digest[0] + digest.size());
+}
+
+} // namespace protector
« 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