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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
11 #include "ash/launcher/launcher.h" | 11 #include "ash/launcher/launcher.h" |
12 #include "ash/launcher/launcher_item_delegate_manager.h" | 12 #include "ash/launcher/launcher_item_delegate_manager.h" |
13 #include "ash/launcher/launcher_model.h" | |
14 #include "ash/multi_profile_uma.h" | 13 #include "ash/multi_profile_uma.h" |
15 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
16 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
| 16 #include "ash/shelf/shelf_model.h" |
17 #include "ash/shelf/shelf_model_util.h" | 17 #include "ash/shelf/shelf_model_util.h" |
18 #include "ash/shelf/shelf_widget.h" | 18 #include "ash/shelf/shelf_widget.h" |
19 #include "ash/shell.h" | 19 #include "ash/shell.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/prefs/scoped_user_pref_update.h" | 22 #include "base/prefs/scoped_user_pref_update.h" |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "chrome/browser/app_mode/app_mode_utils.h" | 26 #include "chrome/browser/app_mode/app_mode_utils.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 void ChromeLauncherControllerUserSwitchObserverChromeOS::AddUser( | 314 void ChromeLauncherControllerUserSwitchObserverChromeOS::AddUser( |
315 Profile* profile) { | 315 Profile* profile) { |
316 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | 316 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == |
317 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | 317 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) |
318 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); | 318 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); |
319 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); | 319 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); |
320 } | 320 } |
321 #endif | 321 #endif |
322 | 322 |
323 ChromeLauncherController::ChromeLauncherController( | 323 ChromeLauncherController::ChromeLauncherController(Profile* profile, |
324 Profile* profile, | 324 ash::ShelfModel* model) |
325 ash::LauncherModel* model) | |
326 : model_(model), | 325 : model_(model), |
327 item_delegate_manager_(NULL), | 326 item_delegate_manager_(NULL), |
328 profile_(profile), | 327 profile_(profile), |
329 app_sync_ui_state_(NULL), | 328 app_sync_ui_state_(NULL), |
330 ignore_persist_pinned_state_change_(false) { | 329 ignore_persist_pinned_state_change_(false) { |
331 if (!profile_) { | 330 if (!profile_) { |
332 // Use the original profile as on chromeos we may get a temporary off the | 331 // Use the original profile as on chromeos we may get a temporary off the |
333 // record profile. | 332 // record profile. |
334 profile_ = ProfileManager::GetDefaultProfile()->GetOriginalProfile(); | 333 profile_ = ProfileManager::GetDefaultProfile()->GetOriginalProfile(); |
335 | 334 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 if (instance_ == this) | 425 if (instance_ == this) |
427 instance_ = NULL; | 426 instance_ = NULL; |
428 | 427 |
429 // Get rid of the multi user window manager instance. | 428 // Get rid of the multi user window manager instance. |
430 chrome::MultiUserWindowManager::DeleteInstance(); | 429 chrome::MultiUserWindowManager::DeleteInstance(); |
431 } | 430 } |
432 | 431 |
433 // static | 432 // static |
434 ChromeLauncherController* ChromeLauncherController::CreateInstance( | 433 ChromeLauncherController* ChromeLauncherController::CreateInstance( |
435 Profile* profile, | 434 Profile* profile, |
436 ash::LauncherModel* model) { | 435 ash::ShelfModel* model) { |
437 // We do not check here for re-creation of the ChromeLauncherController since | 436 // We do not check here for re-creation of the ChromeLauncherController since |
438 // it appears that it might be intentional that the ChromeLauncherController | 437 // it appears that it might be intentional that the ChromeLauncherController |
439 // can be re-created. | 438 // can be re-created. |
440 instance_ = new ChromeLauncherController(profile, model); | 439 instance_ = new ChromeLauncherController(profile, model); |
441 return instance_; | 440 return instance_; |
442 } | 441 } |
443 | 442 |
444 void ChromeLauncherController::Init() { | 443 void ChromeLauncherController::Init() { |
445 CreateBrowserShortcutLauncherItem(); | 444 CreateBrowserShortcutLauncherItem(); |
446 UpdateAppLaunchersFromPref(); | 445 UpdateAppLaunchersFromPref(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 updater->Append(app_value); | 873 updater->Append(app_value); |
875 } | 874 } |
876 } | 875 } |
877 } | 876 } |
878 pref_change_registrar_.Add( | 877 pref_change_registrar_.Add( |
879 prefs::kPinnedLauncherApps, | 878 prefs::kPinnedLauncherApps, |
880 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, | 879 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, |
881 base::Unretained(this))); | 880 base::Unretained(this))); |
882 } | 881 } |
883 | 882 |
884 ash::LauncherModel* ChromeLauncherController::model() { | 883 ash::ShelfModel* ChromeLauncherController::model() { |
885 return model_; | 884 return model_; |
886 } | 885 } |
887 | 886 |
888 Profile* ChromeLauncherController::profile() { | 887 Profile* ChromeLauncherController::profile() { |
889 return profile_; | 888 return profile_; |
890 } | 889 } |
891 | 890 |
892 ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior( | 891 ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior( |
893 aura::Window* root_window) const { | 892 aura::Window* root_window) const { |
894 // Don't show the shelf in app mode. | 893 // Don't show the shelf in app mode. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 MaybePropagatePrefToLocal(prefs, | 1247 MaybePropagatePrefToLocal(prefs, |
1249 prefs::kShelfAlignmentLocal, | 1248 prefs::kShelfAlignmentLocal, |
1250 prefs::kShelfAlignment); | 1249 prefs::kShelfAlignment); |
1251 MaybePropagatePrefToLocal(prefs, | 1250 MaybePropagatePrefToLocal(prefs, |
1252 prefs::kShelfAutoHideBehaviorLocal, | 1251 prefs::kShelfAutoHideBehaviorLocal, |
1253 prefs::kShelfAutoHideBehavior); | 1252 prefs::kShelfAutoHideBehavior); |
1254 } | 1253 } |
1255 | 1254 |
1256 void ChromeLauncherController::OnAppSyncUIStatusChanged() { | 1255 void ChromeLauncherController::OnAppSyncUIStatusChanged() { |
1257 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 1256 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
1258 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); | 1257 model_->SetStatus(ash::ShelfModel::STATUS_LOADING); |
1259 else | 1258 else |
1260 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); | 1259 model_->SetStatus(ash::ShelfModel::STATUS_NORMAL); |
1261 } | 1260 } |
1262 | 1261 |
1263 void ChromeLauncherController::ExtensionEnableFlowFinished() { | 1262 void ChromeLauncherController::ExtensionEnableFlowFinished() { |
1264 LaunchApp(extension_enable_flow_->extension_id(), | 1263 LaunchApp(extension_enable_flow_->extension_id(), |
1265 ash::LAUNCH_FROM_UNKNOWN, | 1264 ash::LAUNCH_FROM_UNKNOWN, |
1266 ui::EF_NONE); | 1265 ui::EF_NONE); |
1267 extension_enable_flow_.reset(); | 1266 extension_enable_flow_.reset(); |
1268 } | 1267 } |
1269 | 1268 |
1270 void ChromeLauncherController::ExtensionEnableFlowAborted(bool user_initiated) { | 1269 void ChromeLauncherController::ExtensionEnableFlowAborted(bool user_initiated) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 | 1461 |
1463 int ChromeLauncherController::PinRunningAppInternal( | 1462 int ChromeLauncherController::PinRunningAppInternal( |
1464 int index, | 1463 int index, |
1465 ash::LauncherID launcher_id) { | 1464 ash::LauncherID launcher_id) { |
1466 int running_index = model_->ItemIndexByID(launcher_id); | 1465 int running_index = model_->ItemIndexByID(launcher_id); |
1467 ash::LauncherItem item = model_->items()[running_index]; | 1466 ash::LauncherItem item = model_->items()[running_index]; |
1468 DCHECK(item.type == ash::TYPE_WINDOWED_APP || | 1467 DCHECK(item.type == ash::TYPE_WINDOWED_APP || |
1469 item.type == ash::TYPE_PLATFORM_APP); | 1468 item.type == ash::TYPE_PLATFORM_APP); |
1470 item.type = ash::TYPE_APP_SHORTCUT; | 1469 item.type = ash::TYPE_APP_SHORTCUT; |
1471 model_->Set(running_index, item); | 1470 model_->Set(running_index, item); |
1472 // The |LauncherModel|'s weight system might reposition the item to a | 1471 // The |ShelfModel|'s weight system might reposition the item to a |
1473 // new index, so we get the index again. | 1472 // new index, so we get the index again. |
1474 running_index = model_->ItemIndexByID(launcher_id); | 1473 running_index = model_->ItemIndexByID(launcher_id); |
1475 if (running_index < index) | 1474 if (running_index < index) |
1476 --index; | 1475 --index; |
1477 if (running_index != index) | 1476 if (running_index != index) |
1478 model_->Move(running_index, index); | 1477 model_->Move(running_index, index); |
1479 return index; | 1478 return index; |
1480 } | 1479 } |
1481 | 1480 |
1482 void ChromeLauncherController::UnpinRunningAppInternal(int index) { | 1481 void ChromeLauncherController::UnpinRunningAppInternal(int index) { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 } | 2015 } |
2017 | 2016 |
2018 void ChromeLauncherController::ReleaseProfile() { | 2017 void ChromeLauncherController::ReleaseProfile() { |
2019 if (app_sync_ui_state_) | 2018 if (app_sync_ui_state_) |
2020 app_sync_ui_state_->RemoveObserver(this); | 2019 app_sync_ui_state_->RemoveObserver(this); |
2021 | 2020 |
2022 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 2021 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
2023 | 2022 |
2024 pref_change_registrar_.RemoveAll(); | 2023 pref_change_registrar_.RemoveAll(); |
2025 } | 2024 } |
OLD | NEW |