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

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

Issue 18769009: [Activity Log] fix logging of blocked API calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/runtime_custom_bindings.h" 5 #include "chrome/renderer/extensions/runtime_custom_bindings.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_messages.h" 11 #include "chrome/common/extensions/extension_messages.h"
12 #include "chrome/common/extensions/features/base_feature_provider.h" 12 #include "chrome/common/extensions/features/base_feature_provider.h"
13 #include "chrome/common/extensions/manifest.h" 13 #include "chrome/common/extensions/manifest.h"
14 #include "chrome/renderer/extensions/api_activity_logger.h"
14 #include "chrome/renderer/extensions/chrome_v8_context.h" 15 #include "chrome/renderer/extensions/chrome_v8_context.h"
15 #include "chrome/renderer/extensions/dispatcher.h" 16 #include "chrome/renderer/extensions/dispatcher.h"
16 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
17 #include "content/public/renderer/v8_value_converter.h" 18 #include "content/public/renderer/v8_value_converter.h"
18 #include "third_party/WebKit/public/web/WebDocument.h" 19 #include "third_party/WebKit/public/web/WebDocument.h"
19 #include "third_party/WebKit/public/web/WebFrame.h" 20 #include "third_party/WebKit/public/web/WebFrame.h"
20 #include "third_party/WebKit/public/web/WebView.h" 21 #include "third_party/WebKit/public/web/WebView.h"
21 22
22 using content::V8ValueConverter; 23 using content::V8ValueConverter;
23 24
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString()); 59 std::string channel_name = *v8::String::Utf8Value(args[1]->ToString());
59 int port_id = -1; 60 int port_id = -1;
60 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( 61 renderview->Send(new ExtensionHostMsg_OpenChannelToExtension(
61 renderview->GetRoutingID(), info, channel_name, &port_id)); 62 renderview->GetRoutingID(), info, channel_name, &port_id));
62 args.GetReturnValue().Set(static_cast<int32_t>(port_id)); 63 args.GetReturnValue().Set(static_cast<int32_t>(port_id));
63 } 64 }
64 65
65 void RuntimeCustomBindings::OpenChannelToNativeApp( 66 void RuntimeCustomBindings::OpenChannelToNativeApp(
66 const v8::FunctionCallbackInfo<v8::Value>& args) { 67 const v8::FunctionCallbackInfo<v8::Value>& args) {
67 // Verify that the extension has permission to use native messaging. 68 // Verify that the extension has permission to use native messaging.
68 if (!BaseFeatureProvider::GetByName("permission")->GetFeature( 69 Feature::Availability availability =
69 "nativeMessaging")->IsAvailableToContext( 70 BaseFeatureProvider::GetByName("permission")->
70 GetExtensionForRenderView(), 71 GetFeature("nativeMessaging")->IsAvailableToContext(
71 context()->context_type(), 72 GetExtensionForRenderView(),
72 context()->GetURL()).is_available()) { 73 context()->context_type(),
74 context()->GetURL());
75 if (!availability.is_available()) {
76 APIActivityLogger::LogBlockedCall(context()->extension()->id(),
77 "nativeMessaging",
78 availability.result());
73 return; 79 return;
74 } 80 }
75 81
76 // Get the current RenderView so that we can send a routed IPC message from 82 // Get the current RenderView so that we can send a routed IPC message from
77 // the correct source. 83 // the correct source.
78 content::RenderView* renderview = GetRenderView(); 84 content::RenderView* renderview = GetRenderView();
79 if (!renderview) 85 if (!renderview)
80 return; 86 return;
81 87
82 // The Javascript code should validate/fill the arguments. 88 // The Javascript code should validate/fill the arguments.
(...skipping 17 matching lines...) Expand all
100 const v8::FunctionCallbackInfo<v8::Value>& args) { 106 const v8::FunctionCallbackInfo<v8::Value>& args) {
101 CHECK(context()->extension()); 107 CHECK(context()->extension());
102 108
103 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 109 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
104 args.GetReturnValue().Set( 110 args.GetReturnValue().Set(
105 converter->ToV8Value(context()->extension()->manifest()->value(), 111 converter->ToV8Value(context()->extension()->manifest()->value(),
106 context()->v8_context())); 112 context()->v8_context()));
107 } 113 }
108 114
109 } // namespace extensions 115 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/resources/extensions/binding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698