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

Side by Side Diff: chrome/browser/extensions/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/declarative_user_script_manager.h"
6
7 #include "chrome/browser/extensions/declarative_user_script_master.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "extensions/browser/extension_registry.h"
10
11 namespace extensions {
12
13 DeclarativeUserScriptManager::DeclarativeUserScriptManager(Profile* profile)
14 : profile_(profile), extension_registry_observer_(this) {
15 extension_registry_observer_.Add(ExtensionRegistry::Get(profile));
16 }
17
18 DeclarativeUserScriptManager::~DeclarativeUserScriptManager() {
19 }
20
21 DeclarativeUserScriptMaster*
22 DeclarativeUserScriptManager::GetDeclarativeUserScriptMasterByID(
23 const HostID& host_id) {
24 UserScriptMasterMap::iterator it =
25 declarative_user_script_masters_.find(host_id);
26
27 if (it != declarative_user_script_masters_.end())
28 return it->second.get();
29
30 return CreateDeclarativeUserScriptMaster(host_id);
31 }
32
33 DeclarativeUserScriptMaster*
34 DeclarativeUserScriptManager::CreateDeclarativeUserScriptMaster(
35 const HostID& host_id) {
36 linked_ptr<DeclarativeUserScriptMaster> master(
37 new DeclarativeUserScriptMaster(profile_, host_id));
38 declarative_user_script_masters_[host_id] = master;
39 return master.get();
40 }
41
42 void DeclarativeUserScriptManager::OnExtensionUnloaded(
43 content::BrowserContext* browser_context,
44 const Extension* extension,
45 UnloadedExtensionInfo::Reason reason) {
46 for (const auto& val : declarative_user_script_masters_) {
47 DeclarativeUserScriptMaster* master = val.second.get();
48 if (master->host_id().id() == extension->id())
49 master->ClearScripts();
50 }
51 }
52
53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698