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