OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_per_browser.
h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.
h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/app_mode/app_mode_utils.h" | 15 #include "chrome/browser/app_mode/app_mode_utils.h" |
16 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service_syncable.h" |
21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" | 24 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" |
25 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 25 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
28 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" | 28 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" |
29 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 29 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
30 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 30 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 i->second->OnRemoved(); | 268 i->second->OnRemoved(); |
269 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); | 269 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); |
270 } | 270 } |
271 | 271 |
272 if (ash::Shell::HasInstance()) | 272 if (ash::Shell::HasInstance()) |
273 ash::Shell::GetInstance()->RemoveShellObserver(this); | 273 ash::Shell::GetInstance()->RemoveShellObserver(this); |
274 | 274 |
275 if (app_sync_ui_state_) | 275 if (app_sync_ui_state_) |
276 app_sync_ui_state_->RemoveObserver(this); | 276 app_sync_ui_state_->RemoveObserver(this); |
277 | 277 |
278 profile_->GetPrefs()->RemoveObserver(this); | 278 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
279 } | 279 } |
280 | 280 |
281 void ChromeLauncherControllerPerBrowser::Init() { | 281 void ChromeLauncherControllerPerBrowser::Init() { |
282 UpdateAppLaunchersFromPref(); | 282 UpdateAppLaunchersFromPref(); |
283 | 283 |
284 // TODO(sky): update unit test so that this test isn't necessary. | 284 // TODO(sky): update unit test so that this test isn't necessary. |
285 if (ash::Shell::HasInstance()) { | 285 if (ash::Shell::HasInstance()) { |
286 SetShelfAutoHideBehaviorFromPrefs(); | 286 SetShelfAutoHideBehaviorFromPrefs(); |
287 SetShelfAlignmentFromPrefs(); | 287 SetShelfAlignmentFromPrefs(); |
288 PrefServiceSyncable* prefs = profile_->GetPrefs(); | 288 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
289 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || | 289 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || |
290 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> | 290 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> |
291 HasUserSetting()) { | 291 HasUserSetting()) { |
292 // This causes OnIsSyncingChanged to be called when the value of | 292 // This causes OnIsSyncingChanged to be called when the value of |
293 // PrefService::IsSyncing() changes. | 293 // PrefService::IsSyncing() changes. |
294 prefs->AddObserver(this); | 294 prefs->AddObserver(this); |
295 } | 295 } |
296 ash::Shell::GetInstance()->AddShellObserver(this); | 296 ash::Shell::GetInstance()->AddShellObserver(this); |
297 } | 297 } |
298 } | 298 } |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); | 938 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); |
939 | 939 |
940 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 940 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
941 // See comment in |kShelfAlignment| about why we have two prefs here. | 941 // See comment in |kShelfAlignment| about why we have two prefs here. |
942 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); | 942 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); |
943 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); | 943 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); |
944 } | 944 } |
945 } | 945 } |
946 | 946 |
947 void ChromeLauncherControllerPerBrowser::OnIsSyncingChanged() { | 947 void ChromeLauncherControllerPerBrowser::OnIsSyncingChanged() { |
948 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 948 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 949 MaybePropagatePrefToLocal(prefs, |
949 prefs::kShelfAlignmentLocal, | 950 prefs::kShelfAlignmentLocal, |
950 prefs::kShelfAlignment); | 951 prefs::kShelfAlignment); |
951 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 952 MaybePropagatePrefToLocal(prefs, |
952 prefs::kShelfAutoHideBehaviorLocal, | 953 prefs::kShelfAutoHideBehaviorLocal, |
953 prefs::kShelfAutoHideBehavior); | 954 prefs::kShelfAutoHideBehavior); |
954 } | 955 } |
955 | 956 |
956 void ChromeLauncherControllerPerBrowser::OnAppSyncUIStatusChanged() { | 957 void ChromeLauncherControllerPerBrowser::OnAppSyncUIStatusChanged() { |
957 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 958 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
958 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); | 959 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); |
959 else | 960 else |
960 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); | 961 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); |
961 } | 962 } |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( | 1264 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( |
1264 ash::AppIconLoader* loader) { | 1265 ash::AppIconLoader* loader) { |
1265 app_icon_loader_.reset(loader); | 1266 app_icon_loader_.reset(loader); |
1266 } | 1267 } |
1267 | 1268 |
1268 const std::string& | 1269 const std::string& |
1269 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( | 1270 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( |
1270 ash::LauncherID id) { | 1271 ash::LauncherID id) { |
1271 return id_to_item_controller_map_[id]->app_id(); | 1272 return id_to_item_controller_map_[id]->app_id(); |
1272 } | 1273 } |
OLD | NEW |