blob: e6f4beb0a9add0bdd6f58258f9addcd7b6556a5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// 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.
#ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_
#define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_
#include "chrome/browser/extensions/activity_log/activity_actions.h"
namespace extensions {
// This class describes API calls that ran into permissions or quota problems.
// See APIActions for API calls that succeeded.
class BlockedAction : public Action {
public:
// These values should not be changed. Append any additional values to the
// end with sequential numbers.
enum Reason {
UNKNOWN = 0,
ACCESS_DENIED = 1,
QUOTA_EXCEEDED = 2,
};
// You must supply the id, time, api_call, and reason.
BlockedAction(const std::string& extension_id,
const base::Time& time,
const std::string& api_call, // the blocked API call
const std::string& args, // the arguments
const Reason reason, // the reason it's blocked
const std::string& extra); // any extra logging info
// Record the action in the database.
virtual bool Record(sql::Connection* db) OVERRIDE;
virtual scoped_ptr<api::activity_log_private::ExtensionActivity>
ConvertToExtensionActivity() OVERRIDE;
// Print a BlockedAction as a string for debugging purposes.
virtual std::string PrintForDebug() OVERRIDE;
// Helper methods for recording the values into the db.
const std::string& api_call() const { return api_call_; }
const std::string& args() const { return args_; }
const std::string& extra() const { return extra_; }
// Helper method for debugging.
std::string ReasonAsString() const;
protected:
virtual ~BlockedAction();
private:
std::string api_call_;
std::string args_;
Reason reason_;
std::string extra_;
DISALLOW_COPY_AND_ASSIGN(BlockedAction);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_BLOCKED_ACTIONS_H_
|