Make LoadIconFromExtension check Chrome-OS-ness

The icon loading helper functions, prior to both this CL and
http://crrev.com/c/1373450, called app_list image processing functions
unconditionally, which broke the build, as app_list is Chrome OS only.

The quick fix was to build app_icon_factory.cc conditionally, only for
Chrome OS. This was http://crrev.com/c/1373450

This fix is to make more of app_icon_factory.cc conditional on #ifdef
OS_CHROMEOS. The App Service isn't necessarily Chrome OS only.

A longer term possibility is to move the app_list image processing
function out of //chrome/browser/ui/app_list per se, and build it
unconditionally. This would be a user-visible change (in that extension
icons on desktop Chrome might look different), but arguably a change
that improves consistency. In any case, doing that is out of scope of
this CL. In the initial stage, the App Service aims to be a
user-invisible refactoring.

BUG=826982

Change-Id: Ic4fd3db27789117bb57e72e6b557b3e56b28fb7f
Reviewed-on: https://chromium-review.googlesource.com/c/1374889
Commit-Queue: Nigel Tao <[email protected]>
Reviewed-by: Dominick Ng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#616190}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 2ed7fe1..8c17a3d 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -2590,6 +2590,8 @@
     sources += [
       "accessibility/invert_bubble_prefs.cc",
       "accessibility/invert_bubble_prefs.h",
+      "apps/app_service/app_icon_factory.cc",
+      "apps/app_service/app_icon_factory.h",
       "apps/app_service/app_icon_source.cc",
       "apps/app_service/app_icon_source.h",
       "apps/app_service/app_service_proxy.cc",
@@ -3120,8 +3122,6 @@
 
   if (is_chromeos) {
     sources += [
-      "apps/app_service/app_icon_factory.cc",
-      "apps/app_service/app_icon_factory.h",
       "apps/app_service/built_in_chromeos_apps.cc",
       "apps/app_service/built_in_chromeos_apps.h",
       "apps/app_service/extension_apps.cc",
diff --git a/chrome/browser/apps/app_service/app_icon_factory.cc b/chrome/browser/apps/app_service/app_icon_factory.cc
index 44db5ba..5f39b134 100644
--- a/chrome/browser/apps/app_service/app_icon_factory.cc
+++ b/chrome/browser/apps/app_service/app_icon_factory.cc
@@ -18,7 +18,6 @@
 #include "chrome/browser/extensions/chrome_app_icon_loader.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/extension_util.h"
-#include "chrome/browser/ui/app_list/md_icon_normalizer.h"
 #include "extensions/browser/extension_system.h"
 #include "extensions/browser/image_loader.h"
 #include "extensions/common/manifest_handlers/icons_handler.h"
@@ -32,6 +31,7 @@
 
 #if defined(OS_CHROMEOS)
 #include "chrome/browser/chromeos/extensions/gfx_utils.h"
+#include "chrome/browser/ui/app_list/md_icon_normalizer.h"
 #endif
 
 namespace {
@@ -128,8 +128,11 @@
         break;
 
       case apps::mojom::IconCompression::kUncompressed: {
+        extensions::ChromeAppIconLoader::ResizeFunction resize_function;
         bool apply_chrome_badge = false;
 #if defined(OS_CHROMEOS)
+        resize_function =
+            base::BindRepeating(&app_list::MaybeResizeAndPadIconForMd),
         apply_chrome_badge =
             extensions::util::ShouldApplyChromeBadge(context, extension_id);
 #endif
@@ -141,8 +144,7 @@
                 &RunCallbackWithUncompressedImage,
                 base::BindOnce(
                     &ChromeAppIconApplyEffects, size_hint_in_dip,
-                    base::BindRepeating(&app_list::MaybeResizeAndPadIconForMd),
-                    apply_chrome_badge,
+                    resize_function, apply_chrome_badge,
                     extensions::util::IsAppLaunchable(extension_id, context),
                     extension->from_bookmark()),
                 std::move(callback)));