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 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 // if the value changed and the extension is actually enabled, since there is | 1469 // if the value changed and the extension is actually enabled, since there is |
1470 // no UI otherwise. | 1470 // no UI otherwise. |
1471 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); | 1471 bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); |
1472 if (enabled == old_enabled) | 1472 if (enabled == old_enabled) |
1473 return; | 1473 return; |
1474 | 1474 |
1475 extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); | 1475 extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); |
1476 | 1476 |
1477 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), | 1477 bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), |
1478 extension) != extensions_.end(); | 1478 extension) != extensions_.end(); |
| 1479 |
| 1480 // When we reload the extension the ID may be invalidated if we've passed it |
| 1481 // by const ref everywhere. Make a copy to be safe. |
| 1482 std::string id = extension_id; |
1479 if (extension_is_enabled) | 1483 if (extension_is_enabled) |
1480 ReloadExtension(extension->id()); | 1484 ReloadExtension(extension->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 |