| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
| 13 #include "ash/multi_profile_uma.h" | 13 #include "ash/multi_profile_uma.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
| 16 #include "ash/shelf/shelf_item_delegate_manager.h" | 16 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 17 #include "ash/shelf/shelf_model.h" | 17 #include "ash/shelf/shelf_model.h" |
| 18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 19 #include "ash/system/tray/system_tray_delegate.h" | 19 #include "ash/system/tray/system_tray_delegate.h" |
| 20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/macros.h" | 22 #include "base/macros.h" |
| 23 #include "base/strings/pattern.h" | 23 #include "base/strings/pattern.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 30 #include "chrome/browser/defaults.h" | 31 #include "chrome/browser/defaults.h" |
| 31 #include "chrome/browser/extensions/extension_app_icon_loader.h" | 32 #include "chrome/browser/extensions/extension_app_icon_loader.h" |
| 32 #include "chrome/browser/extensions/extension_util.h" | 33 #include "chrome/browser/extensions/extension_util.h" |
| 33 #include "chrome/browser/extensions/launch_util.h" | 34 #include "chrome/browser/extensions/launch_util.h" |
| 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 35 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 36 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/profiles/profile_manager.h" | 38 #include "chrome/browser/profiles/profile_manager.h" |
| 38 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" | 39 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" |
| 39 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 40 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 41 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 42 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 41 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 43 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 42 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 44 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 43 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 45 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 46 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 47 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 46 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 48 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 47 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 49 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 48 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 50 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 49 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 51 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if (app_id == app_id_) | 176 if (app_id == app_id_) |
| 175 return false; | 177 return false; |
| 176 } | 178 } |
| 177 } | 179 } |
| 178 } | 180 } |
| 179 // Default, user added new pins | 181 // Default, user added new pins |
| 180 return true; | 182 return true; |
| 181 } | 183 } |
| 182 | 184 |
| 183 const char* const kPinProhibitedExtensionIds[] = { | 185 const char* const kPinProhibitedExtensionIds[] = { |
| 184 "cnbgggchhmkkdmeppjobngjoejnihlei", // Arc Support | 186 ArcSupportHost::kHostAppId, arc::kPlayStoreAppId, |
| 185 }; | 187 }; |
| 186 | 188 |
| 187 const size_t kPinProhibitedExtensionIdsLength = | 189 const size_t kPinProhibitedExtensionIdsLength = |
| 188 arraysize(kPinProhibitedExtensionIds); | 190 arraysize(kPinProhibitedExtensionIds); |
| 189 | 191 |
| 190 } // namespace | 192 } // namespace |
| 191 | 193 |
| 192 // A class to get events from ChromeOS when a user gets changed or added. | 194 // A class to get events from ChromeOS when a user gets changed or added. |
| 193 class ChromeLauncherControllerUserSwitchObserver | 195 class ChromeLauncherControllerUserSwitchObserver |
| 194 : public user_manager::UserManager::UserSessionStateObserver { | 196 : public user_manager::UserManager::UserSessionStateObserver { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 440 } |
| 439 | 441 |
| 440 void ChromeLauncherController::CloseLauncherItem(ash::ShelfID id) { | 442 void ChromeLauncherController::CloseLauncherItem(ash::ShelfID id) { |
| 441 CHECK(id); | 443 CHECK(id); |
| 442 if (IsPinned(id)) { | 444 if (IsPinned(id)) { |
| 443 // Create a new shortcut controller. | 445 // Create a new shortcut controller. |
| 444 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | 446 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); |
| 445 CHECK(iter != id_to_item_controller_map_.end()); | 447 CHECK(iter != id_to_item_controller_map_.end()); |
| 446 SetItemStatus(id, ash::STATUS_CLOSED); | 448 SetItemStatus(id, ash::STATUS_CLOSED); |
| 447 std::string app_id = iter->second->app_id(); | 449 std::string app_id = iter->second->app_id(); |
| 448 iter->second = new AppShortcutLauncherItemController(app_id, this); | 450 iter->second = AppShortcutLauncherItemController::Create(app_id, this); |
| 449 iter->second->set_shelf_id(id); | 451 iter->second->set_shelf_id(id); |
| 450 // Existing controller is destroyed and replaced by registering again. | 452 // Existing controller is destroyed and replaced by registering again. |
| 451 SetShelfItemDelegate(id, iter->second); | 453 SetShelfItemDelegate(id, iter->second); |
| 452 } else { | 454 } else { |
| 453 LauncherItemClosed(id); | 455 LauncherItemClosed(id); |
| 454 } | 456 } |
| 455 } | 457 } |
| 456 | 458 |
| 457 AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable( | 459 AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable( |
| 458 const std::string& app_id) { | 460 const std::string& app_id) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 ash::ShelfID id = GetShelfIDForAppID(app_id); | 610 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| 609 if (id) { | 611 if (id) { |
| 610 LauncherItemController* controller = GetLauncherItemController(id); | 612 LauncherItemController* controller = GetLauncherItemController(id); |
| 611 controller->Activate(source); | 613 controller->Activate(source); |
| 612 return; | 614 return; |
| 613 } | 615 } |
| 614 | 616 |
| 615 // Create a temporary application launcher item and use it to see if there are | 617 // Create a temporary application launcher item and use it to see if there are |
| 616 // running instances. | 618 // running instances. |
| 617 std::unique_ptr<AppShortcutLauncherItemController> app_controller( | 619 std::unique_ptr<AppShortcutLauncherItemController> app_controller( |
| 618 new AppShortcutLauncherItemController(app_id, this)); | 620 AppShortcutLauncherItemController::Create(app_id, this)); |
| 619 if (!app_controller->GetRunningApplications().empty()) | 621 if (!app_controller->GetRunningApplications().empty()) |
| 620 app_controller->Activate(source); | 622 app_controller->Activate(source); |
| 621 else | 623 else |
| 622 LaunchApp(app_id, source, event_flags); | 624 LaunchApp(app_id, source, event_flags); |
| 623 } | 625 } |
| 624 | 626 |
| 625 extensions::LaunchType ChromeLauncherController::GetLaunchType( | 627 extensions::LaunchType ChromeLauncherController::GetLaunchType( |
| 626 ash::ShelfID id) { | 628 ash::ShelfID id) { |
| 627 const Extension* extension = GetExtensionForAppID(GetAppIDForShelfID(id)); | 629 const Extension* extension = GetExtensionForAppID(GetAppIDForShelfID(id)); |
| 628 | 630 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 } | 1275 } |
| 1274 } | 1276 } |
| 1275 } | 1277 } |
| 1276 } | 1278 } |
| 1277 | 1279 |
| 1278 ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItemWithType( | 1280 ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItemWithType( |
| 1279 const std::string& app_id, | 1281 const std::string& app_id, |
| 1280 int index, | 1282 int index, |
| 1281 ash::ShelfItemType shelf_item_type) { | 1283 ash::ShelfItemType shelf_item_type) { |
| 1282 AppShortcutLauncherItemController* controller = | 1284 AppShortcutLauncherItemController* controller = |
| 1283 new AppShortcutLauncherItemController(app_id, this); | 1285 AppShortcutLauncherItemController::Create(app_id, this); |
| 1284 ash::ShelfID shelf_id = InsertAppLauncherItem( | 1286 ash::ShelfID shelf_id = InsertAppLauncherItem( |
| 1285 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); | 1287 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); |
| 1286 return shelf_id; | 1288 return shelf_id; |
| 1287 } | 1289 } |
| 1288 | 1290 |
| 1289 LauncherItemController* ChromeLauncherController::GetLauncherItemController( | 1291 LauncherItemController* ChromeLauncherController::GetLauncherItemController( |
| 1290 const ash::ShelfID id) { | 1292 const ash::ShelfID id) { |
| 1291 if (!HasShelfIDToAppIDMapping(id)) | 1293 if (!HasShelfIDToAppIDMapping(id)) |
| 1292 return NULL; | 1294 return NULL; |
| 1293 return id_to_item_controller_map_[id]; | 1295 return id_to_item_controller_map_[id]; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 | 1876 |
| 1875 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( | 1877 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( |
| 1876 const std::string& app_id) { | 1878 const std::string& app_id) { |
| 1877 for (const auto& app_icon_loader : app_icon_loaders_) { | 1879 for (const auto& app_icon_loader : app_icon_loaders_) { |
| 1878 if (app_icon_loader->CanLoadImageForApp(app_id)) | 1880 if (app_icon_loader->CanLoadImageForApp(app_id)) |
| 1879 return app_icon_loader.get(); | 1881 return app_icon_loader.get(); |
| 1880 } | 1882 } |
| 1881 | 1883 |
| 1882 return nullptr; | 1884 return nullptr; |
| 1883 } | 1885 } |
| OLD | NEW |