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

Side by Side Diff: chrome/browser/extensions/extension_function_dispatcher.cc

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/extensions/extension_function_dispatcher.h" 5 #include "chrome/browser/extensions/extension_function_dispatcher.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 function->set_has_callback(params.has_callback); 479 function->set_has_callback(params.has_callback);
480 function->set_user_gesture(params.user_gesture); 480 function->set_user_gesture(params.user_gesture);
481 ExtensionService* service = profile()->GetExtensionService(); 481 ExtensionService* service = profile()->GetExtensionService();
482 DCHECK(service); 482 DCHECK(service);
483 const Extension* extension = service->GetExtensionById(extension_id(), false); 483 const Extension* extension = service->GetExtensionById(extension_id(), false);
484 DCHECK(extension); 484 DCHECK(extension);
485 function->set_include_incognito(service->CanCrossIncognito(extension)); 485 function->set_include_incognito(service->CanCrossIncognito(extension));
486 486
487 if (!service->ExtensionBindingsAllowed(function->source_url()) || 487 if (!service->ExtensionBindingsAllowed(function->source_url()) ||
488 !extension->HasApiPermission(function->name())) { 488 !extension->HasApiPermission(function->name())) {
489 render_view_host_->BlockExtensionRequest(function->request_id()); 489 render_view_host_->Send(new ExtensionMsg_Response(
490 render_view_host_->routing_id(), function->request_id(), false,
491 std::string(), "Access to extension API denied."));
490 return; 492 return;
491 } 493 }
492 494
493 ExtensionsQuotaService* quota = service->quota_service(); 495 ExtensionsQuotaService* quota = service->quota_service();
494 if (quota->Assess(extension_id(), function, &params.arguments, 496 if (quota->Assess(extension_id(), function, &params.arguments,
495 base::TimeTicks::Now())) { 497 base::TimeTicks::Now())) {
496 // See crbug.com/39178. 498 // See crbug.com/39178.
497 ExternalProtocolHandler::PermitLaunchUrl(); 499 ExternalProtocolHandler::PermitLaunchUrl();
498 500
499 function->Run(); 501 function->Run();
500 } else { 502 } else {
501 render_view_host_->SendExtensionResponse(function->request_id(), false, 503 render_view_host_->Send(new ExtensionMsg_Response(
502 std::string(), QuotaLimitHeuristic::kGenericOverQuotaError); 504 render_view_host_->routing_id(), function->request_id(), false,
505 std::string(), QuotaLimitHeuristic::kGenericOverQuotaError));
503 } 506 }
504 } 507 }
505 508
506 void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function, 509 void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function,
507 bool success) { 510 bool success) {
508 render_view_host_->SendExtensionResponse(function->request_id(), success, 511 render_view_host_->Send(new ExtensionMsg_Response(
509 function->GetResult(), function->GetError()); 512 render_view_host_->routing_id(), function->request_id(), success,
513 function->GetResult(), function->GetError()));
510 } 514 }
511 515
512 void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) { 516 void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
513 LOG(ERROR) << "bad extension message " << 517 LOG(ERROR) << "bad extension message " <<
514 api->name() << 518 api->name() <<
515 " : terminating renderer."; 519 " : terminating renderer.";
516 if (RenderProcessHost::run_renderer_in_process()) { 520 if (RenderProcessHost::run_renderer_in_process()) {
517 // In single process mode it is better if we don't suicide but just crash. 521 // In single process mode it is better if we don't suicide but just crash.
518 CHECK(false); 522 CHECK(false);
519 } else { 523 } else {
520 NOTREACHED(); 524 NOTREACHED();
521 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_EFD")); 525 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_EFD"));
522 base::KillProcess(render_view_host_->process()->GetHandle(), 526 base::KillProcess(render_view_host_->process()->GetHandle(),
523 ResultCodes::KILLED_BAD_MESSAGE, false); 527 ResultCodes::KILLED_BAD_MESSAGE, false);
524 } 528 }
525 } 529 }
526 530
527 Profile* ExtensionFunctionDispatcher::profile() { 531 Profile* ExtensionFunctionDispatcher::profile() {
528 return profile_; 532 return profile_;
529 } 533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698