| 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 "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 static void CheckOnValidThread() { | 12 void CheckOnValidThread() { |
| 13 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 13 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 14 } | 14 } |
| 15 | 15 |
| 16 } // namespace | 16 } // namespace |
| 17 | 17 |
| 18 | 18 |
| 19 struct ExtensionInfoMap::ExtraData { | 19 struct ExtensionInfoMap::ExtraData { |
| 20 // When the extension was installed. | 20 // When the extension was installed. |
| 21 base::Time install_time; | 21 base::Time install_time; |
| 22 | 22 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return iter->second.incognito_enabled; | 89 return iter->second.incognito_enabled; |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool ExtensionInfoMap::CanCrossIncognito(const Extension* extension) { | 93 bool ExtensionInfoMap::CanCrossIncognito(const Extension* extension) { |
| 94 // This is duplicated from ExtensionService :(. | 94 // This is duplicated from ExtensionService :(. |
| 95 return IsIncognitoEnabled(extension->id()) && | 95 return IsIncognitoEnabled(extension->id()) && |
| 96 !extension->incognito_split_mode(); | 96 !extension->incognito_split_mode(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // These are duplicated from ExtensionProcessManager so that we can have the | 99 void ExtensionInfoMap::RegisterExtensionProcess(const std::string& extension_id, |
| 100 // information on the IO thread :(. | 100 int process_id) { |
| 101 void ExtensionInfoMap::BindingsEnabledForProcess(int render_process_id) { | 101 DCHECK(!IsExtensionInProcess(extension_id, process_id)); |
| 102 extension_bindings_process_ids_.insert(render_process_id); | 102 extension_process_ids_.insert( |
| 103 ExtensionProcessIDMap::value_type(extension_id, process_id)); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void ExtensionInfoMap::BindingsDisabledForProcess(int render_process_id) { | 106 void ExtensionInfoMap::UnregisterExtensionProcess( |
| 106 extension_bindings_process_ids_.erase(render_process_id); | 107 const std::string& extension_id, |
| 108 int process_id) { |
| 109 ExtensionProcessIDMap::iterator iter = |
| 110 std::find(extension_process_ids_.begin(), |
| 111 extension_process_ids_.end(), |
| 112 ExtensionProcessIDMap::value_type(extension_id, process_id)); |
| 113 if (iter != extension_process_ids_.end()) |
| 114 extension_process_ids_.erase(iter); |
| 107 } | 115 } |
| 108 | 116 |
| 109 bool ExtensionInfoMap::AreBindingsEnabledForProcess( | 117 bool ExtensionInfoMap::IsExtensionInProcess( |
| 110 int render_process_id) const { | 118 const std::string& extension_id, int process_id) const { |
| 111 // Must behave logically the same as AreBindingsEnabledForProcess() in | 119 return std::find( |
| 112 // extension_process_manager.cc. | 120 extension_process_ids_.begin(), |
| 113 return extension_bindings_process_ids_.find(render_process_id) != | 121 extension_process_ids_.end(), |
| 114 extension_bindings_process_ids_.end(); | 122 ExtensionProcessIDMap::value_type(extension_id, process_id)) != |
| 123 extension_process_ids_.end(); |
| 115 } | 124 } |
| OLD | NEW |