OLD | NEW |
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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 } | 1368 } |
1369 | 1369 |
1370 void Dispatcher::AddOrRemoveBindings(const std::string& extension_id) { | 1370 void Dispatcher::AddOrRemoveBindings(const std::string& extension_id) { |
1371 v8_context_set().ForEach( | 1371 v8_context_set().ForEach( |
1372 extension_id, | 1372 extension_id, |
1373 NULL, // all render views | 1373 NULL, // all render views |
1374 base::Bind(&Dispatcher::AddOrRemoveBindingsForContext, | 1374 base::Bind(&Dispatcher::AddOrRemoveBindingsForContext, |
1375 base::Unretained(this))); | 1375 base::Unretained(this))); |
1376 } | 1376 } |
1377 | 1377 |
1378 void Dispatcher::OnUpdatePermissions(int reason_id, | 1378 void Dispatcher::OnUpdatePermissions( |
1379 const std::string& extension_id, | 1379 const ExtensionMsg_UpdatePermissions_Params& params) { |
1380 const APIPermissionSet& apis, | 1380 int reason_id = params.reason_id; |
1381 const URLPatternSet& explicit_hosts, | 1381 const std::string& extension_id = params.extension_id; |
1382 const URLPatternSet& scriptable_hosts) { | 1382 const APIPermissionSet& apis = params.apis; |
| 1383 const ManifestPermissionSet& manifest_permissions = |
| 1384 params.manifest_permissions; |
| 1385 const URLPatternSet& explicit_hosts = params.explicit_hosts; |
| 1386 const URLPatternSet& scriptable_hosts = params.scriptable_hosts; |
| 1387 |
1383 const Extension* extension = extensions_.GetByID(extension_id); | 1388 const Extension* extension = extensions_.GetByID(extension_id); |
1384 if (!extension) | 1389 if (!extension) |
1385 return; | 1390 return; |
1386 | 1391 |
1387 scoped_refptr<const PermissionSet> delta = | 1392 scoped_refptr<const PermissionSet> delta = |
1388 new PermissionSet(apis, explicit_hosts, scriptable_hosts); | 1393 new PermissionSet(apis, manifest_permissions, |
| 1394 explicit_hosts, scriptable_hosts); |
1389 scoped_refptr<const PermissionSet> old_active = | 1395 scoped_refptr<const PermissionSet> old_active = |
1390 extension->GetActivePermissions(); | 1396 extension->GetActivePermissions(); |
1391 UpdatedExtensionPermissionsInfo::Reason reason = | 1397 UpdatedExtensionPermissionsInfo::Reason reason = |
1392 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id); | 1398 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id); |
1393 | 1399 |
1394 const PermissionSet* new_active = NULL; | 1400 const PermissionSet* new_active = NULL; |
1395 switch (reason) { | 1401 switch (reason) { |
1396 case UpdatedExtensionPermissionsInfo::ADDED: | 1402 case UpdatedExtensionPermissionsInfo::ADDED: |
1397 new_active = PermissionSet::CreateUnion(old_active.get(), delta.get()); | 1403 new_active = PermissionSet::CreateUnion(old_active.get(), delta.get()); |
1398 break; | 1404 break; |
(...skipping 22 matching lines...) Expand all Loading... |
1421 if (view && view->GetPageId() != page_id) | 1427 if (view && view->GetPageId() != page_id) |
1422 return; | 1428 return; |
1423 | 1429 |
1424 const Extension* extension = extensions_.GetByID(extension_id); | 1430 const Extension* extension = extensions_.GetByID(extension_id); |
1425 if (!extension) | 1431 if (!extension) |
1426 return; | 1432 return; |
1427 | 1433 |
1428 PermissionsData::UpdateTabSpecificPermissions( | 1434 PermissionsData::UpdateTabSpecificPermissions( |
1429 extension, | 1435 extension, |
1430 tab_id, | 1436 tab_id, |
1431 new PermissionSet(APIPermissionSet(), origin_set, URLPatternSet())); | 1437 new PermissionSet(APIPermissionSet(), ManifestPermissionSet(), |
| 1438 origin_set, URLPatternSet())); |
1432 } | 1439 } |
1433 | 1440 |
1434 void Dispatcher::OnClearTabSpecificPermissions( | 1441 void Dispatcher::OnClearTabSpecificPermissions( |
1435 int tab_id, | 1442 int tab_id, |
1436 const std::vector<std::string>& extension_ids) { | 1443 const std::vector<std::string>& extension_ids) { |
1437 for (std::vector<std::string>::const_iterator it = extension_ids.begin(); | 1444 for (std::vector<std::string>::const_iterator it = extension_ids.begin(); |
1438 it != extension_ids.end(); ++it) { | 1445 it != extension_ids.end(); ++it) { |
1439 const Extension* extension = extensions_.GetByID(*it); | 1446 const Extension* extension = extensions_.GetByID(*it); |
1440 if (extension) | 1447 if (extension) |
1441 PermissionsData::ClearTabSpecificPermissions(extension, tab_id); | 1448 PermissionsData::ClearTabSpecificPermissions(extension, tab_id); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 RenderView* background_view = | 1634 RenderView* background_view = |
1628 ExtensionHelper::GetBackgroundPage(extension_id); | 1635 ExtensionHelper::GetBackgroundPage(extension_id); |
1629 if (background_view) { | 1636 if (background_view) { |
1630 background_view->Send(new ExtensionHostMsg_EventAck( | 1637 background_view->Send(new ExtensionHostMsg_EventAck( |
1631 background_view->GetRoutingID())); | 1638 background_view->GetRoutingID())); |
1632 } | 1639 } |
1633 } | 1640 } |
1634 } | 1641 } |
1635 | 1642 |
1636 } // namespace extensions | 1643 } // namespace extensions |
OLD | NEW |