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 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 const Extension* extension = GetInstalledExtension(extension_id); | 1451 const Extension* extension = GetInstalledExtension(extension_id); |
1452 if (extension && extension->location() == Extension::COMPONENT) | 1452 if (extension && extension->location() == Extension::COMPONENT) |
1453 return true; | 1453 return true; |
1454 | 1454 |
1455 // Check the prefs. | 1455 // Check the prefs. |
1456 return extension_prefs_->IsIncognitoEnabled(extension_id); | 1456 return extension_prefs_->IsIncognitoEnabled(extension_id); |
1457 } | 1457 } |
1458 | 1458 |
1459 void ExtensionService::SetIsIncognitoEnabled( | 1459 void ExtensionService::SetIsIncognitoEnabled( |
1460 const std::string& extension_id, bool enabled) { | 1460 const std::string& extension_id, bool enabled) { |
1461 const Extension* extension = GetInstalledExtension(extension_id); | 1461 // When we reload the extension the ID may be invalidated if we've passed it |
1462 // by const ref everywhere. Make a copy to be safe. | |
1463 std::string id = extension_id; | |
Finnur
2011/11/11 16:01:07
nit: It would have been enough to make the copy ri
jstritar
2011/11/11 16:31:37
Done.
| |
1464 | |
1465 const Extension* extension = GetInstalledExtension(id); | |
1462 if (extension && extension->location() == Extension::COMPONENT) { | 1466 if (extension && extension->location() == Extension::COMPONENT) { |
1463 // This shouldn't be called for component extensions. | 1467 // This shouldn't be called for component extensions. |
1464 NOTREACHED(); | 1468 NOTREACHED(); |
1465 return; | 1469 return; |
1466 } | 1470 } |
1467 | 1471 |
1468 // Broadcast unloaded and loaded events to update browser state. Only bother | 1472 // Broadcast unloaded and loaded events to update browser state. Only bother |
1469 // if the value changed and the extension is actually enabled, since there is | 1473 // if the value changed and the extension is actually enabled, since there is |
1470 // no UI otherwise. | 1474 // no UI otherwise. |
1471 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); | 1475 bool old_enabled = extension_prefs_->IsIncognitoEnabled(id); |
1472 if (enabled == old_enabled) | 1476 if (enabled == old_enabled) |
1473 return; | 1477 return; |
1474 | 1478 |
1475 extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); | 1479 extension_prefs_->SetIsIncognitoEnabled(id, enabled); |
1476 | 1480 |
1477 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), | 1481 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), |
1478 extension) != extensions_.end(); | 1482 extension) != extensions_.end(); |
1479 if (extension_is_enabled) | 1483 if (extension_is_enabled) |
1480 ReloadExtension(extension->id()); | 1484 ReloadExtension(id); |
1481 | 1485 |
1482 // Reloading the extension invalidates the |extension| pointer. | 1486 // Reloading the extension invalidates the |extension| pointer. |
1483 extension = GetInstalledExtension(extension_id); | 1487 extension = GetInstalledExtension(id); |
1484 if (extension) | 1488 if (extension) |
1485 SyncExtensionChangeIfNeeded(*extension); | 1489 SyncExtensionChangeIfNeeded(*extension); |
1486 } | 1490 } |
1487 | 1491 |
1488 void ExtensionService::SetAppNotificationSetupDone( | 1492 void ExtensionService::SetAppNotificationSetupDone( |
1489 const std::string& extension_id, | 1493 const std::string& extension_id, |
1490 bool value) { | 1494 bool value) { |
1491 const Extension* extension = GetInstalledExtension(extension_id); | 1495 const Extension* extension = GetInstalledExtension(extension_id); |
1492 // This method is called when the user sets up app notifications. | 1496 // This method is called when the user sets up app notifications. |
1493 // So it is not expected to be called until the extension is installed. | 1497 // So it is not expected to be called until the extension is installed. |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2491 | 2495 |
2492 ExtensionService::NaClModuleInfoList::iterator | 2496 ExtensionService::NaClModuleInfoList::iterator |
2493 ExtensionService::FindNaClModule(const GURL& url) { | 2497 ExtensionService::FindNaClModule(const GURL& url) { |
2494 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2498 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2495 iter != nacl_module_list_.end(); ++iter) { | 2499 iter != nacl_module_list_.end(); ++iter) { |
2496 if (iter->url == url) | 2500 if (iter->url == url) |
2497 return iter; | 2501 return iter; |
2498 } | 2502 } |
2499 return nacl_module_list_.end(); | 2503 return nacl_module_list_.end(); |
2500 } | 2504 } |
OLD | NEW |