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

Unified Diff: chrome/browser/extensions/url_actions.cc

Issue 11421192: Save extension activity log to a file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: tryserver bugfix Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/url_actions.cc
===================================================================
--- chrome/browser/extensions/url_actions.cc (revision 0)
+++ chrome/browser/extensions/url_actions.cc (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// User of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/extensions/url_actions.h"
+
+namespace extensions {
+
+const char* url_table_name_ = "activitylog_urls";
+const char* url_table_structure_ = "("
+ "extension_id LONGVARCHAR NOT NULL, "
+ "time INTEGER NOT NULL, "
+ "url_action_type LONGVARCHAR NOT NULL, "
+ "url LONGVARCHAR NOT NULL, "
+ "url_title LONGVARCHAR, "
+ "api_call LONGVARCHAR NOT NULL)";
+
+UrlAction::UrlAction(const std::string& extension_id,
+ const UrlActionType verb,
+ const GURL& url,
+ const string16& url_title,
+ const std::string& ext_script,
+ const base::Time& time)
+ : extension_id_(extension_id),
+ verb_(verb),
+ url_(url),
+ url_title_(url_title),
+ script_(ext_script),
+ time_(time) { }
+
+UrlAction::~UrlAction() {
+}
+
+std::string UrlAction::PrettyPrintFori18n() {
+ // TODO(felt): implement this for real when the UI is redesigned.
+ return PrettyPrintForDebug();
+}
+
+std::string UrlAction::PrettyPrintForDebug() {
+ // TODO(felt): implement this for real when the UI is redesigned.
+ /*return "ID: " + extension_id_ + ", VERB: " + VerbAsString() + ", URL: " +
+ std::string(url_.spec()) + ", URL TITLE: " + UTF16ToUTF8(url_title_) +
+ ", SCRIPT: " + script_;*/
+ return "Injected scripts (" + script_ + ") onto " + std::string(url_.spec());
+}
+
+std::string UrlAction::VerbAsString() const {
+ switch (verb_) {
+ case MODIFIED:
+ return "MODIFIED";
+ case READ:
+ return "READ";
+ case INSERTED:
+ return "INSERTED";
+ case XHR:
+ return "XHR";
+ default:
+ NOTREACHED();
+ return NULL;
+ }
+}
+
+UrlAction::UrlActionType UrlAction::StringAsUrlActionType(
+ const std::string& str) {
+ if (str == "MODIFIED") {
+ return MODIFIED;
+ } else if (str == "READ") {
+ return READ;
+ } else if (str == "INSERTED") {
+ return INSERTED;
+ } else if (str == "XHR") {
+ return XHR;
+ } else {
+ NOTREACHED();
+ return MODIFIED; // this should never happen!
+ }
+}
+
+} // namespace extensions
+

Powered by Google App Engine
This is Rietveld 408576698