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

Side by Side Diff: chrome/renderer/extensions/app_hooks_delegate.cc

Issue 2962093002: [Extensions Bindings] Add activity logging of custom handling (Closed)
Patch Set: nit Created 3 years, 5 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 | « no previous file | chrome/test/data/extensions/api_test/activity_log_private/PRESUBMIT.py » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/renderer/extensions/app_hooks_delegate.h" 5 #include "chrome/renderer/extensions/app_hooks_delegate.h"
6 6
7 #include "extensions/renderer/api_activity_logger.h"
7 #include "extensions/renderer/bindings/api_request_handler.h" 8 #include "extensions/renderer/bindings/api_request_handler.h"
8 #include "extensions/renderer/bindings/api_signature.h" 9 #include "extensions/renderer/bindings/api_signature.h"
9 #include "extensions/renderer/script_context_set.h" 10 #include "extensions/renderer/script_context_set.h"
10 #include "gin/converter.h" 11 #include "gin/converter.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 namespace { 15 namespace {
15 16
16 void IsInstalledGetterCallback( 17 void IsInstalledGetterCallback(
17 v8::Local<v8::String> property, 18 v8::Local<v8::String> property,
18 const v8::PropertyCallbackInfo<v8::Value>& info) { 19 const v8::PropertyCallbackInfo<v8::Value>& info) {
19 v8::HandleScope handle_scope(info.GetIsolate()); 20 v8::HandleScope handle_scope(info.GetIsolate());
21 v8::Local<v8::Context> context = info.Holder()->CreationContext();
20 ScriptContext* script_context = 22 ScriptContext* script_context =
21 ScriptContextSet::GetContextByV8Context(info.Holder()->CreationContext()); 23 ScriptContextSet::GetContextByV8Context(context);
22 DCHECK(script_context); 24 DCHECK(script_context);
23 auto* core = 25 auto* core =
24 static_cast<AppBindingsCore*>(info.Data().As<v8::External>()->Value()); 26 static_cast<AppBindingsCore*>(info.Data().As<v8::External>()->Value());
27 // Since this is more-or-less an API, log it as an API call.
28 APIActivityLogger::LogAPICall(context, "app.getIsInstalled",
29 std::vector<v8::Local<v8::Value>>());
25 info.GetReturnValue().Set(core->GetIsInstalled(script_context)); 30 info.GetReturnValue().Set(core->GetIsInstalled(script_context));
26 } 31 }
27 32
28 } // namespace 33 } // namespace
29 34
30 AppHooksDelegate::AppHooksDelegate(Dispatcher* dispatcher, 35 AppHooksDelegate::AppHooksDelegate(Dispatcher* dispatcher,
31 APIRequestHandler* request_handler) 36 APIRequestHandler* request_handler)
32 : app_core_(dispatcher), request_handler_(request_handler) {} 37 : app_core_(dispatcher), request_handler_(request_handler) {}
33 AppHooksDelegate::~AppHooksDelegate() {} 38 AppHooksDelegate::~AppHooksDelegate() {}
34 39
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const std::string& install_state) { 107 const std::string& install_state) {
103 // Note: it's kind of lame that we serialize the install state to a 108 // Note: it's kind of lame that we serialize the install state to a
104 // base::Value here when we're just going to later convert it to v8, but it's 109 // base::Value here when we're just going to later convert it to v8, but it's
105 // not worth the specialization on APIRequestHandler for this oddball API. 110 // not worth the specialization on APIRequestHandler for this oddball API.
106 base::ListValue response; 111 base::ListValue response;
107 response.AppendString(install_state); 112 response.AppendString(install_state);
108 request_handler_->CompleteRequest(request_id, response, std::string()); 113 request_handler_->CompleteRequest(request_id, response, std::string());
109 } 114 }
110 115
111 } // namespace extensions 116 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/activity_log_private/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698