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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "ash/multi_profile_uma.h" 7 #include "ash/multi_profile_uma.h"
8 #include "ash/public/cpp/shelf_item.h" 8 #include "ash/public/cpp/shelf_item.h"
9 #include "ash/public/interfaces/constants.mojom.h" 9 #include "ash/public/interfaces/constants.mojom.h"
10 #include "ash/resources/grit/ash_resources.h" 10 #include "ash/resources/grit/ash_resources.h"
11 #include "ash/shelf/shelf_model.h" 11 #include "ash/shelf/shelf_model.h"
12 #include "ash/shelf/wm_shelf.h" 12 #include "ash/shelf/wm_shelf.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_port.h" 14 #include "ash/shell_port.h"
15 #include "ash/strings/grit/ash_strings.h" 15 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/tray/system_tray_delegate.h" 16 #include "ash/system/tray/system_tray_delegate.h"
17 #include "ash/wm_window.h" 17 #include "ash/wm_window.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/strings/pattern.h" 19 #include "base/strings/pattern.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "chrome/browser/chromeos/arc/arc_util.h" 23 #include "chrome/browser/chromeos/arc/arc_util.h"
24 #include "chrome/browser/extensions/extension_app_icon_loader.h" 24 #include "chrome/browser/extensions/chrome_app_icon_loader.h"
25 #include "chrome/browser/extensions/extension_util.h" 25 #include "chrome/browser/extensions/extension_util.h"
26 #include "chrome/browser/prefs/pref_service_syncable_util.h" 26 #include "chrome/browser/prefs/pref_service_syncable_util.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 29 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
30 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" 30 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
31 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 31 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
32 #include "chrome/browser/ui/ash/app_sync_ui_state.h" 32 #include "chrome/browser/ui/ash/app_sync_ui_state.h"
33 #include "chrome/browser/ui/ash/ash_util.h" 33 #include "chrome/browser/ui/ash/ash_util.h"
34 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 34 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 807 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
808 if (app_icon_loader) { 808 if (app_icon_loader) {
809 app_icon_loader->ClearImage(app_id); 809 app_icon_loader->ClearImage(app_id);
810 app_icon_loader->FetchImage(app_id); 810 app_icon_loader->FetchImage(app_id);
811 } 811 }
812 } 812 }
813 813
814 UpdateAppLaunchersFromPref(); 814 UpdateAppLaunchersFromPref();
815 } 815 }
816 816
817 void ChromeLauncherController::OnAppUpdated(
818 content::BrowserContext* browser_context,
819 const std::string& app_id) {
820 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
821 if (app_icon_loader)
822 app_icon_loader->UpdateImage(app_id);
823 }
824
825 void ChromeLauncherController::OnAppUninstalledPrepared( 817 void ChromeLauncherController::OnAppUninstalledPrepared(
826 content::BrowserContext* browser_context, 818 content::BrowserContext* browser_context,
827 const std::string& app_id) { 819 const std::string& app_id) {
828 // Since we might have windowed apps of this type which might have 820 // Since we might have windowed apps of this type which might have
829 // outstanding locks which needs to be removed. 821 // outstanding locks which needs to be removed.
830 const Profile* profile = Profile::FromBrowserContext(browser_context); 822 const Profile* profile = Profile::FromBrowserContext(browser_context);
831 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); 823 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id);
832 if (!shelf_id.IsNull()) 824 if (!shelf_id.IsNull())
833 CloseWindowedAppsFromRemovedExtension(app_id, profile); 825 CloseWindowedAppsFromRemovedExtension(app_id, profile);
834 826
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 base::MakeUnique<LauncherControllerHelper>(profile_); 1217 base::MakeUnique<LauncherControllerHelper>(profile_);
1226 } else { 1218 } else {
1227 launcher_controller_helper_->set_profile(profile_); 1219 launcher_controller_helper_->set_profile(profile_);
1228 } 1220 }
1229 1221
1230 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded 1222 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded
1231 // image is associated with a profile (its loader requires the profile). 1223 // image is associated with a profile (its loader requires the profile).
1232 // Since icon size changes are possible, the icon could be requested to be 1224 // Since icon size changes are possible, the icon could be requested to be
1233 // reloaded. However - having it not multi profile aware would cause problems 1225 // reloaded. However - having it not multi profile aware would cause problems
1234 // if the icon cache gets deleted upon user switch. 1226 // if the icon cache gets deleted upon user switch.
1235 std::unique_ptr<AppIconLoader> extension_app_icon_loader = 1227 std::unique_ptr<AppIconLoader> chrome_app_icon_loader =
1236 base::MakeUnique<extensions::ExtensionAppIconLoader>( 1228 base::MakeUnique<extensions::ChromeAppIconLoader>(
1237 profile_, extension_misc::EXTENSION_ICON_SMALL, this); 1229 profile_, extension_misc::EXTENSION_ICON_SMALL, this);
1238 app_icon_loaders_.push_back(std::move(extension_app_icon_loader)); 1230 app_icon_loaders_.push_back(std::move(chrome_app_icon_loader));
1239 1231
1240 if (arc::IsArcAllowedForProfile(profile_)) { 1232 if (arc::IsArcAllowedForProfile(profile_)) {
1241 std::unique_ptr<AppIconLoader> arc_app_icon_loader = 1233 std::unique_ptr<AppIconLoader> arc_app_icon_loader =
1242 base::MakeUnique<ArcAppIconLoader>( 1234 base::MakeUnique<ArcAppIconLoader>(
1243 profile_, extension_misc::EXTENSION_ICON_SMALL, this); 1235 profile_, extension_misc::EXTENSION_ICON_SMALL, this);
1244 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); 1236 app_icon_loaders_.push_back(std::move(arc_app_icon_loader));
1245 } 1237 }
1246 1238
1247 SetShelfBehaviorsFromPrefs(); 1239 SetShelfBehaviorsFromPrefs();
1248 1240
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); 1463 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1472 1464
1473 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); 1465 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1474 DCHECK_GE(app_list_index, 0); 1466 DCHECK_GE(app_list_index, 0);
1475 ash::ShelfItem item = model_->items()[app_list_index]; 1467 ash::ShelfItem item = model_->items()[app_list_index];
1476 if (item.title != title) { 1468 if (item.title != title) {
1477 item.title = title; 1469 item.title = title;
1478 model_->Set(app_list_index, item); 1470 model_->Set(app_list_index, item);
1479 } 1471 }
1480 } 1472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698