Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6680)

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2067943004: ARC: Add badge for Chrome hosted Apps if Arc++ is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failed unittest. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
index 2c8306b1bcf73d1ea6eaf5a0818d3917134b2dd4..8f3461bb0fc5c575a85d74d41127c1a42849cdcd 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
+#include "chrome/browser/chromeos/extensions/gfx_utils.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_app_icon_loader.h"
#include "chrome/browser/extensions/extension_util.h"
@@ -947,6 +948,21 @@ ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() {
return nullptr;
}
+void ChromeLauncherControllerImpl::MayUpdateBrowserShortcutItem() {
+ for (size_t index = 0; index < model_->items().size(); index++) {
+ ash::ShelfItem item = model_->items()[index];
+ if (item.type == ash::TYPE_BROWSER_SHORTCUT) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ item.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32);
+ if (extensions::util::MaybeApplyChromeBadge(
+ profile_, extension_misc::kChromeAppId, &item.image)) {
+ model_->Set(index, item);
+ }
+ break;
+ }
+ }
+}
+
LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController(
const ash::ShelfID id) {
if (!HasShelfIDToAppIDMapping(id))
@@ -1141,6 +1157,11 @@ void ChromeLauncherControllerImpl::OnAppInstalled(
void ChromeLauncherControllerImpl::OnAppUpdated(
content::BrowserContext* browser_context,
const std::string& app_id) {
+ if (app_id == extension_misc::kChromeAppId) {
+ MayUpdateBrowserShortcutItem();
+ return;
+ }
+
AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
if (app_icon_loader)
app_icon_loader->UpdateImage(app_id);
@@ -1349,6 +1370,8 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
// of iterators because of model mutations as part of the loop.
std::vector<std::string>::const_iterator pref_app_id(pinned_apps.begin());
for (; index < max_index && pref_app_id != pinned_apps.end(); ++index) {
+ // Update apps icon if applicable.
+ OnAppUpdated(profile_, *pref_app_id);
// Check if we have an item which we need to handle.
if (*pref_app_id == extension_misc::kChromeAppId ||
*pref_app_id == ash::kPinnedAppsPlaceholder ||
@@ -1443,6 +1466,8 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
// Append unprocessed items from the pref to the end of the model.
for (; pref_app_id != pinned_apps.end(); ++pref_app_id) {
+ // Update apps icon if applicable.
+ OnAppUpdated(profile_, *pref_app_id);
// All items but the chrome and / or app list shortcut needs to be added.
bool is_chrome = *pref_app_id == extension_misc::kChromeAppId;
bool is_app_list = *pref_app_id == ash::kPinnedAppsPlaceholder;
@@ -1593,6 +1618,7 @@ ash::ShelfID ChromeLauncherControllerImpl::CreateBrowserShortcutLauncherItem() {
ash::ShelfID id = model_->next_id();
size_t index = GetChromeIconIndexForCreation();
model_->AddAt(index, browser_shortcut);
+ MayUpdateBrowserShortcutItem();
id_to_item_controller_map_[id] =
new BrowserShortcutLauncherItemController(this, model_);
id_to_item_controller_map_[id]->set_shelf_id(id);

Powered by Google App Engine
This is Rietveld 408576698