Chromium Code Reviews| 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" | 8 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 DCHECK(context); | 187 DCHECK(context); |
| 188 DCHECK(icon_out); | 188 DCHECK(icon_out); |
| 189 | 189 |
| 190 Profile* profile = Profile::FromBrowserContext(context); | 190 Profile* profile = Profile::FromBrowserContext(context); |
| 191 // Only apply Chrome badge for the primary profile. | 191 // Only apply Chrome badge for the primary profile. |
| 192 if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || | 192 if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || |
| 193 !multi_user_util::IsProfileFromActiveUser(profile)) { | 193 !multi_user_util::IsProfileFromActiveUser(profile)) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 | 196 |
| 197 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); | |
|
hidehiko
2016/11/03 22:54:15
Note: conceptually HasEquivalentInstalledArcApp sh
| |
| 198 // Only apply Chrome badge when ARC service is enabled. | |
| 199 if (!arc_auth_service || | |
|
khmel
2016/11/03 23:09:17
nit: you might no need #include "chrome/browser/ch
hidehiko
2016/11/04 00:04:56
Done.
| |
| 200 arc_auth_service->state() != arc::ArcAuthService::State::ACTIVE) { | |
| 201 return; | |
| 202 } | |
| 203 | |
| 204 const ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 197 const ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
| 205 if (!registry || !registry->GetInstalledExtension(extension_id)) | 198 if (!registry || !registry->GetInstalledExtension(extension_id)) |
| 206 return; | 199 return; |
| 207 | 200 |
| 208 if (!HasEquivalentInstalledArcApp(context, extension_id)) | 201 if (!HasEquivalentInstalledArcApp(context, extension_id)) |
| 209 return; | 202 return; |
| 210 | 203 |
| 211 const gfx::ImageSkia* badge_image = | 204 const gfx::ImageSkia* badge_image = |
| 212 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 205 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 213 IDR_ARC_DUAL_ICON_BADGE); | 206 IDR_ARC_DUAL_ICON_BADGE); |
| 214 DCHECK(badge_image); | 207 DCHECK(badge_image); |
| 215 | 208 |
| 216 gfx::ImageSkia resized_badge_image = *badge_image; | 209 gfx::ImageSkia resized_badge_image = *badge_image; |
| 217 if (badge_image->size() != icon_out->size()) { | 210 if (badge_image->size() != icon_out->size()) { |
| 218 resized_badge_image = gfx::ImageSkiaOperations::CreateResizedImage( | 211 resized_badge_image = gfx::ImageSkiaOperations::CreateResizedImage( |
| 219 *badge_image, skia::ImageOperations::RESIZE_BEST, icon_out->size()); | 212 *badge_image, skia::ImageOperations::RESIZE_BEST, icon_out->size()); |
| 220 } | 213 } |
| 221 *icon_out = gfx::ImageSkiaOperations::CreateSuperimposedImage( | 214 *icon_out = gfx::ImageSkiaOperations::CreateSuperimposedImage( |
| 222 *icon_out, resized_badge_image); | 215 *icon_out, resized_badge_image); |
| 223 return; | 216 return; |
| 224 } | 217 } |
| 225 | 218 |
| 226 } // namespace util | 219 } // namespace util |
| 227 } // namespace extensions | 220 } // namespace extensions |
| OLD | NEW |