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

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

Issue 164039: Add module-level permissions to extensions. (Closed)
Patch Set: final nits Created 11 years, 4 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/browser/extensions/extension_host.cc » ('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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_bookmarks_module.h" 10 #include "chrome/browser/extensions/extension_bookmarks_module.h"
11 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" 11 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
12 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
13 #include "chrome/browser/extensions/extension_message_service.h" 13 #include "chrome/browser/extensions/extension_message_service.h"
14 #include "chrome/browser/extensions/extension_page_actions_module.h" 14 #include "chrome/browser/extensions/extension_page_actions_module.h"
15 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" 15 #include "chrome/browser/extensions/extension_page_actions_module_constants.h"
16 #include "chrome/browser/extensions/extension_process_manager.h" 16 #include "chrome/browser/extensions/extension_process_manager.h"
17 #include "chrome/browser/extensions/extension_tabs_module.h" 17 #include "chrome/browser/extensions/extension_tabs_module.h"
18 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 18 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
19 #include "chrome/browser/extensions/extension_toolstrip_api.h" 19 #include "chrome/browser/extensions/extension_toolstrip_api.h"
20 #include "chrome/browser/profile.h" 20 #include "chrome/browser/profile.h"
21 #include "chrome/browser/renderer_host/render_process_host.h" 21 #include "chrome/browser/renderer_host/render_process_host.h"
22 #include "chrome/browser/renderer_host/render_view_host.h" 22 #include "chrome/browser/renderer_host/render_view_host.h"
23 #include "chrome/common/render_messages.h"
23 #include "chrome/common/result_codes.h" 24 #include "chrome/common/result_codes.h"
24 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
25 26
26 // FactoryRegistry ------------------------------------------------------------- 27 // FactoryRegistry -------------------------------------------------------------
27 28
28 namespace { 29 namespace {
29 30
30 // Template for defining ExtensionFunctionFactory. 31 // Template for defining ExtensionFunctionFactory.
31 template<class T> 32 template<class T>
32 ExtensionFunction* NewExtensionFunction() { 33 ExtensionFunction* NewExtensionFunction() {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher( 192 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
192 RenderViewHost* render_view_host, 193 RenderViewHost* render_view_host,
193 Delegate* delegate, 194 Delegate* delegate,
194 const GURL& url) 195 const GURL& url)
195 : render_view_host_(render_view_host), 196 : render_view_host_(render_view_host),
196 delegate_(delegate), 197 delegate_(delegate),
197 url_(url), 198 url_(url),
198 ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) { 199 ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
199 // TODO(erikkay) should we do something for these errors in Release? 200 // TODO(erikkay) should we do something for these errors in Release?
200 DCHECK(url.SchemeIs(chrome::kExtensionScheme)); 201 DCHECK(url.SchemeIs(chrome::kExtensionScheme));
201 DCHECK(profile()->GetExtensionsService()->GetExtensionByURL(url)); 202
203 Extension* extension =
204 profile()->GetExtensionsService()->GetExtensionByURL(url);
205 DCHECK(extension);
202 206
203 all_instances()->insert(this); 207 all_instances()->insert(this);
204 208
205 // Notify the ExtensionProcessManager that the view was created. 209 // Notify the ExtensionProcessManager that the view was created.
206 ExtensionProcessManager* epm = profile()->GetExtensionProcessManager(); 210 ExtensionProcessManager* epm = profile()->GetExtensionProcessManager();
207 epm->RegisterExtensionProcess(extension_id(), 211 epm->RegisterExtensionProcess(extension_id(),
208 render_view_host->process()->pid()); 212 render_view_host->process()->pid());
213
214 // Update the extension permissions. Doing this each time we create an EFD
215 // ensures that new processes are informed of permissions for newly installed
216 // extensions.
217 render_view_host->Send(new ViewMsg_Extension_SetPermissions(
218 extension->id(), extension->api_permissions()));
209 } 219 }
210 220
211 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { 221 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
212 all_instances()->erase(this); 222 all_instances()->erase(this);
213 peer_->dispatcher_ = NULL; 223 peer_->dispatcher_ = NULL;
214 } 224 }
215 225
216 Browser* ExtensionFunctionDispatcher::GetBrowser() { 226 Browser* ExtensionFunctionDispatcher::GetBrowser() {
217 DCHECK(delegate_); 227 DCHECK(delegate_);
218 228
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } else { 263 } else {
254 NOTREACHED(); 264 NOTREACHED();
255 base::KillProcess(render_view_host_->process()->process().handle(), 265 base::KillProcess(render_view_host_->process()->process().handle(),
256 ResultCodes::KILLED_BAD_MESSAGE, false); 266 ResultCodes::KILLED_BAD_MESSAGE, false);
257 } 267 }
258 } 268 }
259 269
260 Profile* ExtensionFunctionDispatcher::profile() { 270 Profile* ExtensionFunctionDispatcher::profile() {
261 return render_view_host_->process()->profile(); 271 return render_view_host_->process()->profile();
262 } 272 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698