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/utf_string_conversions.h" | |
6 #include "chrome/browser/extensions/url_actions.h" | |
7 | |
8 namespace extensions { | |
9 | |
10 const char* url_table_name_ = "activitylog_urls"; | |
11 const char* url_table_structure_ = "(" | |
12 "extension_id LONGVARCHAR NOT NULL, " | |
13 "time INTEGER NOT NULL, " | |
14 "url_action_type LONGVARCHAR NOT NULL, " | |
15 "url LONGVARCHAR NOT NULL, " | |
16 "url_title LONGVARCHAR, " | |
17 "api_call LONGVARCHAR NOT NULL)"; | |
18 | |
19 UrlAction::UrlAction(const std::string& extension_id, | |
20 const UrlActionType verb, | |
21 const GURL& url, | |
22 const string16& url_title, | |
23 const std::string& ext_script, | |
24 const base::Time& time) | |
25 : extension_id_(extension_id), | |
26 verb_(verb), | |
27 url_(url), | |
28 url_title_(url_title), | |
29 script_(ext_script), | |
30 time_(time) { } | |
31 | |
32 UrlAction::~UrlAction() { | |
33 } | |
34 | |
35 std::string UrlAction::PrettyPrintFori18n() { | |
36 // TODO(felt): implement this for real when the UI is redesigned. | |
37 return PrettyPrintForDebug(); | |
38 } | |
39 | |
40 std::string UrlAction::PrettyPrintForDebug() { | |
41 // TODO(felt): implement this for real when the UI is redesigned. | |
42 /*return "ID: " + extension_id_ + ", VERB: " + VerbAsString() + ", URL: " + | |
43 std::string(url_.spec()) + ", URL TITLE: " + UTF16ToUTF8(url_title_) + | |
44 ", SCRIPT: " + script_;*/ | |
45 return "Injected scripts (" + script_ + ") onto " + std::string(url_.spec()); | |
46 } | |
47 | |
48 std::string UrlAction::VerbAsString() const { | |
49 switch (verb_) { | |
50 case MODIFIED: | |
51 return "MODIFIED"; | |
52 case READ: | |
53 return "READ"; | |
54 case INSERTED: | |
55 return "INSERTED"; | |
56 case XHR: | |
57 return "XHR"; | |
58 default: | |
59 return "UNKNOWN"; | |
60 } | |
61 } | |
62 | |
63 UrlAction::UrlActionType UrlAction::StringAsUrlActionType( | |
64 const std::string& str) { | |
65 if (str == "MODIFIED") { | |
66 return MODIFIED; | |
67 } else if (str == "READ") { | |
68 return READ; | |
69 } else if (str == "INSERTED") { | |
70 return INSERTED; | |
71 } else if (str == "XHR") { | |
72 return XHR; | |
73 } else { | |
74 return UNKNOWN; // this should never happen! | |
Eric Dingle
2012/12/13 20:37:34
Perhaps use NOTREACHED() instead of having an UNKN
felt
2012/12/15 02:51:52
Done, although I still have to return *something*
| |
75 } | |
76 } | |
77 | |
78 } // namespace | |
79 | |
OLD | NEW |