| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 *static_cast<DictionaryValue*>(manifest.get()), | 526 *static_cast<DictionaryValue*>(manifest.get()), |
| 527 true, // require key | 527 true, // require key |
| 528 &error)) { | 528 &error)) { |
| 529 NOTREACHED() << error; | 529 NOTREACHED() << error; |
| 530 return; | 530 return; |
| 531 } | 531 } |
| 532 | 532 |
| 533 // In order for the --apps-gallery-url switch to work with the gallery | 533 // In order for the --apps-gallery-url switch to work with the gallery |
| 534 // process isolation, we must insert any provided value into the component | 534 // process isolation, we must insert any provided value into the component |
| 535 // app's launch url and web extent. | 535 // app's launch url and web extent. |
| 536 if (extension->id() == extension_misc::kWebStoreAppId ) { | 536 if (extension->id() == extension_misc::kWebStoreAppId) { |
| 537 GURL gallery_url(CommandLine::ForCurrentProcess() | 537 GURL gallery_url(CommandLine::ForCurrentProcess() |
| 538 ->GetSwitchValueASCII(switches::kAppsGalleryURL)); | 538 ->GetSwitchValueASCII(switches::kAppsGalleryURL)); |
| 539 if (gallery_url.is_valid()) { | 539 if (gallery_url.is_valid()) { |
| 540 extension->set_launch_web_url(gallery_url.spec()); | 540 extension->set_launch_web_url(gallery_url.spec()); |
| 541 URLPattern pattern(URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS); | 541 URLPattern pattern(URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS); |
| 542 pattern.Parse(gallery_url.spec()); | 542 pattern.Parse(gallery_url.spec()); |
| 543 pattern.set_path(pattern.path() + '*'); | 543 pattern.set_path(pattern.path() + '*'); |
| 544 extension->web_extent().AddPattern(pattern); | 544 extension->web_extent().AddPattern(pattern); |
| 545 } | 545 } |
| 546 } | 546 } |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 Extension* ExtensionsService::GetExtensionByWebExtent(const GURL& url) { | 1250 Extension* ExtensionsService::GetExtensionByWebExtent(const GURL& url) { |
| 1251 for (size_t i = 0; i < extensions_.size(); ++i) { | 1251 for (size_t i = 0; i < extensions_.size(); ++i) { |
| 1252 if (extensions_[i]->web_extent().ContainsURL(url)) | 1252 if (extensions_[i]->web_extent().ContainsURL(url)) |
| 1253 return extensions_[i]; | 1253 return extensions_[i]; |
| 1254 } | 1254 } |
| 1255 return NULL; | 1255 return NULL; |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 bool ExtensionsService::ExtensionBindingsAllowed(const GURL& url) { |
| 1259 // Allow bindings for all packaged extension. |
| 1260 if (GetExtensionByURL(url)) |
| 1261 return true; |
| 1262 |
| 1263 // Allow bindings for all component, hosted apps. |
| 1264 Extension* extension = GetExtensionByWebExtent(url); |
| 1265 return (extension && extension->location() == Extension::COMPONENT); |
| 1266 } |
| 1267 |
| 1258 Extension* ExtensionsService::GetExtensionByOverlappingWebExtent( | 1268 Extension* ExtensionsService::GetExtensionByOverlappingWebExtent( |
| 1259 const ExtensionExtent& extent) { | 1269 const ExtensionExtent& extent) { |
| 1260 for (size_t i = 0; i < extensions_.size(); ++i) { | 1270 for (size_t i = 0; i < extensions_.size(); ++i) { |
| 1261 if (extensions_[i]->web_extent().OverlapsWith(extent)) | 1271 if (extensions_[i]->web_extent().OverlapsWith(extent)) |
| 1262 return extensions_[i]; | 1272 return extensions_[i]; |
| 1263 } | 1273 } |
| 1264 | 1274 |
| 1265 return NULL; | 1275 return NULL; |
| 1266 } | 1276 } |
| 1267 | 1277 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 // Finish installing on UI thread. | 1615 // Finish installing on UI thread. |
| 1606 ChromeThread::PostTask( | 1616 ChromeThread::PostTask( |
| 1607 ChromeThread::UI, FROM_HERE, | 1617 ChromeThread::UI, FROM_HERE, |
| 1608 NewRunnableMethod( | 1618 NewRunnableMethod( |
| 1609 frontend_, | 1619 frontend_, |
| 1610 &ExtensionsService::ContinueLoadAllExtensions, | 1620 &ExtensionsService::ContinueLoadAllExtensions, |
| 1611 extensions_to_reload, | 1621 extensions_to_reload, |
| 1612 start_time, | 1622 start_time, |
| 1613 true)); | 1623 true)); |
| 1614 } | 1624 } |
| OLD | NEW |