| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/activity_log/dom_actions.h" | 8 #include "chrome/browser/extensions/activity_log/dom_actions.h" |
| 9 #include "chrome/browser/history/url_database.h" | 9 #include "chrome/browser/history/url_database.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 | 11 |
| 12 using content::BrowserThread; | 12 using content::BrowserThread; |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 const char* DOMAction::kTableName = "activitylog_urls"; | 16 const char* DOMAction::kTableName = "activitylog_urls"; |
| 17 const char* DOMAction::kTableContentFields[] = | 17 const char* DOMAction::kTableContentFields[] = |
| 18 {"url_action_type", "url", "url_title", "api_call", "args", "extra"}; | 18 {"url_action_type", "url", "url_title", "api_call", "args", "extra"}; |
| 19 const char* DOMAction::kTableFieldTypes[] = | 19 const char* DOMAction::kTableFieldTypes[] = |
| 20 {"INTEGER", "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR", | 20 {"INTEGER", "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR", |
| 21 "LONGVARCHAR"}; | 21 "LONGVARCHAR"}; |
| 22 | 22 |
| 23 DOMAction::DOMAction(const std::string& extension_id, | 23 DOMAction::DOMAction(const std::string& extension_id, |
| 24 const base::Time& time, | 24 const base::Time& time, |
| 25 const DOMActionType verb, | 25 const DomActionType::Type verb, |
| 26 const GURL& url, | 26 const GURL& url, |
| 27 const string16& url_title, | 27 const string16& url_title, |
| 28 const std::string& api_call, | 28 const std::string& api_call, |
| 29 const std::string& args, | 29 const std::string& args, |
| 30 const std::string& extra) | 30 const std::string& extra) |
| 31 : Action(extension_id, time), | 31 : Action(extension_id, time), |
| 32 verb_(verb), | 32 verb_(verb), |
| 33 url_(url), | 33 url_(url), |
| 34 url_title_(url_title), | 34 url_title_(url_title), |
| 35 api_call_(api_call), | 35 api_call_(api_call), |
| 36 args_(args), | 36 args_(args), |
| 37 extra_(extra) { } | 37 extra_(extra) { } |
| 38 | 38 |
| 39 DOMAction::DOMAction(const sql::Statement& s) | 39 DOMAction::DOMAction(const sql::Statement& s) |
| 40 : Action(s.ColumnString(0), | 40 : Action(s.ColumnString(0), |
| 41 base::Time::FromInternalValue(s.ColumnInt64(1))), | 41 base::Time::FromInternalValue(s.ColumnInt64(1))), |
| 42 verb_(static_cast<DOMActionType>(s.ColumnInt(2))), | 42 verb_(static_cast<DomActionType::Type>(s.ColumnInt(2))), |
| 43 url_(GURL(s.ColumnString(3))), | 43 url_(GURL(s.ColumnString(3))), |
| 44 url_title_(s.ColumnString16(4)), | 44 url_title_(s.ColumnString16(4)), |
| 45 api_call_(s.ColumnString(5)), | 45 api_call_(s.ColumnString(5)), |
| 46 args_(s.ColumnString(6)), | 46 args_(s.ColumnString(6)), |
| 47 extra_(s.ColumnString(7)) { } | 47 extra_(s.ColumnString(7)) { } |
| 48 | 48 |
| 49 DOMAction::~DOMAction() { | 49 DOMAction::~DOMAction() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 statement.BindString(3, history::URLDatabase::GURLToDatabaseURL(url_)); | 93 statement.BindString(3, history::URLDatabase::GURLToDatabaseURL(url_)); |
| 94 statement.BindString16(4, url_title_); | 94 statement.BindString16(4, url_title_); |
| 95 statement.BindString(5, api_call_); | 95 statement.BindString(5, api_call_); |
| 96 statement.BindString(6, args_); | 96 statement.BindString(6, args_); |
| 97 statement.BindString(7, extra_); | 97 statement.BindString(7, extra_); |
| 98 if (!statement.Run()) | 98 if (!statement.Run()) |
| 99 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; | 99 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::string DOMAction::PrintForDebug() { | 102 std::string DOMAction::PrintForDebug() { |
| 103 if (verb_ == INSERTED) | 103 if (verb_ == DomActionType::INSERTED) |
| 104 return "Injected scripts (" + args_ + ") onto " | 104 return "Injected scripts (" + args_ + ") onto " |
| 105 + std::string(url_.spec()); | 105 + std::string(url_.spec()); |
| 106 else | 106 else |
| 107 return "DOM API CALL: " + api_call_ + ", ARGS: " + args_ + ", VERB: " | 107 return "DOM API CALL: " + api_call_ + ", ARGS: " + args_ + ", VERB: " |
| 108 + VerbAsString(); | 108 + VerbAsString(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::string DOMAction::VerbAsString() const { | 111 std::string DOMAction::VerbAsString() const { |
| 112 switch (verb_) { | 112 switch (verb_) { |
| 113 case GETTER: | 113 case DomActionType::GETTER: |
| 114 return "GETTER"; | 114 return "GETTER"; |
| 115 case SETTER: | 115 case DomActionType::SETTER: |
| 116 return "SETTER"; | 116 return "SETTER"; |
| 117 case METHOD: | 117 case DomActionType::METHOD: |
| 118 return "METHOD"; | 118 return "METHOD"; |
| 119 case INSERTED: | 119 case DomActionType::INSERTED: |
| 120 return "INSERTED"; | 120 return "INSERTED"; |
| 121 case XHR: | 121 case DomActionType::XHR: |
| 122 return "XHR"; | 122 return "XHR"; |
| 123 case WEBREQUEST: | 123 case DomActionType::WEBREQUEST: |
| 124 return "WEBREQUEST"; | 124 return "WEBREQUEST"; |
| 125 case MODIFIED: // legacy | 125 case DomActionType::MODIFIED: // legacy |
| 126 return "MODIFIED"; | 126 return "MODIFIED"; |
| 127 default: | 127 default: |
| 128 NOTREACHED(); | 128 NOTREACHED(); |
| 129 return NULL; | 129 return NULL; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace extensions | 133 } // namespace extensions |
| OLD | NEW |