[Extension] Rename classes in forced_extensions/

This CL combines number of small cosmetic changes:
 * extensions::InstallationReporter is renamed to
 extensions::InstallStageTracker as it doesn't report anything by
 itself, otherwise, different parts of extension installation flow
 report to it
 * extensions::InstallationTracker is renamed to
 extensions::ForceInstalledTracker to reflect what kind of extensions it
 tracks data of.
 * extension::InstallationMetrics is renamed to
 extensions::ForceInstalledMetrics to reflect what kind of extension it
 reports metrics about.
 * extensions::ForcedExtensionsInstallationTrackerTest is renamed to
 extensions::ForceInstalledMetrics test, as it is test for both Tracker
 and Metrics now, and Metrics class is more specific one.
 * A couple of unneeded includes are removed.
 * One stale TODO is removed.
 * Slightly updated comments to the classes.

Bug: 1076159
Change-Id: Ied9252d9277543e8a8d84f67b713cb344d3916d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207462
Commit-Queue: Oleg Davydov <[email protected]>
Reviewed-by: Sergey Poromov <[email protected]>
Reviewed-by: Drew Wilson <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#771587}
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index 0d2b964..c51cb16 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -31,7 +31,7 @@
 #include "chrome/browser/extensions/external_component_loader.h"
 #include "chrome/browser/extensions/external_policy_loader.h"
 #include "chrome/browser/extensions/external_pref_loader.h"
-#include "chrome/browser/extensions/forced_extensions/installation_reporter.h"
+#include "chrome/browser/extensions/forced_extensions/install_stage_tracker.h"
 #include "chrome/browser/policy/profile_policy_connector.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/common/chrome_paths.h"
@@ -149,11 +149,11 @@
   // away while |loader_| was working on the FILE thread.
   if (!service_) return;
 
-  InstallationReporter* installation_reporter =
-      InstallationReporter::Get(profile_);
+  InstallStageTracker* install_stage_tracker =
+      InstallStageTracker::Get(profile_);
   for (const auto& it : prefs->DictItems()) {
-    installation_reporter->ReportInstallationStage(
-        it.first, InstallationReporter::Stage::SEEN_BY_EXTERNAL_PROVIDER);
+    install_stage_tracker->ReportInstallationStage(
+        it.first, InstallStageTracker::Stage::SEEN_BY_EXTERNAL_PROVIDER);
   }
 
   prefs_ = std::move(prefs);
@@ -214,8 +214,8 @@
     std::vector<ExternalInstallInfoFile>* external_file_extensions) {
   // Set of unsupported extensions that need to be deleted from prefs_.
   std::set<std::string> unsupported_extensions;
-  InstallationReporter* installation_reporter =
-      InstallationReporter::Get(profile_);
+  InstallStageTracker* install_stage_tracker =
+      InstallStageTracker::Get(profile_);
 
   // Discover all the extensions this provider has.
   for (base::DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) {
@@ -227,9 +227,9 @@
       VLOG(1) << "Extension with key: " << extension_id << " was replaced "
               << "by a default ARC app, and will be uninstalled.";
       unsupported_extensions.emplace(extension_id);
-      installation_reporter->ReportFailure(
+      install_stage_tracker->ReportFailure(
           extension_id,
-          InstallationReporter::FailureReason::REPLACED_BY_ARC_APP);
+          InstallStageTracker::FailureReason::REPLACED_BY_ARC_APP);
       continue;
     }
 #endif  // defined(OS_CHROMEOS)
@@ -237,8 +237,8 @@
     if (!crx_file::id_util::IdIsValid(extension_id)) {
       LOG(WARNING) << "Malformed extension dictionary: key "
                    << extension_id.c_str() << " is not a valid id.";
-      installation_reporter->ReportFailure(
-          extension_id, InstallationReporter::FailureReason::INVALID_ID);
+      install_stage_tracker->ReportFailure(
+          extension_id, InstallStageTracker::FailureReason::INVALID_ID);
       continue;
     }
 
@@ -246,9 +246,9 @@
       LOG(WARNING) << "Malformed extension dictionary: key "
                    << extension_id.c_str()
                    << " has a value that is not a dictionary.";
-      installation_reporter->ReportFailure(
+      install_stage_tracker->ReportFailure(
           extension_id,
-          InstallationReporter::FailureReason::MALFORMED_EXTENSION_DICT);
+          InstallStageTracker::FailureReason::MALFORMED_EXTENSION_DICT);
       continue;
     }
 
