OLD | NEW |
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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 771 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
772 if (app_icon_loader) { | 772 if (app_icon_loader) { |
773 app_icon_loader->ClearImage(app_id); | 773 app_icon_loader->ClearImage(app_id); |
774 app_icon_loader->FetchImage(app_id); | 774 app_icon_loader->FetchImage(app_id); |
775 } | 775 } |
776 } | 776 } |
777 | 777 |
778 UpdateAppLaunchersFromPref(); | 778 UpdateAppLaunchersFromPref(); |
779 } | 779 } |
780 | 780 |
781 void ChromeLauncherController::OnAppUpdated( | |
782 content::BrowserContext* browser_context, | |
783 const std::string& app_id) { | |
784 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | |
785 if (app_icon_loader) | |
786 app_icon_loader->UpdateImage(app_id); | |
787 } | |
788 | |
789 void ChromeLauncherController::OnAppUninstalledPrepared( | 781 void ChromeLauncherController::OnAppUninstalledPrepared( |
790 content::BrowserContext* browser_context, | 782 content::BrowserContext* browser_context, |
791 const std::string& app_id) { | 783 const std::string& app_id) { |
792 // Since we might have windowed apps of this type which might have | 784 // Since we might have windowed apps of this type which might have |
793 // outstanding locks which needs to be removed. | 785 // outstanding locks which needs to be removed. |
794 const Profile* profile = Profile::FromBrowserContext(browser_context); | 786 const Profile* profile = Profile::FromBrowserContext(browser_context); |
795 ash::ShelfID shelf_id(app_id); | 787 ash::ShelfID shelf_id(app_id); |
796 if (GetItem(shelf_id) != nullptr) | 788 if (GetItem(shelf_id) != nullptr) |
797 CloseWindowedAppsFromRemovedExtension(app_id, profile); | 789 CloseWindowedAppsFromRemovedExtension(app_id, profile); |
798 | 790 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 base::MakeUnique<LauncherControllerHelper>(profile_); | 1159 base::MakeUnique<LauncherControllerHelper>(profile_); |
1168 } else { | 1160 } else { |
1169 launcher_controller_helper_->set_profile(profile_); | 1161 launcher_controller_helper_->set_profile(profile_); |
1170 } | 1162 } |
1171 | 1163 |
1172 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded | 1164 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded |
1173 // image is associated with a profile (its loader requires the profile). | 1165 // image is associated with a profile (its loader requires the profile). |
1174 // Since icon size changes are possible, the icon could be requested to be | 1166 // Since icon size changes are possible, the icon could be requested to be |
1175 // reloaded. However - having it not multi profile aware would cause problems | 1167 // reloaded. However - having it not multi profile aware would cause problems |
1176 // if the icon cache gets deleted upon user switch. | 1168 // if the icon cache gets deleted upon user switch. |
1177 std::unique_ptr<AppIconLoader> extension_app_icon_loader = | 1169 std::unique_ptr<AppIconLoader> chrome_app_icon_loader = |
1178 base::MakeUnique<extensions::ExtensionAppIconLoader>( | 1170 base::MakeUnique<extensions::ChromeAppIconLoader>( |
1179 profile_, extension_misc::EXTENSION_ICON_SMALL, this); | 1171 profile_, extension_misc::EXTENSION_ICON_SMALL, this); |
1180 app_icon_loaders_.push_back(std::move(extension_app_icon_loader)); | 1172 app_icon_loaders_.push_back(std::move(chrome_app_icon_loader)); |
1181 | 1173 |
1182 if (arc::IsArcAllowedForProfile(profile_)) { | 1174 if (arc::IsArcAllowedForProfile(profile_)) { |
1183 std::unique_ptr<AppIconLoader> arc_app_icon_loader = | 1175 std::unique_ptr<AppIconLoader> arc_app_icon_loader = |
1184 base::MakeUnique<ArcAppIconLoader>( | 1176 base::MakeUnique<ArcAppIconLoader>( |
1185 profile_, extension_misc::EXTENSION_ICON_SMALL, this); | 1177 profile_, extension_misc::EXTENSION_ICON_SMALL, this); |
1186 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); | 1178 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); |
1187 } | 1179 } |
1188 | 1180 |
1189 SetShelfBehaviorsFromPrefs(); | 1181 SetShelfBehaviorsFromPrefs(); |
1190 | 1182 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | 1402 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); |
1411 | 1403 |
1412 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); | 1404 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); |
1413 DCHECK_GE(app_list_index, 0); | 1405 DCHECK_GE(app_list_index, 0); |
1414 ash::ShelfItem item = model_->items()[app_list_index]; | 1406 ash::ShelfItem item = model_->items()[app_list_index]; |
1415 if (item.title != title) { | 1407 if (item.title != title) { |
1416 item.title = title; | 1408 item.title = title; |
1417 model_->Set(app_list_index, item); | 1409 model_->Set(app_list_index, item); |
1418 } | 1410 } |
1419 } | 1411 } |
OLD | NEW |