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

Side by Side Diff: chrome/browser/extensions/declarative_user_script_master.h

Issue 420543002: Declarative content scripts: Browser-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing changes to extension systems Created 6 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
Devlin 2014/07/30 21:20:38 nit: we don't use (c) anymore (I don't know why, b
Mark Dittmer 2014/07/31 18:37:33 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_
7
8 #include <set>
9
10 #include "base/scoped_observer.h"
Devlin 2014/07/30 21:20:38 unused?
Mark Dittmer 2014/07/31 18:37:33 Done.
11 #include "chrome/browser/extensions/user_script_master.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "extensions/common/extension.h"
15
16 class Profile;
17
18 namespace extensions {
19
20 class DeclarativeUserScriptMaster : public UserScriptMaster,
21 public content::NotificationObserver {
22 public:
23 DeclarativeUserScriptMaster(Profile* profile,
24 const ExtensionId& extension_id);
25 virtual ~DeclarativeUserScriptMaster();
26
27 // content::NotificationObserver implementation.
28 virtual void Observe(int type,
Devlin 2014/07/30 21:20:38 Let's make this private.
Mark Dittmer 2014/07/31 18:37:33 Done.
29 const content::NotificationSource& source,
30 const content::NotificationDetails& details) OVERRIDE;
31
32 // Add script to shared memory region. This may not happen right away if a
33 // script load is in progress.
34 void AddScript(const UserScript& script);
35
36 // Remove script from shared memory region. This may not happen right away if
37 // a script load is in progress.
38 void RemoveScript(const UserScript& script);
39
40 // Remove all scripts from shared memory region. This may not happen right
41 // away if a script load is in progress.
42 void ClearScripts();
43
44 // Start loading scripts into shared memory region.
Devlin 2014/07/30 21:20:38 Replace this comment with just UserScriptMaster im
Mark Dittmer 2014/07/31 18:37:33 Done.
45 virtual void StartLoad() OVERRIDE;
46
47 private:
48 // Reset UserScriptMaster::pending_load_ based on our data.
49 void ResetPendingLoad() {
Devlin 2014/07/30 21:20:38 This and ResetPendingLoadData should probably both
Mark Dittmer 2014/07/31 18:37:33 Done.
50 pending_load_ = (clear_scripts_ || scripts_to_add_.size() > 0 ||
51 scripts_to_remove_.size() > 0);
52 }
53
54 // Reset data upon which UserScriptMaster::pending_load_ depends.
55 void ResetPendingLoadData() {
56 scripts_to_add_.clear();
57 scripts_to_remove_.clear();
58 clear_scripts_ = false;
59 }
60
61 // Scripts to be added next time the memory region reloads.
62 std::set<UserScript> scripts_to_add_;
63
64 // Scripts to be removed next time the memory region reloads.
65 std::set<UserScript> scripts_to_remove_;
66
67 // Indicator variable: clear list of scripts on next reload.
68 bool clear_scripts_;
69
70 // Manages our notification registrations.
71 content::NotificationRegistrar registrar_;
72
73 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster);
74 };
75
76 } // namespace extensions
77
78 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698