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

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

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test failures. Created 5 years, 11 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 2015 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/declarative_user_script_master.h" 5 #include "chrome/browser/extensions/extension_declarative_user_script_master.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "extensions/browser/extension_registry.h" 10 #include "extensions/browser/extension_registry.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 DeclarativeUserScriptMaster::DeclarativeUserScriptMaster( 14 ExtensionDeclarativeUserScriptMaster::ExtensionDeclarativeUserScriptMaster(
Devlin 2015/01/14 16:45:08 Actually, this class makes me sad. Will the Decla
Xi Han 2015/01/14 23:46:03 This is a great idea!
15 Profile* profile, 15 Profile* profile,
16 const ExtensionId& extension_id) 16 const ConsumerID& consumer_id)
17 : extension_id_(extension_id), 17 : DeclarativeUserScriptMaster(profile, consumer_id),
18 loader_(profile,
19 extension_id,
20 false /* listen_for_extension_system_loaded */),
21 extension_registry_observer_(this) { 18 extension_registry_observer_(this) {
22 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); 19 extension_registry_observer_.Add(ExtensionRegistry::Get(profile));
23 } 20 }
24 21
25 DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() { 22 ExtensionDeclarativeUserScriptMaster::~ExtensionDeclarativeUserScriptMaster() {
26 } 23 }
27 24
28 void DeclarativeUserScriptMaster::OnExtensionUnloaded( 25 void ExtensionDeclarativeUserScriptMaster::OnExtensionUnloaded(
29 content::BrowserContext* browser_context, 26 content::BrowserContext* browser_context,
30 const Extension* extension, 27 const Extension* extension,
31 UnloadedExtensionInfo::Reason reason) { 28 UnloadedExtensionInfo::Reason reason) {
32 if (extension_id_ == extension->id()) 29 if (consumer_id().host_id() == extension->id())
33 ClearScripts(); 30 ClearScripts();
34 } 31 }
35 32
36 void DeclarativeUserScriptMaster::AddScript(const UserScript& script) {
37 std::set<UserScript> set;
38 set.insert(script);
39 loader_.AddScripts(set);
40 }
41
42 void DeclarativeUserScriptMaster::RemoveScript(const UserScript& script) {
43 std::set<UserScript> set;
44 set.insert(script);
45 loader_.RemoveScripts(set);
46 }
47
48 void DeclarativeUserScriptMaster::ClearScripts() {
49 loader_.ClearScripts();
50 }
51
52 } // namespace extensions 33 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698