summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_management_internal.h
diff options
context:
space:
mode:
authorbinjin <binjin@chromium.org>2014-10-02 04:47:12 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-02 11:47:29 +0000
commit81d7c55c47677582259ab1b62b92d0d7c2557d47 (patch)
treeb7717a55f3e23ada91a355dc53c5a850fd2fcd8c /chrome/browser/extensions/extension_management_internal.h
parent9accc09a59b1b5e6a2b40d8dace0a47e16ba4a12 (diff)
downloadchromium_src-81d7c55c47677582259ab1b62b92d0d7c2557d47.zip
chromium_src-81d7c55c47677582259ab1b62b92d0d7c2557d47.tar.gz
chromium_src-81d7c55c47677582259ab1b62b92d0d7c2557d47.tar.bz2
Refactor ExtensionManagement
This CL removes IndividualSettings and GlobalSettings from ExtensionManagment header file in order to simply header file and reduce static size of ExtensionManagement class. Linked pointer is used to prevent potential unintended use of copy constructor of these structure in the future, when more fields are added. A new internal header file is created since these structures are also used in unit tests. BUG=177351 Review URL: https://codereview.chromium.org/602803002 Cr-Commit-Position: refs/heads/master@{#297808}
Diffstat (limited to 'chrome/browser/extensions/extension_management_internal.h')
-rw-r--r--chrome/browser/extensions/extension_management_internal.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_management_internal.h b/chrome/browser/extensions/extension_management_internal.h
new file mode 100644
index 0000000..d01bb33
--- /dev/null
+++ b/chrome/browser/extensions/extension_management_internal.h
@@ -0,0 +1,87 @@
+// 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_EXTENSION_MANAGEMENT_INTERNAL_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_INTERNAL_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "chrome/browser/extensions/extension_management.h"
+#include "extensions/common/manifest.h"
+
+namespace base {
+class DictionaryValue;
+} // namespace base
+
+namespace extensions {
+
+class URLPatternSet;
+
+namespace internal {
+
+// Class to hold extension management settings for one or a group of
+// extensions. Settings can be applied to an individual extension identified
+// by an ID, a group of extensions with specific |update_url| or all
+// extensions at once.
+struct IndividualSettings {
+ enum ParsingScope {
+ // Parses the default settings.
+ SCOPE_DEFAULT = 0,
+ // Parses the settings for an extension with specified extension ID.
+ SCOPE_INDIVIDUAL,
+ };
+
+ IndividualSettings();
+ ~IndividualSettings();
+
+ void Reset();
+
+ // Parses the individual settings. |dict| is the a sub-dictionary in extension
+ // management preference and |scope| represents the applicable range of the
+ // settings, a single extension, a group of extensions or default settings.
+ // Note that in case of parsing errors, |this| will NOT be left untouched.
+ bool Parse(const base::DictionaryValue* dict, ParsingScope scope);
+
+ // Extension installation mode. Setting this to INSTALLATION_FORCED or
+ // INSTALLATION_RECOMMENDED will enable extension auto-loading (only
+ // applicable to single extension), and in this case the |update_url| must
+ // be specified, containing the update URL for this extension.
+ // Note that |update_url| will be ignored for INSTALLATION_ALLOWED and
+ // INSTALLATION_BLOCKED installation mode.
+ // These settings will override the default settings, and unspecified
+ // settings will take value from default settings.
+ ExtensionManagement::InstallationMode installation_mode;
+ std::string update_url;
+
+ private:
+ DISALLOW_ASSIGN(IndividualSettings);
+};
+
+// Global extension management settings, applicable to all extensions.
+struct GlobalSettings {
+ GlobalSettings();
+ ~GlobalSettings();
+
+ void Reset();
+
+ // Settings specifying which URLs are allowed to install extensions, will be
+ // enforced only if |has_restricted_install_sources| is set to true.
+ URLPatternSet install_sources;
+ bool has_restricted_install_sources;
+
+ // Settings specifying all allowed app/extension types, will be enforced
+ // only of |has_restricted_allowed_types| is set to true.
+ std::vector<Manifest::Type> allowed_types;
+ bool has_restricted_allowed_types;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GlobalSettings);
+};
+
+} // namespace internal
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_INTERNAL_H_