| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 return (referrer_valid && download_valid); | 320 return (referrer_valid && download_valid); |
| 321 } | 321 } |
| 322 | 322 |
| 323 bool ExtensionService::IsDownloadFromMiniGallery(const GURL& download_url) { | 323 bool ExtensionService::IsDownloadFromMiniGallery(const GURL& download_url) { |
| 324 return StartsWithASCII(download_url.spec(), | 324 return StartsWithASCII(download_url.spec(), |
| 325 extension_urls::kMiniGalleryDownloadPrefix, | 325 extension_urls::kMiniGalleryDownloadPrefix, |
| 326 false); // case_sensitive | 326 false); // case_sensitive |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool ExtensionService::IsInstalledApp(const GURL& url) { | 329 const Extension* ExtensionService::GetInstalledApp(const GURL& url) { |
| 330 // Check for hosted app. | 330 // Check for hosted app. |
| 331 if (GetExtensionByWebExtent(url) != NULL) | 331 const Extension* app = GetExtensionByWebExtent(url); |
| 332 return true; | 332 if (app) |
| 333 return app; |
| 333 | 334 |
| 334 // Check for packaged app. | 335 // Check for packaged app. |
| 335 const Extension* extension = GetExtensionByURL(url); | 336 app = GetExtensionByURL(url); |
| 336 return extension != NULL && extension->is_app(); | 337 if (app && app->is_app()) |
| 338 return app; |
| 339 |
| 340 return NULL; |
| 341 } |
| 342 |
| 343 bool ExtensionService::IsInstalledApp(const GURL& url) { |
| 344 return !!GetInstalledApp(url); |
| 337 } | 345 } |
| 338 | 346 |
| 339 // static | 347 // static |
| 340 bool ExtensionService::UninstallExtensionHelper( | 348 bool ExtensionService::UninstallExtensionHelper( |
| 341 ExtensionService* extensions_service, | 349 ExtensionService* extensions_service, |
| 342 const std::string& extension_id) { | 350 const std::string& extension_id) { |
| 343 | 351 |
| 344 // We can't call UninstallExtension with an invalid extension ID, so check it | 352 // We can't call UninstallExtension with an invalid extension ID, so check it |
| 345 // first. | 353 // first. |
| 346 if (extensions_service->GetExtensionById(extension_id, true) || | 354 if (extensions_service->GetExtensionById(extension_id, true) || |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 } | 1857 } |
| 1850 | 1858 |
| 1851 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 1859 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
| 1852 bool value) { | 1860 bool value) { |
| 1853 extension_runtime_data_[extension->id()].being_upgraded = value; | 1861 extension_runtime_data_[extension->id()].being_upgraded = value; |
| 1854 } | 1862 } |
| 1855 | 1863 |
| 1856 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { | 1864 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { |
| 1857 return &extension_runtime_data_[extension->id()].property_bag; | 1865 return &extension_runtime_data_[extension->id()].property_bag; |
| 1858 } | 1866 } |
| OLD | NEW |