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

Side by Side Diff: extensions/renderer/dom_activity_logger.cc

Issue 2656433005: Use explicit WebString conversions in extensions/ (Closed)
Patch Set: Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/dom_activity_logger.h" 5 #include "extensions/renderer/dom_activity_logger.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/public/child/v8_value_converter.h" 9 #include "content/public/child/v8_value_converter.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 DOMActivityLogger* logger = new DOMActivityLogger(extension_id); 56 DOMActivityLogger* logger = new DOMActivityLogger(extension_id);
57 blink::setDOMActivityLogger(world_id, 57 blink::setDOMActivityLogger(world_id,
58 WebString::fromUTF8(extension_id), 58 WebString::fromUTF8(extension_id),
59 logger); 59 logger);
60 } 60 }
61 } 61 }
62 62
63 void DOMActivityLogger::logGetter(const WebString& api_name, 63 void DOMActivityLogger::logGetter(const WebString& api_name,
64 const WebURL& url, 64 const WebURL& url,
65 const WebString& title) { 65 const WebString& title) {
66 SendDomActionMessage(api_name.utf8(), url, title, DomActionType::GETTER, 66 SendDomActionMessage(api_name.utf8(), url, title.utf16(),
67 DomActionType::GETTER,
67 std::unique_ptr<base::ListValue>(new base::ListValue())); 68 std::unique_ptr<base::ListValue>(new base::ListValue()));
68 } 69 }
69 70
70 void DOMActivityLogger::logSetter(const WebString& api_name, 71 void DOMActivityLogger::logSetter(const WebString& api_name,
71 const v8::Local<v8::Value>& new_value, 72 const v8::Local<v8::Value>& new_value,
72 const WebURL& url, 73 const WebURL& url,
73 const WebString& title) { 74 const WebString& title) {
74 logSetter(api_name, new_value, v8::Local<v8::Value>(), url, title); 75 logSetter(api_name, new_value, v8::Local<v8::Value>(), url, title);
75 } 76 }
76 77
77 void DOMActivityLogger::logSetter(const WebString& api_name, 78 void DOMActivityLogger::logSetter(const WebString& api_name,
78 const v8::Local<v8::Value>& new_value, 79 const v8::Local<v8::Value>& new_value,
79 const v8::Local<v8::Value>& old_value, 80 const v8::Local<v8::Value>& old_value,
80 const WebURL& url, 81 const WebURL& url,
81 const WebString& title) { 82 const WebString& title) {
82 std::unique_ptr<base::ListValue> args(new base::ListValue); 83 std::unique_ptr<base::ListValue> args(new base::ListValue);
83 std::string api_name_utf8 = api_name.utf8(); 84 std::string api_name_utf8 = api_name.utf8();
84 AppendV8Value(api_name_utf8, new_value, args.get()); 85 AppendV8Value(api_name_utf8, new_value, args.get());
85 if (!old_value.IsEmpty()) 86 if (!old_value.IsEmpty())
86 AppendV8Value(api_name_utf8, old_value, args.get()); 87 AppendV8Value(api_name_utf8, old_value, args.get());
87 SendDomActionMessage(api_name_utf8, url, title, DomActionType::SETTER, 88 SendDomActionMessage(api_name_utf8, url, title.utf16(), DomActionType::SETTER,
88 std::move(args)); 89 std::move(args));
89 } 90 }
90 91
91 void DOMActivityLogger::logMethod(const WebString& api_name, 92 void DOMActivityLogger::logMethod(const WebString& api_name,
92 int argc, 93 int argc,
93 const v8::Local<v8::Value>* argv, 94 const v8::Local<v8::Value>* argv,
94 const WebURL& url, 95 const WebURL& url,
95 const WebString& title) { 96 const WebString& title) {
96 std::unique_ptr<base::ListValue> args(new base::ListValue); 97 std::unique_ptr<base::ListValue> args(new base::ListValue);
97 std::string api_name_utf8 = api_name.utf8(); 98 std::string api_name_utf8 = api_name.utf8();
98 for (int i = 0; i < argc; ++i) 99 for (int i = 0; i < argc; ++i)
99 AppendV8Value(api_name_utf8, argv[i], args.get()); 100 AppendV8Value(api_name_utf8, argv[i], args.get());
100 SendDomActionMessage(api_name_utf8, url, title, DomActionType::METHOD, 101 SendDomActionMessage(api_name_utf8, url, title.utf16(), DomActionType::METHOD,
101 std::move(args)); 102 std::move(args));
102 } 103 }
103 104
104 void DOMActivityLogger::logEvent(const WebString& event_name, 105 void DOMActivityLogger::logEvent(const WebString& event_name,
105 int argc, 106 int argc,
106 const WebString* argv, 107 const WebString* argv,
107 const WebURL& url, 108 const WebURL& url,
108 const WebString& title) { 109 const WebString& title) {
109 std::unique_ptr<base::ListValue> args(new base::ListValue); 110 std::unique_ptr<base::ListValue> args(new base::ListValue);
110 std::string event_name_utf8 = event_name.utf8(); 111 std::string event_name_utf8 = event_name.utf8();
111 for (int i = 0; i < argc; ++i) 112 for (int i = 0; i < argc; ++i)
112 args->AppendString(argv[i]); 113 args->AppendString(argv[i].utf16());
113 SendDomActionMessage(event_name_utf8, url, title, DomActionType::METHOD, 114 SendDomActionMessage(event_name_utf8, url, title.utf16(),
114 std::move(args)); 115 DomActionType::METHOD, std::move(args));
115 } 116 }
116 117
117 void DOMActivityLogger::SendDomActionMessage( 118 void DOMActivityLogger::SendDomActionMessage(
118 const std::string& api_call, 119 const std::string& api_call,
119 const GURL& url, 120 const GURL& url,
120 const base::string16& url_title, 121 const base::string16& url_title,
121 DomActionType::Type call_type, 122 DomActionType::Type call_type,
122 std::unique_ptr<base::ListValue> args) { 123 std::unique_ptr<base::ListValue> args) {
123 ExtensionHostMsg_DOMAction_Params params; 124 ExtensionHostMsg_DOMAction_Params params;
124 params.api_call = api_call; 125 params.api_call = api_call;
125 params.url = url; 126 params.url = url;
126 params.url_title = url_title; 127 params.url_title = url_title;
127 params.call_type = call_type; 128 params.call_type = call_type;
128 params.arguments.Swap(args.get()); 129 params.arguments.Swap(args.get());
129 content::RenderThread::Get()->Send( 130 content::RenderThread::Get()->Send(
130 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params)); 131 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params));
131 } 132 }
132 133
133 } // namespace extensions 134 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698