Implement CloudReportingEnabled policy

The policy force installs Chrome Reporting Extension and overrides any
other extension policies about extensions black list,
blcoked permissions, allowed/blocked runtime hosts,
minimum version requirment, allowed type and update url.

The policy does not override install source policy as it does not affect
force-installed extension.


Bug: 898673
Change-Id: I8f17d2073b200448d268a34dc07ab61ff65753d8
Reviewed-on: https://chromium-review.googlesource.com/c/1306233
Commit-Queue: Owen Min <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#604696}
diff --git a/chrome/browser/extensions/extension_management.h b/chrome/browser/extensions/extension_management.h
index 68accd1..7894fd13 100644
--- a/chrome/browser/extensions/extension_management.h
+++ b/chrome/browser/extensions/extension_management.h
@@ -108,9 +108,10 @@
   bool IsOffstoreInstallAllowed(const GURL& url,
                                 const GURL& referrer_url) const;
 
-  // Returns true if an extension with manifest type |manifest_type| is
-  // allowed to be installed.
-  bool IsAllowedManifestType(Manifest::Type manifest_type) const;
+  // Returns true if an extension with manifest type |manifest_type| and
+  // id |extension_id| is allowed to be installed.
+  bool IsAllowedManifestType(Manifest::Type manifest_type,
+                             const std::string& extension_id) const;
 
   // Returns the list of blocked API permissions for |extension|.
   APIPermissionSet GetBlockedAPIPermissions(const Extension* extension) const;
@@ -182,7 +183,7 @@
   // be loaded from or has the wrong type.
   const base::Value* LoadPreference(const char* pref_name,
                                     bool force_managed,
-                                    base::Value::Type expected_type);
+                                    base::Value::Type expected_type) const;
 
   void OnExtensionPrefChanged();
   void NotifyExtensionManagementPrefChanged();
@@ -195,6 +196,12 @@
   // Helper to update |extension_dict| for forced installs.
   void UpdateForcedExtensions(const base::DictionaryValue* extension_dict);
 
+  // Helper to update |settings_by_id_| for forced cloud reporting extension.
+  void UpdateForcedCloudReportingExtension();
+
+  // Returns true if cloud reporting policy is enabled.
+  bool IsCloudReportingPolicyEnabled() const;
+
   // Helper function to access |settings_by_id_| with |id| as key.
   // Adds a new IndividualSettings entry to |settings_by_id_| if none exists for
   // |id| yet.