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

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

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: rebase + nit 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 813 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
814 if (app_icon_loader) { 814 if (app_icon_loader) {
815 app_icon_loader->ClearImage(app_id); 815 app_icon_loader->ClearImage(app_id);
816 app_icon_loader->FetchImage(app_id); 816 app_icon_loader->FetchImage(app_id);
817 } 817 }
818 } 818 }
819 819
820 UpdateAppLaunchersFromPref(); 820 UpdateAppLaunchersFromPref();
821 } 821 }
822 822
823 void ChromeLauncherController::OnAppUpdated(
824 content::BrowserContext* browser_context,
825 const std::string& app_id) {
826 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
827 if (app_icon_loader)
828 app_icon_loader->UpdateImage(app_id);
829 }
830
831 void ChromeLauncherController::OnAppUninstalledPrepared( 823 void ChromeLauncherController::OnAppUninstalledPrepared(
832 content::BrowserContext* browser_context, 824 content::BrowserContext* browser_context,
833 const std::string& app_id) { 825 const std::string& app_id) {
834 // Since we might have windowed apps of this type which might have 826 // Since we might have windowed apps of this type which might have
835 // outstanding locks which needs to be removed. 827 // outstanding locks which needs to be removed.
836 const Profile* profile = Profile::FromBrowserContext(browser_context); 828 const Profile* profile = Profile::FromBrowserContext(browser_context);
837 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); 829 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id);
838 if (shelf_id != ash::kInvalidShelfID) 830 if (shelf_id != ash::kInvalidShelfID)
839 CloseWindowedAppsFromRemovedExtension(app_id, profile); 831 CloseWindowedAppsFromRemovedExtension(app_id, profile);
840 832
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 base::MakeUnique<LauncherControllerHelper>(profile_); 1231 base::MakeUnique<LauncherControllerHelper>(profile_);
1240 } else { 1232 } else {
1241 launcher_controller_helper_->set_profile(profile_); 1233 launcher_controller_helper_->set_profile(profile_);
1242 } 1234 }
1243 1235
1244 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded 1236 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded
1245 // image is associated with a profile (its loader requires the profile). 1237 // image is associated with a profile (its loader requires the profile).
1246 // Since icon size changes are possible, the icon could be requested to be 1238 // Since icon size changes are possible, the icon could be requested to be
1247 // reloaded. However - having it not multi profile aware would cause problems 1239 // reloaded. However - having it not multi profile aware would cause problems
1248 // if the icon cache gets deleted upon user switch. 1240 // if the icon cache gets deleted upon user switch.
1249 std::unique_ptr<AppIconLoader> extension_app_icon_loader = 1241 std::unique_ptr<AppIconLoader> chrome_app_icon_loader =
1250 base::MakeUnique<extensions::ExtensionAppIconLoader>( 1242 base::MakeUnique<extensions::ChromeAppIconLoader>(
1251 profile_, extension_misc::EXTENSION_ICON_SMALL, this); 1243 profile_, extension_misc::EXTENSION_ICON_SMALL, this);
1252 app_icon_loaders_.push_back(std::move(extension_app_icon_loader)); 1244 app_icon_loaders_.push_back(std::move(chrome_app_icon_loader));
1253 1245
1254 if (arc::IsArcAllowedForProfile(profile_)) { 1246 if (arc::IsArcAllowedForProfile(profile_)) {
1255 std::unique_ptr<AppIconLoader> arc_app_icon_loader = 1247 std::unique_ptr<AppIconLoader> arc_app_icon_loader =
1256 base::MakeUnique<ArcAppIconLoader>( 1248 base::MakeUnique<ArcAppIconLoader>(
1257 profile_, extension_misc::EXTENSION_ICON_SMALL, this); 1249 profile_, extension_misc::EXTENSION_ICON_SMALL, this);
1258 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); 1250 app_icon_loaders_.push_back(std::move(arc_app_icon_loader));
1259 } 1251 }
1260 1252
1261 SetShelfBehaviorsFromPrefs(); 1253 SetShelfBehaviorsFromPrefs();
1262 1254
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); 1480 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1489 1481
1490 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); 1482 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1491 DCHECK_GE(app_list_index, 0); 1483 DCHECK_GE(app_list_index, 0);
1492 ash::ShelfItem item = model_->items()[app_list_index]; 1484 ash::ShelfItem item = model_->items()[app_list_index];
1493 if (item.title != title) { 1485 if (item.title != title) {
1494 item.title = title; 1486 item.title = title;
1495 model_->Set(app_list_index, item); 1487 model_->Set(app_list_index, item);
1496 } 1488 }
1497 } 1489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698