Chromium Code Reviews| 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_info_map.h" | 5 #include "chrome/browser/extensions/extension_info_map.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/extension.h" | 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "chrome/common/extensions/extension_set.h" | 8 #include "chrome/common/extensions/extension_set.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool ExtensionInfoMap::CanCrossIncognito(const Extension* extension) { | 103 bool ExtensionInfoMap::CanCrossIncognito(const Extension* extension) { |
| 104 // This is duplicated from ExtensionService :(. | 104 // This is duplicated from ExtensionService :(. |
| 105 return IsIncognitoEnabled(extension->id()) && | 105 return IsIncognitoEnabled(extension->id()) && |
| 106 !extension->incognito_split_mode(); | 106 !extension->incognito_split_mode(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ExtensionInfoMap::RegisterExtensionProcess(const std::string& extension_id, | 109 void ExtensionInfoMap::RegisterExtensionProcess(const std::string& extension_id, |
| 110 int process_id) { | 110 int process_id) { |
| 111 if (!process_map_.Insert(extension_id, process_id)) { | 111 // An extension may be added multiple times for the same process, such as |
| 112 NOTREACHED() << "Duplicate extension process registration for: " | 112 // multiple instances of the same hosted app once the process limit is |
| 113 << extension_id << "," << process_id << "."; | 113 // reached. |
|
Charlie Reis
2011/11/23 23:46:54
aa: I was hitting this NOTREACHED when loading a s
| |
| 114 } | 114 process_map_.Insert(extension_id, process_id); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ExtensionInfoMap::UnregisterExtensionProcess( | 117 void ExtensionInfoMap::UnregisterExtensionProcess( |
| 118 const std::string& extension_id, | 118 const std::string& extension_id, |
| 119 int process_id) { | 119 int process_id) { |
| 120 if (!process_map_.Remove(extension_id, process_id)) { | 120 if (!process_map_.Remove(extension_id, process_id)) { |
| 121 NOTREACHED() << "Unknown extension process registration for: " | 121 NOTREACHED() << "Unknown extension process registration for: " |
| 122 << extension_id << "," << process_id << "."; | 122 << extension_id << "," << process_id << "."; |
| 123 } | 123 } |
| 124 } | 124 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 139 ExtensionSet::ExtensionMap::const_iterator i = extensions_.begin(); | 139 ExtensionSet::ExtensionMap::const_iterator i = extensions_.begin(); |
| 140 for (; i != extensions_.end(); ++i) { | 140 for (; i != extensions_.end(); ++i) { |
| 141 if (i->second->web_extent().MatchesSecurityOrigin(origin) && | 141 if (i->second->web_extent().MatchesSecurityOrigin(origin) && |
| 142 process_map_.Contains(i->first, process_id) && | 142 process_map_.Contains(i->first, process_id) && |
| 143 i->second->HasAPIPermission(permission)) { | 143 i->second->HasAPIPermission(permission)) { |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| OLD | NEW |