OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/user_script_listener.h" | 5 #include "chrome/browser/extensions/user_script_listener.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 const Extension* unloaded_extension = | 224 const Extension* unloaded_extension = |
225 content::Details<UnloadedExtensionInfo>(details)->extension; | 225 content::Details<UnloadedExtensionInfo>(details)->extension; |
226 if (ContentScriptsInfo::GetContentScripts(unloaded_extension).empty()) | 226 if (ContentScriptsInfo::GetContentScripts(unloaded_extension).empty()) |
227 return; // no patterns to delete for this extension. | 227 return; // no patterns to delete for this extension. |
228 | 228 |
229 // Clear all our patterns and reregister all the still-loaded extensions. | 229 // Clear all our patterns and reregister all the still-loaded extensions. |
230 URLPatterns new_patterns; | 230 URLPatterns new_patterns; |
231 ExtensionService* service = profile->GetExtensionService(); | 231 ExtensionService* service = profile->GetExtensionService(); |
232 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 232 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
233 it != service->extensions()->end(); ++it) { | 233 it != service->extensions()->end(); ++it) { |
234 if (*it != unloaded_extension) | 234 if (it->get() != unloaded_extension) |
235 CollectURLPatterns(*it, &new_patterns); | 235 CollectURLPatterns(it->get(), &new_patterns); |
236 } | 236 } |
237 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 237 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
238 &UserScriptListener::ReplaceURLPatterns, this, | 238 &UserScriptListener::ReplaceURLPatterns, this, |
239 profile, new_patterns)); | 239 profile, new_patterns)); |
240 break; | 240 break; |
241 } | 241 } |
242 | 242 |
243 case chrome::NOTIFICATION_USER_SCRIPTS_UPDATED: { | 243 case chrome::NOTIFICATION_USER_SCRIPTS_UPDATED: { |
244 Profile* profile = content::Source<Profile>(source).ptr(); | 244 Profile* profile = content::Source<Profile>(source).ptr(); |
245 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 245 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
246 &UserScriptListener::UserScriptsReady, this, profile)); | 246 &UserScriptListener::UserScriptsReady, this, profile)); |
247 break; | 247 break; |
248 } | 248 } |
249 | 249 |
250 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 250 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
251 Profile* profile = content::Source<Profile>(source).ptr(); | 251 Profile* profile = content::Source<Profile>(source).ptr(); |
252 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 252 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
253 &UserScriptListener::ProfileDestroyed, this, profile)); | 253 &UserScriptListener::ProfileDestroyed, this, profile)); |
254 break; | 254 break; |
255 } | 255 } |
256 | 256 |
257 default: | 257 default: |
258 NOTREACHED(); | 258 NOTREACHED(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace extensions | 262 } // namespace extensions |
OLD | NEW |