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 14 matching lines...) Expand all Loading... |
25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.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/prefs/incognito_mode_prefs.h" | 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 35 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
37 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 38 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
38 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 39 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
39 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
40 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 41 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
41 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 42 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
42 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 43 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
43 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
44 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 45 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
(...skipping 23 matching lines...) Expand all Loading... |
68 #include "chrome/common/chrome_switches.h" | 69 #include "chrome/common/chrome_switches.h" |
69 #include "chrome/common/pref_names.h" | 70 #include "chrome/common/pref_names.h" |
70 #include "chrome/common/url_constants.h" | 71 #include "chrome/common/url_constants.h" |
71 #include "chrome/grit/chromium_strings.h" | 72 #include "chrome/grit/chromium_strings.h" |
72 #include "chrome/grit/generated_resources.h" | 73 #include "chrome/grit/generated_resources.h" |
73 #include "chrome/grit/theme_resources.h" | 74 #include "chrome/grit/theme_resources.h" |
74 #include "components/favicon/content/content_favicon_driver.h" | 75 #include "components/favicon/content/content_favicon_driver.h" |
75 #include "components/prefs/scoped_user_pref_update.h" | 76 #include "components/prefs/scoped_user_pref_update.h" |
76 #include "components/signin/core/account_id/account_id.h" | 77 #include "components/signin/core/account_id/account_id.h" |
77 #include "components/strings/grit/components_strings.h" | 78 #include "components/strings/grit/components_strings.h" |
| 79 #include "components/sync_preferences/pref_service_syncable.h" |
78 #include "components/user_manager/user_manager.h" | 80 #include "components/user_manager/user_manager.h" |
79 #include "content/public/browser/navigation_entry.h" | 81 #include "content/public/browser/navigation_entry.h" |
80 #include "content/public/browser/web_contents.h" | 82 #include "content/public/browser/web_contents.h" |
81 #include "extensions/common/extension.h" | 83 #include "extensions/common/extension.h" |
82 #include "ui/aura/window.h" | 84 #include "ui/aura/window.h" |
83 #include "ui/aura/window_event_dispatcher.h" | 85 #include "ui/aura/window_event_dispatcher.h" |
84 #include "ui/base/l10n/l10n_util.h" | 86 #include "ui/base/l10n/l10n_util.h" |
85 #include "ui/base/resource/resource_bundle.h" | 87 #include "ui/base/resource/resource_bundle.h" |
86 #include "ui/base/window_open_disposition.h" | 88 #include "ui/base/window_open_disposition.h" |
87 #include "ui/keyboard/keyboard_util.h" | 89 #include "ui/keyboard/keyboard_util.h" |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 if (arc::ArcSessionManager::IsAllowedForProfile(profile())) { | 821 if (arc::ArcSessionManager::IsAllowedForProfile(profile())) { |
820 std::unique_ptr<LauncherAppUpdater> arc_app_updater( | 822 std::unique_ptr<LauncherAppUpdater> arc_app_updater( |
821 new LauncherArcAppUpdater(this, profile())); | 823 new LauncherArcAppUpdater(this, profile())); |
822 app_updaters_.push_back(std::move(arc_app_updater)); | 824 app_updaters_.push_back(std::move(arc_app_updater)); |
823 } | 825 } |
824 | 826 |
825 app_list::AppListSyncableService* app_service = | 827 app_list::AppListSyncableService* app_service = |
826 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 828 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
827 if (app_service) | 829 if (app_service) |
828 app_service->AddObserverAndStart(this); | 830 app_service->AddObserverAndStart(this); |
| 831 |
| 832 PrefServiceSyncableFromProfile(profile())->AddObserver(this); |
829 } | 833 } |
830 | 834 |
831 /////////////////////////////////////////////////////////////////////////////// | 835 /////////////////////////////////////////////////////////////////////////////// |
832 // ash::ShelfDelegate: | 836 // ash::ShelfDelegate: |
833 | 837 |
834 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 838 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
835 const std::string& app_id) { | 839 const std::string& app_id) { |
836 // Get shelf id for app_id and empty launch_id. | 840 // Get shelf id for app_id and empty launch_id. |
837 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); | 841 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); |
838 } | 842 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 | 1111 |
1108 ash::launcher::SetPinPosition(profile(), | 1112 ash::launcher::SetPinPosition(profile(), |
1109 ash::launcher::AppLauncherId(app_id, launch_id), | 1113 ash::launcher::AppLauncherId(app_id, launch_id), |
1110 app_launcher_id_before, app_launcher_ids_after); | 1114 app_launcher_id_before, app_launcher_ids_after); |
1111 } | 1115 } |
1112 | 1116 |
1113 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1117 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
1114 UpdateAppLaunchersFromPref(); | 1118 UpdateAppLaunchersFromPref(); |
1115 } | 1119 } |
1116 | 1120 |
| 1121 void ChromeLauncherControllerImpl::OnIsSyncingChanged() { |
| 1122 UpdateAppLaunchersFromPref(); |
| 1123 } |
| 1124 |
1117 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1125 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
1118 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1126 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1119 FROM_HERE, | 1127 FROM_HERE, |
1120 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1128 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
1121 weak_ptr_factory_.GetWeakPtr())); | 1129 weak_ptr_factory_.GetWeakPtr())); |
1122 } | 1130 } |
1123 | 1131 |
1124 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { | 1132 void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
1125 // There are various functions which will trigger a |SyncPinPosition| call | 1133 // There are various functions which will trigger a |SyncPinPosition| call |
1126 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu | 1134 // like a direct call to |DoPinAppWithID|, or an indirect call to the menu |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 app_updaters_.clear(); | 1390 app_updaters_.clear(); |
1383 | 1391 |
1384 prefs_observer_.reset(); | 1392 prefs_observer_.reset(); |
1385 | 1393 |
1386 pref_change_registrar_.RemoveAll(); | 1394 pref_change_registrar_.RemoveAll(); |
1387 | 1395 |
1388 app_list::AppListSyncableService* app_service = | 1396 app_list::AppListSyncableService* app_service = |
1389 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 1397 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
1390 if (app_service) | 1398 if (app_service) |
1391 app_service->RemoveObserver(this); | 1399 app_service->RemoveObserver(this); |
| 1400 |
| 1401 PrefServiceSyncableFromProfile(profile())->RemoveObserver(this); |
1392 } | 1402 } |
1393 | 1403 |
1394 /////////////////////////////////////////////////////////////////////////////// | 1404 /////////////////////////////////////////////////////////////////////////////// |
1395 // ash::ShelfModelObserver: | 1405 // ash::ShelfModelObserver: |
1396 | 1406 |
1397 void ChromeLauncherControllerImpl::ShelfItemAdded(int index) {} | 1407 void ChromeLauncherControllerImpl::ShelfItemAdded(int index) {} |
1398 | 1408 |
1399 void ChromeLauncherControllerImpl::ShelfItemRemoved(int index, | 1409 void ChromeLauncherControllerImpl::ShelfItemRemoved(int index, |
1400 ash::ShelfID id) { | 1410 ash::ShelfID id) { |
1401 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we | 1411 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 LauncherItemController* controller = GetLauncherItemController(item.id); | 1490 LauncherItemController* controller = GetLauncherItemController(item.id); |
1481 if (!controller || controller->image_set_by_controller()) | 1491 if (!controller || controller->image_set_by_controller()) |
1482 continue; | 1492 continue; |
1483 item.image = image; | 1493 item.image = image; |
1484 if (arc_deferred_launcher_) | 1494 if (arc_deferred_launcher_) |
1485 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1495 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1486 model_->Set(index, item); | 1496 model_->Set(index, item); |
1487 // It's possible we're waiting on more than one item, so don't break. | 1497 // It's possible we're waiting on more than one item, so don't break. |
1488 } | 1498 } |
1489 } | 1499 } |
OLD | NEW |