| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 BrowserThread::PostTask( | 260 BrowserThread::PostTask( |
| 261 BrowserThread::IO, FROM_HERE, | 261 BrowserThread::IO, FROM_HERE, |
| 262 base::BindOnce(&UserScriptListener::AppendNewURLPatterns, this, | 262 base::BindOnce(&UserScriptListener::AppendNewURLPatterns, this, |
| 263 browser_context, new_patterns)); | 263 browser_context, new_patterns)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 void UserScriptListener::OnExtensionUnloaded( | 267 void UserScriptListener::OnExtensionUnloaded( |
| 268 content::BrowserContext* browser_context, | 268 content::BrowserContext* browser_context, |
| 269 const Extension* extension, | 269 const Extension* extension, |
| 270 UnloadedExtensionInfo::Reason reason) { | 270 UnloadedExtensionReason reason) { |
| 271 if (ContentScriptsInfo::GetContentScripts(extension).empty()) | 271 if (ContentScriptsInfo::GetContentScripts(extension).empty()) |
| 272 return; // No patterns to delete for this extension. | 272 return; // No patterns to delete for this extension. |
| 273 | 273 |
| 274 // Clear all our patterns and reregister all the still-loaded extensions. | 274 // Clear all our patterns and reregister all the still-loaded extensions. |
| 275 const ExtensionSet& extensions = | 275 const ExtensionSet& extensions = |
| 276 ExtensionRegistry::Get(browser_context)->enabled_extensions(); | 276 ExtensionRegistry::Get(browser_context)->enabled_extensions(); |
| 277 URLPatterns new_patterns; | 277 URLPatterns new_patterns; |
| 278 for (ExtensionSet::const_iterator it = extensions.begin(); | 278 for (ExtensionSet::const_iterator it = extensions.begin(); |
| 279 it != extensions.end(); ++it) { | 279 it != extensions.end(); ++it) { |
| 280 if (it->get() != extension) | 280 if (it->get() != extension) |
| 281 CollectURLPatterns(it->get(), &new_patterns); | 281 CollectURLPatterns(it->get(), &new_patterns); |
| 282 } | 282 } |
| 283 BrowserThread::PostTask( | 283 BrowserThread::PostTask( |
| 284 BrowserThread::IO, FROM_HERE, | 284 BrowserThread::IO, FROM_HERE, |
| 285 base::BindOnce(&UserScriptListener::ReplaceURLPatterns, this, | 285 base::BindOnce(&UserScriptListener::ReplaceURLPatterns, this, |
| 286 browser_context, new_patterns)); | 286 browser_context, new_patterns)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void UserScriptListener::OnShutdown(ExtensionRegistry* registry) { | 289 void UserScriptListener::OnShutdown(ExtensionRegistry* registry) { |
| 290 extension_registry_observer_.Remove(registry); | 290 extension_registry_observer_.Remove(registry); |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace extensions | 293 } // namespace extensions |
| OLD | NEW |