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