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

Side by Side Diff: extensions/browser/declarative_user_script_manager.cc

Issue 955473002: Move DeclarativeUserScriptManager/Master and UserScriptLoader to //extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/declarative_user_script_manager.h" 5 #include "extensions/browser/declarative_user_script_manager.h"
6 6
7 #include "chrome/browser/extensions/declarative_user_script_master.h" 7 #include "content/public/browser/browser_context.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "extensions/browser/declarative_user_script_master.h"
9 #include "extensions/browser/extension_registry.h" 9 #include "extensions/browser/extension_registry.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 12
13 DeclarativeUserScriptManager::DeclarativeUserScriptManager(Profile* profile) 13 DeclarativeUserScriptManager::DeclarativeUserScriptManager(
14 : profile_(profile), extension_registry_observer_(this) { 14 content::BrowserContext* browser_context)
15 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); 15 : browser_context_(browser_context), extension_registry_observer_(this) {
16 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context));
16 } 17 }
17 18
18 DeclarativeUserScriptManager::~DeclarativeUserScriptManager() { 19 DeclarativeUserScriptManager::~DeclarativeUserScriptManager() {
19 } 20 }
20 21
21 DeclarativeUserScriptMaster* 22 DeclarativeUserScriptMaster*
22 DeclarativeUserScriptManager::GetDeclarativeUserScriptMasterByID( 23 DeclarativeUserScriptManager::GetDeclarativeUserScriptMasterByID(
23 const HostID& host_id) { 24 const HostID& host_id) {
24 UserScriptMasterMap::iterator it = 25 UserScriptMasterMap::iterator it =
25 declarative_user_script_masters_.find(host_id); 26 declarative_user_script_masters_.find(host_id);
26 27
27 if (it != declarative_user_script_masters_.end()) 28 if (it != declarative_user_script_masters_.end())
28 return it->second.get(); 29 return it->second.get();
29 30
30 return CreateDeclarativeUserScriptMaster(host_id); 31 return CreateDeclarativeUserScriptMaster(host_id);
31 } 32 }
32 33
33 DeclarativeUserScriptMaster* 34 DeclarativeUserScriptMaster*
34 DeclarativeUserScriptManager::CreateDeclarativeUserScriptMaster( 35 DeclarativeUserScriptManager::CreateDeclarativeUserScriptMaster(
35 const HostID& host_id) { 36 const HostID& host_id) {
36 linked_ptr<DeclarativeUserScriptMaster> master( 37 linked_ptr<DeclarativeUserScriptMaster> master(
37 new DeclarativeUserScriptMaster(profile_, host_id)); 38 new DeclarativeUserScriptMaster(browser_context_, host_id));
38 declarative_user_script_masters_[host_id] = master; 39 declarative_user_script_masters_[host_id] = master;
39 return master.get(); 40 return master.get();
40 } 41 }
41 42
42 void DeclarativeUserScriptManager::OnExtensionUnloaded( 43 void DeclarativeUserScriptManager::OnExtensionUnloaded(
43 content::BrowserContext* browser_context, 44 content::BrowserContext* browser_context,
44 const Extension* extension, 45 const Extension* extension,
45 UnloadedExtensionInfo::Reason reason) { 46 UnloadedExtensionInfo::Reason reason) {
46 for (const auto& val : declarative_user_script_masters_) { 47 for (const auto& val : declarative_user_script_masters_) {
47 DeclarativeUserScriptMaster* master = val.second.get(); 48 DeclarativeUserScriptMaster* master = val.second.get();
48 if (master->host_id().id() == extension->id()) 49 if (master->host_id().id() == extension->id())
49 master->ClearScripts(); 50 master->ClearScripts();
50 } 51 }
51 } 52 }
52 53
53 } // namespace extensions 54 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/declarative_user_script_manager.h ('k') | extensions/browser/declarative_user_script_master.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698