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

Unified 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: Refactor relationship between UserScriptMaster and its subclasses Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/declarative_user_script_master.h
diff --git a/chrome/browser/extensions/declarative_user_script_master.h b/chrome/browser/extensions/declarative_user_script_master.h
new file mode 100644
index 0000000000000000000000000000000000000000..5f306099f168860a3ee748807e3496f237d47968
--- /dev/null
+++ b/chrome/browser/extensions/declarative_user_script_master.h
@@ -0,0 +1,84 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_
+#define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_
+
+#include <set>
+
+#include "chrome/browser/extensions/user_script_master.h"
+#include "extensions/common/extension.h"
+
+class Profile;
+
+namespace extensions {
+
+class DeclarativeUserScriptMaster : public UserScriptMaster {
+ public:
+ DeclarativeUserScriptMaster(Profile* profile,
+ const ExtensionId& extension_id);
+ virtual ~DeclarativeUserScriptMaster();
+
+ // Add script to shared memory region. This may not happen right away if a
+ // script load is in progress.
+ void AddScript(const UserScript& script);
+
+ // Remove script from shared memory region. This may not happen right away if
+ // a script load is in progress.
+ void RemoveScript(const UserScript& script);
+
+ // Remove all scripts from shared memory region. This may not happen right
+ // away if a script load is in progress.
+ void ClearScripts();
+
+ // UserScriptMaster implementation.
Devlin 2014/07/31 20:32:24 make this private.
+ virtual void StartLoad() OVERRIDE;
+
+ protected:
+ // UserScriptMaster implementation.
Devlin 2014/07/31 20:32:24 Make all of these private.
+ virtual void AcquireUserScripts(scoped_ptr<UserScriptList> scripts) OVERRIDE;
+ virtual ExtensionsInfo GetExtensionsInfo() OVERRIDE;
+ virtual std::set<ExtensionId> GetAddedExtensions() OVERRIDE;
+ virtual std::set<ExtensionId> GetAllManagedExtensions() OVERRIDE;
+ virtual std::set<ExtensionId> GetChangedExtensions() OVERRIDE;
+ virtual void ResetChangedExtensions() OVERRIDE;
+
+ private:
+ // Attempt to initiate a load of scripts. May need to signal a pending load if
+ // a load is already in progress.
+ void AttemptLoad();
+
+ // Reset UserScriptMaster::pending_load_ based on our data.
Devlin 2014/07/31 20:32:24 Prefer: "Signal a pending load if any scripts have
+ void MaybeSignalPendingLoad();
+
+ bool is_loading() const {
+ // Ownership of |user_scripts_| is passed to the file thread when loading.
+ return user_scripts_.get() == NULL;
+ }
+
+ // List of scripts from currently-installed extensions we should load.
+ scoped_ptr<UserScriptList> user_scripts_;
+
+ // Set containing only the extension we manage. This is passed to the base
+ // class in several different contexts.
+ std::set<ExtensionId> owner_extension_as_set_;
+
+ // Scripts to be added next time the memory region reloads.
+ std::set<UserScript> scripts_to_add_;
+
+ // Scripts to be removed next time the memory region reloads.
+ std::set<UserScript> scripts_to_remove_;
+
+ // Indicator variable: clear list of scripts on next reload.
+ bool clear_scripts_;
+
+ // Maps extension info needed for localization to an extension ID.
+ ExtensionsInfo extensions_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_

Powered by Google App Engine
This is Rietveld 408576698