| 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_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/values.h" | 27 #include "base/values.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
| 31 #include "chrome/browser/chromeos/extensions/gfx_utils.h" | 31 #include "chrome/browser/chromeos/extensions/gfx_utils.h" |
| 32 #include "chrome/browser/defaults.h" | 32 #include "chrome/browser/defaults.h" |
| 33 #include "chrome/browser/extensions/extension_util.h" | 33 #include "chrome/browser/extensions/extension_util.h" |
| 34 #include "chrome/browser/extensions/launch_util.h" | 34 #include "chrome/browser/extensions/launch_util.h" |
| 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.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/app_list_syncable_service_factory.h" | 39 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 39 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 40 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 41 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 41 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 42 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 42 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 43 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 43 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 45 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 46 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 69 #include "chrome/common/chrome_switches.h" | 70 #include "chrome/common/chrome_switches.h" |
| 70 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 71 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 71 #include "chrome/common/pref_names.h" | 72 #include "chrome/common/pref_names.h" |
| 72 #include "chrome/common/url_constants.h" | 73 #include "chrome/common/url_constants.h" |
| 73 #include "chrome/grit/generated_resources.h" | 74 #include "chrome/grit/generated_resources.h" |
| 74 #include "chrome/grit/theme_resources.h" | 75 #include "chrome/grit/theme_resources.h" |
| 75 #include "components/favicon/content/content_favicon_driver.h" | 76 #include "components/favicon/content/content_favicon_driver.h" |
| 76 #include "components/prefs/scoped_user_pref_update.h" | 77 #include "components/prefs/scoped_user_pref_update.h" |
| 77 #include "components/signin/core/account_id/account_id.h" | 78 #include "components/signin/core/account_id/account_id.h" |
| 78 #include "components/strings/grit/components_strings.h" | 79 #include "components/strings/grit/components_strings.h" |
| 80 #include "components/sync_preferences/pref_service_syncable.h" |
| 79 #include "components/user_manager/user_manager.h" | 81 #include "components/user_manager/user_manager.h" |
| 80 #include "content/public/browser/navigation_entry.h" | 82 #include "content/public/browser/navigation_entry.h" |
| 81 #include "content/public/browser/web_contents.h" | 83 #include "content/public/browser/web_contents.h" |
| 82 #include "extensions/browser/extension_prefs.h" | 84 #include "extensions/browser/extension_prefs.h" |
| 83 #include "extensions/browser/extension_system.h" | 85 #include "extensions/browser/extension_system.h" |
| 84 #include "extensions/browser/extension_util.h" | 86 #include "extensions/browser/extension_util.h" |
| 85 #include "extensions/common/constants.h" | 87 #include "extensions/common/constants.h" |
| 86 #include "extensions/common/extension.h" | 88 #include "extensions/common/extension.h" |
| 87 #include "extensions/common/extension_resource.h" | 89 #include "extensions/common/extension_resource.h" |
| 88 #include "extensions/common/manifest_handlers/icons_handler.h" | 90 #include "extensions/common/manifest_handlers/icons_handler.h" |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 if (arc::ArcAuthService::IsAllowedForProfile(profile())) { | 888 if (arc::ArcAuthService::IsAllowedForProfile(profile())) { |
| 887 std::unique_ptr<LauncherAppUpdater> arc_app_updater( | 889 std::unique_ptr<LauncherAppUpdater> arc_app_updater( |
| 888 new LauncherArcAppUpdater(this, profile())); | 890 new LauncherArcAppUpdater(this, profile())); |
| 889 app_updaters_.push_back(std::move(arc_app_updater)); | 891 app_updaters_.push_back(std::move(arc_app_updater)); |
| 890 } | 892 } |
| 891 | 893 |
| 892 app_list::AppListSyncableService* app_service = | 894 app_list::AppListSyncableService* app_service = |
| 893 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 895 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 894 if (app_service) | 896 if (app_service) |
| 895 app_service->AddObserverAndStart(this); | 897 app_service->AddObserverAndStart(this); |
| 898 |
| 899 PrefServiceSyncableFromProfile(profile())->AddObserver(this); |
| 896 } | 900 } |
| 897 | 901 |
| 898 /////////////////////////////////////////////////////////////////////////////// | 902 /////////////////////////////////////////////////////////////////////////////// |
| 899 // ash::ShelfDelegate: | 903 // ash::ShelfDelegate: |
| 900 | 904 |
| 901 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 905 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
| 902 const std::string& app_id) { | 906 const std::string& app_id) { |
| 903 // Get shelf id for app_id and empty launch_id. | 907 // Get shelf id for app_id and empty launch_id. |
| 904 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); | 908 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); |
| 905 } | 909 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 | 1197 |
| 1194 ash::launcher::SetPinPosition(profile(), | 1198 ash::launcher::SetPinPosition(profile(), |
| 1195 ash::launcher::AppLauncherId(app_id, launch_id), | 1199 ash::launcher::AppLauncherId(app_id, launch_id), |
| 1196 app_launcher_id_before, app_launcher_ids_after); | 1200 app_launcher_id_before, app_launcher_ids_after); |
| 1197 } | 1201 } |
| 1198 | 1202 |
| 1199 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
| 1200 UpdateAppLaunchersFromPref(); | 1204 UpdateAppLaunchersFromPref(); |
| 1201 } | 1205 } |
| 1202 | 1206 |
| 1207 void ChromeLauncherControllerImpl::OnIsSyncingChanged() { |
| 1208 UpdateAppLaunchersFromPref(); |
| 1209 } |
| 1210 |
| 1203 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1211 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
| 1204 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1212 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1205 FROM_HERE, | 1213 FROM_HERE, |
| 1206 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1214 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
| 1207 weak_ptr_factory_.GetWeakPtr())); | 1215 weak_ptr_factory_.GetWeakPtr())); |
| 1208 } | 1216 } |
| 1209 | 1217 |
| 1210 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { | 1218 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
| 1211 // There are various functions which will trigger a |SyncPinPosition| call | 1219 // There are various functions which will trigger a |SyncPinPosition| call |
| 1212 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu | 1220 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 app_updaters_.clear(); | 1469 app_updaters_.clear(); |
| 1462 | 1470 |
| 1463 prefs_observer_.reset(); | 1471 prefs_observer_.reset(); |
| 1464 | 1472 |
| 1465 pref_change_registrar_.RemoveAll(); | 1473 pref_change_registrar_.RemoveAll(); |
| 1466 | 1474 |
| 1467 app_list::AppListSyncableService* app_service = | 1475 app_list::AppListSyncableService* app_service = |
| 1468 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 1476 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 1469 if (app_service) | 1477 if (app_service) |
| 1470 app_service->RemoveObserver(this); | 1478 app_service->RemoveObserver(this); |
| 1479 |
| 1480 PrefServiceSyncableFromProfile(profile())->RemoveObserver(this); |
| 1471 } | 1481 } |
| 1472 | 1482 |
| 1473 /////////////////////////////////////////////////////////////////////////////// | 1483 /////////////////////////////////////////////////////////////////////////////// |
| 1474 // ash::ShelfModelObserver: | 1484 // ash::ShelfModelObserver: |
| 1475 | 1485 |
| 1476 void ChromeLauncherControllerImpl::ShelfItemAdded(int index) {} | 1486 void ChromeLauncherControllerImpl::ShelfItemAdded(int index) {} |
| 1477 | 1487 |
| 1478 void ChromeLauncherControllerImpl::ShelfItemRemoved(int index, | 1488 void ChromeLauncherControllerImpl::ShelfItemRemoved(int index, |
| 1479 ash::ShelfID id) { | 1489 ash::ShelfID id) { |
| 1480 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we | 1490 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 LauncherItemController* controller = GetLauncherItemController(item.id); | 1560 LauncherItemController* controller = GetLauncherItemController(item.id); |
| 1551 if (!controller || controller->image_set_by_controller()) | 1561 if (!controller || controller->image_set_by_controller()) |
| 1552 continue; | 1562 continue; |
| 1553 item.image = image; | 1563 item.image = image; |
| 1554 if (arc_deferred_launcher_) | 1564 if (arc_deferred_launcher_) |
| 1555 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1565 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1556 model_->Set(index, item); | 1566 model_->Set(index, item); |
| 1557 // It's possible we're waiting on more than one item, so don't break. | 1567 // It's possible we're waiting on more than one item, so don't break. |
| 1558 } | 1568 } |
| 1559 } | 1569 } |
| OLD | NEW |