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

Unified Diff: chrome/browser/extensions/blocked_actions.cc

Issue 11421192: Save extension activity log to a file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: something about lkgr Created 7 years, 11 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
Index: chrome/browser/extensions/blocked_actions.cc
===================================================================
--- chrome/browser/extensions/blocked_actions.cc (revision 0)
+++ chrome/browser/extensions/blocked_actions.cc (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 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 <string>
+#include "base/logging.h"
+#include "chrome/browser/extensions/blocked_actions.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace extensions {
+
+const char* BlockedAction::kTableName = "activitylog_blocked";
+const char* BlockedAction::kTableStructure = "("
+ "extension_id LONGVARCHAR NOT NULL, "
+ "time INTEGER NOT NULL, "
+ "blocked_action LONGVARCHAR NOT NULL, "
+ "reason LONGVARCHAR NOT NULL, "
+ "extra LONGVARCHAR NOT NULL)";
+
+BlockedAction::BlockedAction(const std::string& extension_id,
+ const base::Time& time,
+ const std::string& blocked_action,
+ const std::string& reason,
+ const std::string& extra)
+ : extension_id_(extension_id),
+ time_(time),
+ blocked_action_(blocked_action),
+ reason_(reason),
+ extra_(extra) { }
+
+BlockedAction::~BlockedAction() {
+}
+
+void BlockedAction::Record(sql::Connection* db) {
+ std::string sql_str = "INSERT INTO " + std::string(kTableName)
+ + " (extension_id, time, blocked_action, reason, extra) VALUES (?,?,?,?,?)";
+ sql::Statement statement(db->GetCachedStatement(
+ sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
+ statement.BindString(0, extension_id_);
+ statement.BindInt64(1, time().ToInternalValue());
+ statement.BindString(2, blocked_action_);
+ statement.BindString(3, reason_);
+ statement.BindString(4, extra_);
+ if (!statement.Run())
+ LOG(ERROR) << "Activity log database I/O failed: " << sql_str;
+}
+
+std::string BlockedAction::PrettyPrintFori18n() {
+ // TODO(felt): implement this for real when the UI is redesigned.
+ return PrettyPrintForDebug();
+}
+
+std::string BlockedAction::PrettyPrintForDebug() {
+ // TODO(felt): implement this for real when the UI is redesigned.
+ return "ID: " + extension_id_ + ", blocked action " + blocked_action_ +
+ ", reason: " + reason_;
+}
+
+} // namespace extensions
+
« no previous file with comments | « chrome/browser/extensions/blocked_actions.h ('k') | chrome/browser/extensions/extension_function_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698