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

Side by Side Diff: chrome/renderer/extensions/dispatcher.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/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void GetAvailability(const v8::FunctionCallbackInfo<v8::Value>& args) { 170 void GetAvailability(const v8::FunctionCallbackInfo<v8::Value>& args) {
171 CHECK_EQ(args.Length(), 1); 171 CHECK_EQ(args.Length(), 1);
172 std::string api_name = *v8::String::AsciiValue(args[0]->ToString()); 172 std::string api_name = *v8::String::AsciiValue(args[0]->ToString());
173 Feature::Availability availability = context_->GetAvailability(api_name); 173 Feature::Availability availability = context_->GetAvailability(api_name);
174 174
175 v8::Handle<v8::Object> ret = v8::Object::New(); 175 v8::Handle<v8::Object> ret = v8::Object::New();
176 ret->Set(v8::String::New("is_available"), 176 ret->Set(v8::String::New("is_available"),
177 v8::Boolean::New(availability.is_available())); 177 v8::Boolean::New(availability.is_available()));
178 ret->Set(v8::String::New("message"), 178 ret->Set(v8::String::New("message"),
179 v8::String::New(availability.message().c_str())); 179 v8::String::New(availability.message().c_str()));
180 ret->Set(v8::String::New("result"),
181 v8::Integer::New(availability.result()));
180 args.GetReturnValue().Set(ret); 182 args.GetReturnValue().Set(ret);
181 } 183 }
182 184
183 void GetModuleSystem(const v8::FunctionCallbackInfo<v8::Value>& args) { 185 void GetModuleSystem(const v8::FunctionCallbackInfo<v8::Value>& args) {
184 CHECK_EQ(args.Length(), 1); 186 CHECK_EQ(args.Length(), 1);
185 CHECK(args[0]->IsObject()); 187 CHECK(args[0]->IsObject());
186 v8::Handle<v8::Context> v8_context = 188 v8::Handle<v8::Context> v8_context =
187 v8::Handle<v8::Object>::Cast(args[0])->CreationContext(); 189 v8::Handle<v8::Object>::Cast(args[0])->CreationContext();
188 ChromeV8Context* context = dispatcher_->v8_context_set().GetByV8Context( 190 ChromeV8Context* context = dispatcher_->v8_context_set().GetByV8Context(
189 v8_context); 191 v8_context);
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 static const char kMessage[] = 1437 static const char kMessage[] =
1436 "%s cannot be used within a sandboxed frame."; 1438 "%s cannot be used within a sandboxed frame.";
1437 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); 1439 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str());
1438 v8::ThrowException( 1440 v8::ThrowException(
1439 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1441 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1440 return false; 1442 return false;
1441 } 1443 }
1442 1444
1443 Feature::Availability availability = context->GetAvailability(function_name); 1445 Feature::Availability availability = context->GetAvailability(function_name);
1444 if (!availability.is_available()) { 1446 if (!availability.is_available()) {
1447 APIActivityLogger::LogBlockedCall(context->extension()->id(),
1448 function_name,
1449 availability.result());
1445 v8::ThrowException(v8::Exception::Error( 1450 v8::ThrowException(v8::Exception::Error(
1446 v8::String::New(availability.message().c_str()))); 1451 v8::String::New(availability.message().c_str())));
1447 } 1452 }
1448 1453
1449 return availability.is_available(); 1454 return availability.is_available();
1450 } 1455 }
1451 1456
1452 void Dispatcher::DispatchEvent(const std::string& extension_id, 1457 void Dispatcher::DispatchEvent(const std::string& extension_id,
1453 const std::string& event_name) const { 1458 const std::string& event_name) const {
1454 base::ListValue args; 1459 base::ListValue args;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 RenderView* background_view = 1500 RenderView* background_view =
1496 ExtensionHelper::GetBackgroundPage(extension_id); 1501 ExtensionHelper::GetBackgroundPage(extension_id);
1497 if (background_view) { 1502 if (background_view) {
1498 background_view->Send(new ExtensionHostMsg_EventAck( 1503 background_view->Send(new ExtensionHostMsg_EventAck(
1499 background_view->GetRoutingID())); 1504 background_view->GetRoutingID()));
1500 } 1505 }
1501 } 1506 }
1502 } 1507 }
1503 1508
1504 } // namespace extensions 1509 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/api_activity_logger.cc ('k') | chrome/renderer/extensions/runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698