| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/gfx_utils.h" | 5 #include "chrome/browser/chromeos/extensions/gfx_utils.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | |
| 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" | |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 13 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 11 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 16 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 17 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" | 17 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 DCHECK(context); | 185 DCHECK(context); |
| 188 DCHECK(icon_out); | 186 DCHECK(icon_out); |
| 189 | 187 |
| 190 Profile* profile = Profile::FromBrowserContext(context); | 188 Profile* profile = Profile::FromBrowserContext(context); |
| 191 // Only apply Chrome badge for the primary profile. | 189 // Only apply Chrome badge for the primary profile. |
| 192 if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || | 190 if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || |
| 193 !multi_user_util::IsProfileFromActiveUser(profile)) { | 191 !multi_user_util::IsProfileFromActiveUser(profile)) { |
| 194 return; | 192 return; |
| 195 } | 193 } |
| 196 | 194 |
| 197 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); | |
| 198 // Only apply Chrome badge when ARC service is enabled. | |
| 199 if (!arc_auth_service || | |
| 200 arc_auth_service->state() != arc::ArcAuthService::State::ACTIVE) { | |
| 201 return; | |
| 202 } | |
| 203 | |
| 204 const ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 195 const ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
| 205 if (!registry || !registry->GetInstalledExtension(extension_id)) | 196 if (!registry || !registry->GetInstalledExtension(extension_id)) |
| 206 return; | 197 return; |
| 207 | 198 |
| 208 if (!HasEquivalentInstalledArcApp(context, extension_id)) | 199 if (!HasEquivalentInstalledArcApp(context, extension_id)) |
| 209 return; | 200 return; |
| 210 | 201 |
| 211 const gfx::ImageSkia* badge_image = | 202 const gfx::ImageSkia* badge_image = |
| 212 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 203 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 213 IDR_ARC_DUAL_ICON_BADGE); | 204 IDR_ARC_DUAL_ICON_BADGE); |
| 214 DCHECK(badge_image); | 205 DCHECK(badge_image); |
| 215 | 206 |
| 216 gfx::ImageSkia resized_badge_image = *badge_image; | 207 gfx::ImageSkia resized_badge_image = *badge_image; |
| 217 if (badge_image->size() != icon_out->size()) { | 208 if (badge_image->size() != icon_out->size()) { |
| 218 resized_badge_image = gfx::ImageSkiaOperations::CreateResizedImage( | 209 resized_badge_image = gfx::ImageSkiaOperations::CreateResizedImage( |
| 219 *badge_image, skia::ImageOperations::RESIZE_BEST, icon_out->size()); | 210 *badge_image, skia::ImageOperations::RESIZE_BEST, icon_out->size()); |
| 220 } | 211 } |
| 221 *icon_out = gfx::ImageSkiaOperations::CreateSuperimposedImage( | 212 *icon_out = gfx::ImageSkiaOperations::CreateSuperimposedImage( |
| 222 *icon_out, resized_badge_image); | 213 *icon_out, resized_badge_image); |
| 223 return; | 214 return; |
| 224 } | 215 } |
| 225 | 216 |
| 226 } // namespace util | 217 } // namespace util |
| 227 } // namespace extensions | 218 } // namespace extensions |
| OLD | NEW |