| 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/strings/string_number_conversions.h" | 13 #include "base/strings/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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 i->second->OnRemoved(); | 296 i->second->OnRemoved(); |
| 297 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); | 297 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 if (ash::Shell::HasInstance()) | 300 if (ash::Shell::HasInstance()) |
| 301 ash::Shell::GetInstance()->RemoveShellObserver(this); | 301 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 302 | 302 |
| 303 if (app_sync_ui_state_) | 303 if (app_sync_ui_state_) |
| 304 app_sync_ui_state_->RemoveObserver(this); | 304 app_sync_ui_state_->RemoveObserver(this); |
| 305 | 305 |
| 306 profile_->GetPrefs()->RemoveObserver(this); | 306 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void ChromeLauncherControllerPerBrowser::Init() { | 309 void ChromeLauncherControllerPerBrowser::Init() { |
| 310 UpdateAppLaunchersFromPref(); | 310 UpdateAppLaunchersFromPref(); |
| 311 | 311 |
| 312 // TODO(sky): update unit test so that this test isn't necessary. | 312 // TODO(sky): update unit test so that this test isn't necessary. |
| 313 if (ash::Shell::HasInstance()) { | 313 if (ash::Shell::HasInstance()) { |
| 314 SetShelfAutoHideBehaviorFromPrefs(); | 314 SetShelfAutoHideBehaviorFromPrefs(); |
| 315 SetShelfAlignmentFromPrefs(); | 315 SetShelfAlignmentFromPrefs(); |
| 316 PrefServiceSyncable* prefs = profile_->GetPrefs(); | 316 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 317 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || | 317 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || |
| 318 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> | 318 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> |
| 319 HasUserSetting()) { | 319 HasUserSetting()) { |
| 320 // This causes OnIsSyncingChanged to be called when the value of | 320 // This causes OnIsSyncingChanged to be called when the value of |
| 321 // PrefService::IsSyncing() changes. | 321 // PrefService::IsSyncing() changes. |
| 322 prefs->AddObserver(this); | 322 prefs->AddObserver(this); |
| 323 } | 323 } |
| 324 ash::Shell::GetInstance()->AddShellObserver(this); | 324 ash::Shell::GetInstance()->AddShellObserver(this); |
| 325 } | 325 } |
| 326 } | 326 } |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); | 966 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); |
| 967 | 967 |
| 968 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 968 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
| 969 // See comment in |kShelfAlignment| about why we have two prefs here. | 969 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 970 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); | 970 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); |
| 971 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); | 971 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); |
| 972 } | 972 } |
| 973 } | 973 } |
| 974 | 974 |
| 975 void ChromeLauncherControllerPerBrowser::OnIsSyncingChanged() { | 975 void ChromeLauncherControllerPerBrowser::OnIsSyncingChanged() { |
| 976 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 976 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 977 MaybePropagatePrefToLocal(prefs, |
| 977 prefs::kShelfAlignmentLocal, | 978 prefs::kShelfAlignmentLocal, |
| 978 prefs::kShelfAlignment); | 979 prefs::kShelfAlignment); |
| 979 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 980 MaybePropagatePrefToLocal(prefs, |
| 980 prefs::kShelfAutoHideBehaviorLocal, | 981 prefs::kShelfAutoHideBehaviorLocal, |
| 981 prefs::kShelfAutoHideBehavior); | 982 prefs::kShelfAutoHideBehavior); |
| 982 } | 983 } |
| 983 | 984 |
| 984 void ChromeLauncherControllerPerBrowser::OnAppSyncUIStatusChanged() { | 985 void ChromeLauncherControllerPerBrowser::OnAppSyncUIStatusChanged() { |
| 985 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 986 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
| 986 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); | 987 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); |
| 987 else | 988 else |
| 988 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); | 989 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); |
| 989 } | 990 } |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( | 1301 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( |
| 1301 ash::AppIconLoader* loader) { | 1302 ash::AppIconLoader* loader) { |
| 1302 app_icon_loader_.reset(loader); | 1303 app_icon_loader_.reset(loader); |
| 1303 } | 1304 } |
| 1304 | 1305 |
| 1305 const std::string& | 1306 const std::string& |
| 1306 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( | 1307 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( |
| 1307 ash::LauncherID id) { | 1308 ash::LauncherID id) { |
| 1308 return id_to_item_controller_map_[id]->app_id(); | 1309 return id_to_item_controller_map_[id]->app_id(); |
| 1309 } | 1310 } |
| OLD | NEW |