OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // User of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/logging.h" |
| 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/extensions/url_actions.h" |
| 8 |
| 9 namespace extensions { |
| 10 |
| 11 const char* url_table_name_ = "activitylog_urls"; |
| 12 const char* url_table_structure_ = "(" |
| 13 "extension_id LONGVARCHAR NOT NULL, " |
| 14 "time INTEGER NOT NULL, " |
| 15 "url_action_type LONGVARCHAR NOT NULL, " |
| 16 "url LONGVARCHAR NOT NULL, " |
| 17 "url_title LONGVARCHAR, " |
| 18 "api_call LONGVARCHAR NOT NULL)"; |
| 19 |
| 20 UrlAction::UrlAction(const std::string& extension_id, |
| 21 const UrlActionType verb, |
| 22 const GURL& url, |
| 23 const string16& url_title, |
| 24 const std::string& ext_script, |
| 25 const base::Time& time) |
| 26 : extension_id_(extension_id), |
| 27 verb_(verb), |
| 28 url_(url), |
| 29 url_title_(url_title), |
| 30 script_(ext_script), |
| 31 time_(time) { } |
| 32 |
| 33 UrlAction::~UrlAction() { |
| 34 } |
| 35 |
| 36 std::string UrlAction::PrettyPrintFori18n() { |
| 37 // TODO(felt): implement this for real when the UI is redesigned. |
| 38 return PrettyPrintForDebug(); |
| 39 } |
| 40 |
| 41 std::string UrlAction::PrettyPrintForDebug() { |
| 42 // TODO(felt): implement this for real when the UI is redesigned. |
| 43 /*return "ID: " + extension_id_ + ", VERB: " + VerbAsString() + ", URL: " + |
| 44 std::string(url_.spec()) + ", URL TITLE: " + UTF16ToUTF8(url_title_) + |
| 45 ", SCRIPT: " + script_;*/ |
| 46 return "Injected scripts (" + script_ + ") onto " + std::string(url_.spec()); |
| 47 } |
| 48 |
| 49 std::string UrlAction::VerbAsString() const { |
| 50 switch (verb_) { |
| 51 case MODIFIED: |
| 52 return "MODIFIED"; |
| 53 case READ: |
| 54 return "READ"; |
| 55 case INSERTED: |
| 56 return "INSERTED"; |
| 57 case XHR: |
| 58 return "XHR"; |
| 59 default: |
| 60 NOTREACHED(); |
| 61 return NULL; |
| 62 } |
| 63 } |
| 64 |
| 65 UrlAction::UrlActionType UrlAction::StringAsUrlActionType( |
| 66 const std::string& str) { |
| 67 if (str == "MODIFIED") { |
| 68 return MODIFIED; |
| 69 } else if (str == "READ") { |
| 70 return READ; |
| 71 } else if (str == "INSERTED") { |
| 72 return INSERTED; |
| 73 } else if (str == "XHR") { |
| 74 return XHR; |
| 75 } else { |
| 76 NOTREACHED(); |
| 77 return MODIFIED; // this should never happen! |
| 78 } |
| 79 } |
| 80 |
| 81 } // namespace extensions |
| 82 |
OLD | NEW |