Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/extensions/shared_user_script_master.cc

Issue 2228743002: Rework some UserScriptLoader logic in preparation to removing UserScript copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shared_user_script_master.h" 5 #include "chrome/browser/extensions/shared_user_script_master.h"
6 6
7 #include "chrome/browser/extensions/extension_util.h" 7 #include "chrome/browser/extensions/extension_util.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 9 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
10 #include "extensions/browser/extension_registry.h" 10 #include "extensions/browser/extension_registry.h"
(...skipping 16 matching lines...) Expand all
27 void SharedUserScriptMaster::OnExtensionLoaded( 27 void SharedUserScriptMaster::OnExtensionLoaded(
28 content::BrowserContext* browser_context, 28 content::BrowserContext* browser_context,
29 const Extension* extension) { 29 const Extension* extension) {
30 loader_.AddScripts(GetScriptsMetadata(extension)); 30 loader_.AddScripts(GetScriptsMetadata(extension));
31 } 31 }
32 32
33 void SharedUserScriptMaster::OnExtensionUnloaded( 33 void SharedUserScriptMaster::OnExtensionUnloaded(
34 content::BrowserContext* browser_context, 34 content::BrowserContext* browser_context,
35 const Extension* extension, 35 const Extension* extension,
36 UnloadedExtensionInfo::Reason reason) { 36 UnloadedExtensionInfo::Reason reason) {
37 loader_.RemoveScripts(GetScriptsMetadata(extension)); 37 const UserScriptList& script_list =
38 ContentScriptsInfo::GetContentScripts(extension);
39 std::set<UserScriptIDPair> scripts_to_remove;
40 for (const UserScript& script : script_list)
41 scripts_to_remove.insert(UserScriptIDPair(script.id(), script.host_id()));
42 loader_.RemoveScripts(scripts_to_remove);
38 } 43 }
39 44
40 const std::set<UserScript> SharedUserScriptMaster::GetScriptsMetadata( 45 const std::vector<UserScript> SharedUserScriptMaster::GetScriptsMetadata(
41 const Extension* extension) { 46 const Extension* extension) {
42 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); 47 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
43 const UserScriptList& script_list = 48 const UserScriptList& script_list =
44 ContentScriptsInfo::GetContentScripts(extension); 49 ContentScriptsInfo::GetContentScripts(extension);
45 std::set<UserScript> script_set; 50 std::vector<UserScript> scripts;
46 for (UserScriptList::const_iterator it = script_list.begin(); 51 scripts.reserve(script_list.size());
47 it != script_list.end(); 52 for (const UserScript& script : script_list) {
48 ++it) { 53 UserScript script_copy = script;
Devlin 2016/08/09 23:28:54 This is actually two copies (and was before, too).
lazyboy 2016/08/10 00:03:41 Done (Yes, this is temporary, on my next CL i'm do
49 UserScript script = *it; 54 script_copy.set_incognito_enabled(incognito_enabled);
50 script.set_incognito_enabled(incognito_enabled); 55 scripts.push_back(script_copy);
51 script_set.insert(script);
52 } 56 }
53 57
54 return script_set; 58 return scripts;
55 } 59 }
56 60
57 } // namespace extensions 61 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698