| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome_extensions_dispatcher_delegate.h" | 5 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void ChromeExtensionsDispatcherDelegate::ClearTabSpecificPermissions( | 323 void ChromeExtensionsDispatcherDelegate::ClearTabSpecificPermissions( |
| 324 const extensions::Dispatcher* dispatcher, | 324 const extensions::Dispatcher* dispatcher, |
| 325 int tab_id, | 325 int tab_id, |
| 326 const std::vector<std::string>& extension_ids) { | 326 const std::vector<std::string>& extension_ids) { |
| 327 for (std::vector<std::string>::const_iterator it = extension_ids.begin(); | 327 for (std::vector<std::string>::const_iterator it = extension_ids.begin(); |
| 328 it != extension_ids.end(); | 328 it != extension_ids.end(); |
| 329 ++it) { | 329 ++it) { |
| 330 const extensions::Extension* extension = | 330 const extensions::Extension* extension = |
| 331 dispatcher->extensions()->GetByID(*it); | 331 dispatcher->extensions()->GetByID(*it); |
| 332 if (extension) | 332 if (extension) |
| 333 extensions::PermissionsData::ClearTabSpecificPermissions(extension, | 333 extensions::PermissionsData::ForExtension(extension) |
| 334 tab_id); | 334 ->ClearTabSpecificPermissions(tab_id); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 void ChromeExtensionsDispatcherDelegate::UpdateTabSpecificPermissions( | 338 void ChromeExtensionsDispatcherDelegate::UpdateTabSpecificPermissions( |
| 339 const extensions::Dispatcher* dispatcher, | 339 const extensions::Dispatcher* dispatcher, |
| 340 int page_id, | 340 int page_id, |
| 341 int tab_id, | 341 int tab_id, |
| 342 const std::string& extension_id, | 342 const std::string& extension_id, |
| 343 const extensions::URLPatternSet& origin_set) { | 343 const extensions::URLPatternSet& origin_set) { |
| 344 content::RenderView* view = extensions::TabFinder::Find(tab_id); | 344 content::RenderView* view = extensions::TabFinder::Find(tab_id); |
| 345 | 345 |
| 346 // For now, the message should only be sent to the render view that contains | 346 // For now, the message should only be sent to the render view that contains |
| 347 // the target tab. This may change. Either way, if this is the target tab it | 347 // the target tab. This may change. Either way, if this is the target tab it |
| 348 // gives us the chance to check against the page ID to avoid races. | 348 // gives us the chance to check against the page ID to avoid races. |
| 349 DCHECK(view); | 349 DCHECK(view); |
| 350 if (view && view->GetPageId() != page_id) | 350 if (view && view->GetPageId() != page_id) |
| 351 return; | 351 return; |
| 352 | 352 |
| 353 const extensions::Extension* extension = | 353 const extensions::Extension* extension = |
| 354 dispatcher->extensions()->GetByID(extension_id); | 354 dispatcher->extensions()->GetByID(extension_id); |
| 355 if (!extension) | 355 if (!extension) |
| 356 return; | 356 return; |
| 357 | 357 |
| 358 extensions::PermissionsData::UpdateTabSpecificPermissions( | 358 extensions::PermissionsData::ForExtension(extension) |
| 359 extension, | 359 ->UpdateTabSpecificPermissions( |
| 360 tab_id, | 360 tab_id, |
| 361 new extensions::PermissionSet(extensions::APIPermissionSet(), | 361 new extensions::PermissionSet(extensions::APIPermissionSet(), |
| 362 extensions::ManifestPermissionSet(), | 362 extensions::ManifestPermissionSet(), |
| 363 origin_set, | 363 origin_set, |
| 364 extensions::URLPatternSet())); | 364 extensions::URLPatternSet())); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 367 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
| 368 bool adblock, | 368 bool adblock, |
| 369 bool adblock_plus, | 369 bool adblock_plus, |
| 370 bool other) { | 370 bool other) { |
| 371 webrequest_adblock_ = adblock; | 371 webrequest_adblock_ = adblock; |
| 372 webrequest_adblock_plus_ = adblock_plus; | 372 webrequest_adblock_plus_ = adblock_plus; |
| 373 webrequest_other_ = other; | 373 webrequest_other_ = other; |
| 374 } | 374 } |
| OLD | NEW |