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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for initial review. Created 8 years, 9 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/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/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // If the delegate has an associated browser, that is always the right answer. 661 // If the delegate has an associated browser, that is always the right answer.
662 if (browser) 662 if (browser)
663 return browser; 663 return browser;
664 664
665 // Otherwise, try to default to a reasonable browser. If |include_incognito| 665 // Otherwise, try to default to a reasonable browser. If |include_incognito|
666 // is true, we will also search browsers in the incognito version of this 666 // is true, we will also search browsers in the incognito version of this
667 // profile. Note that the profile may already be incognito, in which case 667 // profile. Note that the profile may already be incognito, in which case
668 // we will search the incognito version only, regardless of the value of 668 // we will search the incognito version only, regardless of the value of
669 // |include_incognito|. 669 // |include_incognito|.
670 Profile* profile = Profile::FromBrowserContext( 670 Profile* profile = Profile::FromBrowserContext(
671 render_view_host->process()->GetBrowserContext()); 671 render_view_host->GetProcess()->GetBrowserContext());
672 browser = BrowserList::FindAnyBrowser(profile, include_incognito); 672 browser = BrowserList::FindAnyBrowser(profile, include_incognito);
673 673
674 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, 674 // NOTE(rafaelw): This can return NULL in some circumstances. In particular,
675 // a background_page onload chrome.tabs api call can make it into here 675 // a background_page onload chrome.tabs api call can make it into here
676 // before the browser is sufficiently initialized to return here. 676 // before the browser is sufficiently initialized to return here.
677 // A similar situation may arise during shutdown. 677 // A similar situation may arise during shutdown.
678 // TODO(rafaelw): Delay creation of background_page until the browser 678 // TODO(rafaelw): Delay creation of background_page until the browser
679 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 679 // is available. http://code.google.com/p/chromium/issues/detail?id=13284
680 return browser; 680 return browser;
681 } 681 }
682 682
683 void ExtensionFunctionDispatcher::Dispatch( 683 void ExtensionFunctionDispatcher::Dispatch(
684 const ExtensionHostMsg_Request_Params& params, 684 const ExtensionHostMsg_Request_Params& params,
685 RenderViewHost* render_view_host) { 685 RenderViewHost* render_view_host) {
686 ExtensionService* service = profile()->GetExtensionService(); 686 ExtensionService* service = profile()->GetExtensionService();
687 extensions::ProcessMap* process_map = service->process_map(); 687 extensions::ProcessMap* process_map = service->process_map();
688 if (!service || !process_map) 688 if (!service || !process_map)
689 return; 689 return;
690 690
691 const Extension* extension = service->extensions()->GetByID( 691 const Extension* extension = service->extensions()->GetByID(
692 params.extension_id); 692 params.extension_id);
693 if (!extension) 693 if (!extension)
694 extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo( 694 extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo(
695 WebSecurityOrigin::createFromString(params.source_origin), 695 WebSecurityOrigin::createFromString(params.source_origin),
696 params.source_url)); 696 params.source_url));
697 697
698 scoped_refptr<ExtensionFunction> function( 698 scoped_refptr<ExtensionFunction> function(
699 CreateExtensionFunction(params, extension, 699 CreateExtensionFunction(params, extension,
700 render_view_host->process()->GetID(), 700 render_view_host->GetProcess()->GetID(),
701 *(service->process_map()), 701 *(service->process_map()),
702 profile(), render_view_host, 702 profile(), render_view_host,
703 render_view_host->routing_id())); 703 render_view_host->GetRoutingID()));
704 if (!function) { 704 if (!function) {
705 LogFailure(extension, params.name, kAccessDenied); 705 LogFailure(extension, params.name, kAccessDenied);
706 return; 706 return;
707 } 707 }
708 708
709 UIThreadExtensionFunction* function_ui = 709 UIThreadExtensionFunction* function_ui =
710 function->AsUIThreadExtensionFunction(); 710 function->AsUIThreadExtensionFunction();
711 if (!function_ui) { 711 if (!function_ui) {
712 NOTREACHED(); 712 NOTREACHED();
713 return; 713 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 return function; 774 return function;
775 } 775 }
776 776
777 // static 777 // static
778 void ExtensionFunctionDispatcher::SendAccessDenied( 778 void ExtensionFunctionDispatcher::SendAccessDenied(
779 IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { 779 IPC::Message::Sender* ipc_sender, int routing_id, int request_id) {
780 ipc_sender->Send(new ExtensionMsg_Response( 780 ipc_sender->Send(new ExtensionMsg_Response(
781 routing_id, request_id, false, std::string(), 781 routing_id, request_id, false, std::string(),
782 "Access to extension API denied.")); 782 "Access to extension API denied."));
783 } 783 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698