| 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_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.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/launcher/launcher_util.h" | 10 #include "ash/launcher/launcher_util.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/app_mode/app_mode_utils.h" | 16 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
| 20 #include "chrome/browser/favicon/favicon_tab_helper.h" | 20 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 21 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 21 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" | 26 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" |
| 27 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 27 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 28 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 28 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 29 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 29 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 30 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 30 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 31 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" | 31 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" |
| 32 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" | 32 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (index != -1) | 240 if (index != -1) |
| 241 model_->RemoveItemAt(index); | 241 model_->RemoveItemAt(index); |
| 242 } | 242 } |
| 243 | 243 |
| 244 if (ash::Shell::HasInstance()) | 244 if (ash::Shell::HasInstance()) |
| 245 ash::Shell::GetInstance()->RemoveShellObserver(this); | 245 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 246 | 246 |
| 247 if (app_sync_ui_state_) | 247 if (app_sync_ui_state_) |
| 248 app_sync_ui_state_->RemoveObserver(this); | 248 app_sync_ui_state_->RemoveObserver(this); |
| 249 | 249 |
| 250 profile_->GetPrefs()->RemoveObserver(this); | 250 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void ChromeLauncherControllerPerApp::Init() { | 253 void ChromeLauncherControllerPerApp::Init() { |
| 254 UpdateAppLaunchersFromPref(); | 254 UpdateAppLaunchersFromPref(); |
| 255 | 255 |
| 256 // TODO(sky): update unit test so that this test isn't necessary. | 256 // TODO(sky): update unit test so that this test isn't necessary. |
| 257 if (ash::Shell::HasInstance()) { | 257 if (ash::Shell::HasInstance()) { |
| 258 SetShelfAutoHideBehaviorFromPrefs(); | 258 SetShelfAutoHideBehaviorFromPrefs(); |
| 259 SetShelfAlignmentFromPrefs(); | 259 SetShelfAlignmentFromPrefs(); |
| 260 PrefServiceSyncable* prefs = profile_->GetPrefs(); | 260 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 261 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || | 261 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || |
| 262 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> | 262 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> |
| 263 HasUserSetting()) { | 263 HasUserSetting()) { |
| 264 // This causes OnIsSyncingChanged to be called when the value of | 264 // This causes OnIsSyncingChanged to be called when the value of |
| 265 // PrefService::IsSyncing() changes. | 265 // PrefService::IsSyncing() changes. |
| 266 prefs->AddObserver(this); | 266 prefs->AddObserver(this); |
| 267 } | 267 } |
| 268 ash::Shell::GetInstance()->AddShellObserver(this); | 268 ash::Shell::GetInstance()->AddShellObserver(this); |
| 269 } | 269 } |
| 270 } | 270 } |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); | 957 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); |
| 958 | 958 |
| 959 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 959 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
| 960 // See comment in |kShelfAlignment| about why we have two prefs here. | 960 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 961 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); | 961 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); |
| 962 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); | 962 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); |
| 963 } | 963 } |
| 964 } | 964 } |
| 965 | 965 |
| 966 void ChromeLauncherControllerPerApp::OnIsSyncingChanged() { | 966 void ChromeLauncherControllerPerApp::OnIsSyncingChanged() { |
| 967 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 967 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 968 MaybePropagatePrefToLocal(prefs, |
| 968 prefs::kShelfAlignmentLocal, | 969 prefs::kShelfAlignmentLocal, |
| 969 prefs::kShelfAlignment); | 970 prefs::kShelfAlignment); |
| 970 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 971 MaybePropagatePrefToLocal(prefs, |
| 971 prefs::kShelfAutoHideBehaviorLocal, | 972 prefs::kShelfAutoHideBehaviorLocal, |
| 972 prefs::kShelfAutoHideBehavior); | 973 prefs::kShelfAutoHideBehavior); |
| 973 } | 974 } |
| 974 | 975 |
| 975 void ChromeLauncherControllerPerApp::OnAppSyncUIStatusChanged() { | 976 void ChromeLauncherControllerPerApp::OnAppSyncUIStatusChanged() { |
| 976 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 977 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
| 977 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); | 978 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); |
| 978 else | 979 else |
| 979 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); | 980 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); |
| 980 } | 981 } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 web_contents->GetTitle(), | 1383 web_contents->GetTitle(), |
| 1383 app_icon.IsEmpty() ? NULL : &app_icon, | 1384 app_icon.IsEmpty() ? NULL : &app_icon, |
| 1384 browser)); | 1385 browser)); |
| 1385 } | 1386 } |
| 1386 // If only windowed applications are open, we return an empty list to | 1387 // If only windowed applications are open, we return an empty list to |
| 1387 // enforce the creation of a new browser. | 1388 // enforce the creation of a new browser. |
| 1388 if (!found_tabbed_browser) | 1389 if (!found_tabbed_browser) |
| 1389 items.clear(); | 1390 items.clear(); |
| 1390 return items.Pass(); | 1391 return items.Pass(); |
| 1391 } | 1392 } |
| OLD | NEW |