@@ -265,8 +265,8 @@
         external_version_value->GetAsString(&external_version);
         has_external_version = true;
       } else {
-        installation_reporter->ReportFailure(
-            extension_id, InstallationReporter::FailureReason::
+        install_stage_tracker->ReportFailure(
+            extension_id, InstallStageTracker::FailureReason::
                               MALFORMED_EXTENSION_DICT_VERSION);
         LOG(WARNING) << "Malformed extension dictionary for extension: "
                      << extension_id.c_str() << ". " << kExternalVersion
@@ -278,9 +278,9 @@
     bool has_external_update_url = extension->GetString(kExternalUpdateUrl,
                                                         &external_update_url);
     if (has_external_crx != has_external_version) {
-      installation_reporter->ReportFailure(
+      install_stage_tracker->ReportFailure(
           extension_id,
-          InstallationReporter::FailureReason::MALFORMED_EXTENSION_DICT);
+          InstallStageTracker::FailureReason::MALFORMED_EXTENSION_DICT);
       LOG(WARNING) << "Malformed extension dictionary for extension: "
                    << extension_id.c_str() << ".  " << kExternalCrx
                    << " and " << kExternalVersion << " must be used together.";
@@ -288,9 +288,9 @@
     }
 
     if (has_external_crx == has_external_update_url) {
-      installation_reporter->ReportFailure(
+      install_stage_tracker->ReportFailure(
           extension_id,
-          InstallationReporter::FailureReason::MALFORMED_EXTENSION_DICT);
+          InstallStageTracker::FailureReason::MALFORMED_EXTENSION_DICT);
       LOG(WARNING) << "Malformed extension dictionary for extension: "
                    << extension_id.c_str() << ".  Exactly one of the "
                    << "followng keys should be used: " << kExternalCrx
@@ -325,9 +325,9 @@
 
       if (!locale_supported) {
         unsupported_extensions.insert(extension_id);
-        installation_reporter->ReportFailure(
+        install_stage_tracker->ReportFailure(
             extension_id,
-            InstallationReporter::FailureReason::LOCALE_NOT_SUPPORTED);
+            InstallStageTracker::FailureReason::LOCALE_NOT_SUPPORTED);
         VLOG(1) << "Skip installing (or uninstall) external extension: "
                 << extension_id << " because the extension doesn't support "
                 << "the browser locale.";
@@ -356,9 +356,9 @@
                              : nullptr;
       if (!extension) {
         unsupported_extensions.insert(extension_id);
-        installation_reporter->ReportFailure(
+        install_stage_tracker->ReportFailure(
             extension_id,
-            InstallationReporter::FailureReason::NOT_PERFORMING_NEW_INSTALL);
+            InstallStageTracker::FailureReason::NOT_PERFORMING_NEW_INSTALL);
         VLOG(1) << "Skip installing (or uninstall) external extension: "
                 << extension_id << " because the extension should be kept "
                 << "only if it is already installed.";
@@ -391,17 +391,17 @@
 
     if (has_external_crx) {
       if (crx_location_ == Manifest::INVALID_LOCATION) {
-        installation_reporter->ReportFailure(
+        install_stage_tracker->ReportFailure(
             extension_id,
-            InstallationReporter::FailureReason::NOT_SUPPORTED_EXTENSION_DICT);
+            InstallStageTracker::FailureReason::NOT_SUPPORTED_EXTENSION_DICT);
         LOG(WARNING) << "This provider does not support installing external "
                      << "extensions from crx files.";
         continue;
       }
       if (external_crx.find(base::FilePath::kParentDirectory) !=
           base::StringPiece::npos) {
-        installation_reporter->ReportFailure(
-            extension_id, InstallationReporter::FailureReason::
+        install_stage_tracker->ReportFailure(
+            extension_id, InstallStageTracker::FailureReason::
                               MALFORMED_EXTENSION_DICT_FILE_PATH);
         LOG(WARNING) << "Path traversal not allowed in path: "
                      << external_crx.c_str();
@@ -414,8 +414,8 @@
       if (!path.IsAbsolute()) {
         base::FilePath base_path = loader_->GetBaseCrxFilePath();
         if (base_path.empty()) {
-          installation_reporter->ReportFailure(
-              extension_id, InstallationReporter::FailureReason::
+          install_stage_tracker->ReportFailure(
+              extension_id, InstallStageTracker::FailureReason::
                                 MALFORMED_EXTENSION_DICT_FILE_PATH);
           LOG(WARNING) << "File path " << external_crx.c_str()
                        << " is relative.  An absolute path is required.";
@@ -426,8 +426,8 @@
 
       base::Version version(external_version);
       if (!version.IsValid()) {
-        installation_reporter->ReportFailure(
-            extension_id, InstallationReporter::FailureReason::
+        install_stage_tracker->ReportFailure(
+            extension_id, InstallStageTracker::FailureReason::
                               MALFORMED_EXTENSION_DICT_VERSION);
         LOG(WARNING) << "Malformed extension dictionary for extension: "
                      << extension_id.c_str() << ".  Invalid version string \""
@@ -440,17 +440,17 @@
     } else {  // if (has_external_update_url)
       CHECK(has_external_update_url);  // Checking of keys above ensures this.
       if (download_location_ == Manifest::INVALID_LOCATION) {
-        installation_reporter->ReportFailure(
+        install_stage_tracker->ReportFailure(
             extension_id,
-            InstallationReporter::FailureReason::NOT_SUPPORTED_EXTENSION_DICT);
+            InstallStageTracker::FailureReason::NOT_SUPPORTED_EXTENSION_DICT);
         LOG(WARNING) << "This provider does not support installing external "
                      << "extensions from update URLs.";
         continue;
       }
       GURL update_url(external_update_url);
       if (!update_url.is_valid()) {
-        installation_reporter->ReportFailure(
-            extension_id, InstallationReporter::FailureReason::
+        install_stage_tracker->ReportFailure(
+            extension_id, InstallStageTracker::FailureReason::
                               MALFORMED_EXTENSION_DICT_UPDATE_URL);
         LOG(WARNING) << "Malformed extension dictionary for extension: "
                      << extension_id.c_str() << ".  Key " << kExternalUpdateUrl
@@ -536,8 +536,8 @@
     base::Version min_version(min_profile_created_by_version);
     if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) {
       unsupported_extensions->insert(extension_id);
-      InstallationReporter::Get(profile_)->ReportFailure(
-          extension_id, InstallationReporter::FailureReason::TOO_OLD_PROFILE);
+      InstallStageTracker::Get(profile_)->ReportFailure(
+          extension_id, InstallStageTracker::FailureReason::TOO_OLD_PROFILE);
       VLOG(1) << "Skip installing (or uninstall) external extension: "
               << extension_id
               << " profile.created_by_version: " << profile_version.GetString()
@@ -561,9 +561,9 @@
         profile_->GetProfilePolicyConnector();
     if (connector->IsManaged()) {
       unsupported_extensions->insert(extension_id);
-      InstallationReporter::Get(profile_)->ReportFailure(
+      InstallStageTracker::Get(profile_)->ReportFailure(
           extension_id,
-          InstallationReporter::FailureReason::DO_NOT_INSTALL_FOR_ENTERPRISE);
+          InstallStageTracker::FailureReason::DO_NOT_INSTALL_FOR_ENTERPRISE);
       VLOG(1) << "Skip installing (or uninstall) external extension "
               << extension_id << " restricted for managed user";
       return false;