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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6 #include "base/logging.h"
7 #include "chrome/browser/extensions/blocked_actions.h"
8 #include "content/public/browser/browser_thread.h"
9
10 using content::BrowserThread;
11
12 namespace extensions {
13
14 const char* BlockedAction::kTableName = "activitylog_blocked";
15 const char* BlockedAction::kTableStructure = "("
16 "extension_id LONGVARCHAR NOT NULL, "
17 "time INTEGER NOT NULL, "
18 "blocked_action LONGVARCHAR NOT NULL, "
19 "reason LONGVARCHAR NOT NULL, "
20 "extra LONGVARCHAR NOT NULL)";
21
22 BlockedAction::BlockedAction(const std::string& extension_id,
23 const base::Time& time,
24 const std::string& blocked_action,
25 const std::string& reason,
26 const std::string& extra)
27 : extension_id_(extension_id),
28 time_(time),
29 blocked_action_(blocked_action),
30 reason_(reason),
31 extra_(extra) { }
32
33 BlockedAction::~BlockedAction() {
34 }
35
36 void BlockedAction::Record(sql::Connection* db) {
37 std::string sql_str = "INSERT INTO " + std::string(kTableName)
38 + " (extension_id, time, blocked_action, reason, extra) VALUES (?,?,?,?,?)";
39 sql::Statement statement(db->GetCachedStatement(
40 sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
41 statement.BindString(0, extension_id_);
42 statement.BindInt64(1, time().ToInternalValue());
43 statement.BindString(2, blocked_action_);
44 statement.BindString(3, reason_);
45 statement.BindString(4, extra_);
46 if (!statement.Run())
47 LOG(ERROR) << "Activity log database I/O failed: " << sql_str;
48 }
49
50 std::string BlockedAction::PrettyPrintFori18n() {
51 // TODO(felt): implement this for real when the UI is redesigned.
52 return PrettyPrintForDebug();
53 }
54
55 std::string BlockedAction::PrettyPrintForDebug() {
56 // TODO(felt): implement this for real when the UI is redesigned.
57 return "ID: " + extension_id_ + ", blocked action " + blocked_action_ +
58 ", reason: " + reason_;
59 }
60
61 } // namespace extensions
62
OLDNEW
« 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