Chromium Code Reviews| 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/string_number_conversions.h" | 14 #include "base/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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 if (index != -1) | 213 if (index != -1) |
| 214 model_->RemoveItemAt(index); | 214 model_->RemoveItemAt(index); |
| 215 } | 215 } |
| 216 | 216 |
| 217 if (ash::Shell::HasInstance()) | 217 if (ash::Shell::HasInstance()) |
| 218 ash::Shell::GetInstance()->RemoveShellObserver(this); | 218 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 219 | 219 |
| 220 if (app_sync_ui_state_) | 220 if (app_sync_ui_state_) |
| 221 app_sync_ui_state_->RemoveObserver(this); | 221 app_sync_ui_state_->RemoveObserver(this); |
| 222 | 222 |
| 223 profile_->GetPrefs()->RemoveObserver(this); | 223 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
Oh, this is the OnIsSyncingChanged stuff. I'll hav
Jói
2013/02/07 14:52:32
OK.
Mattias Nissler (ping if slow)
2013/02/08 14:49:18
FWIW, I've looked into this some more. I've found
| |
| 224 } | 224 } |
| 225 | 225 |
| 226 void ChromeLauncherControllerPerApp::Init() { | 226 void ChromeLauncherControllerPerApp::Init() { |
| 227 UpdateAppLaunchersFromPref(); | 227 UpdateAppLaunchersFromPref(); |
| 228 | 228 |
| 229 // TODO(sky): update unit test so that this test isn't necessary. | 229 // TODO(sky): update unit test so that this test isn't necessary. |
| 230 if (ash::Shell::HasInstance()) { | 230 if (ash::Shell::HasInstance()) { |
| 231 SetShelfAutoHideBehaviorFromPrefs(); | 231 SetShelfAutoHideBehaviorFromPrefs(); |
| 232 SetShelfAlignmentFromPrefs(); | 232 SetShelfAlignmentFromPrefs(); |
| 233 PrefServiceSyncable* prefs = profile_->GetPrefs(); | 233 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 234 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || | 234 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || |
| 235 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> | 235 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)-> |
| 236 HasUserSetting()) { | 236 HasUserSetting()) { |
| 237 // This causes OnIsSyncingChanged to be called when the value of | 237 // This causes OnIsSyncingChanged to be called when the value of |
| 238 // PrefService::IsSyncing() changes. | 238 // PrefService::IsSyncing() changes. |
| 239 prefs->AddObserver(this); | 239 prefs->AddObserver(this); |
| 240 } | 240 } |
| 241 ash::Shell::GetInstance()->AddShellObserver(this); | 241 ash::Shell::GetInstance()->AddShellObserver(this); |
| 242 } | 242 } |
| 243 } | 243 } |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); | 930 profile_->GetPrefs(), root_window, prefs::kShelfAlignment, pref_value); |
| 931 | 931 |
| 932 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 932 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
| 933 // See comment in |kShelfAlignment| about why we have two prefs here. | 933 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 934 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); | 934 profile_->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, pref_value); |
| 935 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); | 935 profile_->GetPrefs()->SetString(prefs::kShelfAlignment, pref_value); |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 void ChromeLauncherControllerPerApp::OnIsSyncingChanged() { | 939 void ChromeLauncherControllerPerApp::OnIsSyncingChanged() { |
| 940 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 940 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| 941 MaybePropagatePrefToLocal(prefs, | |
| 941 prefs::kShelfAlignmentLocal, | 942 prefs::kShelfAlignmentLocal, |
| 942 prefs::kShelfAlignment); | 943 prefs::kShelfAlignment); |
| 943 MaybePropagatePrefToLocal(profile_->GetPrefs(), | 944 MaybePropagatePrefToLocal(prefs, |
| 944 prefs::kShelfAutoHideBehaviorLocal, | 945 prefs::kShelfAutoHideBehaviorLocal, |
| 945 prefs::kShelfAutoHideBehavior); | 946 prefs::kShelfAutoHideBehavior); |
| 946 } | 947 } |
| 947 | 948 |
| 948 void ChromeLauncherControllerPerApp::OnAppSyncUIStatusChanged() { | 949 void ChromeLauncherControllerPerApp::OnAppSyncUIStatusChanged() { |
| 949 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) | 950 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) |
| 950 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); | 951 model_->SetStatus(ash::LauncherModel::STATUS_LOADING); |
| 951 else | 952 else |
| 952 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); | 953 model_->SetStatus(ash::LauncherModel::STATUS_NORMAL); |
| 953 } | 954 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1339 WebContents* web_contents = | 1340 WebContents* web_contents = |
| 1340 tab_strip->GetWebContentsAt(tab_strip->active_index()); | 1341 tab_strip->GetWebContentsAt(tab_strip->active_index()); |
| 1341 gfx::Image app_icon = GetAppListIcon(web_contents); | 1342 gfx::Image app_icon = GetAppListIcon(web_contents); |
| 1342 items.push_back(new ChromeLauncherAppMenuItemBrowser( | 1343 items.push_back(new ChromeLauncherAppMenuItemBrowser( |
| 1343 web_contents->GetTitle(), | 1344 web_contents->GetTitle(), |
| 1344 app_icon.IsEmpty() ? NULL : &app_icon, | 1345 app_icon.IsEmpty() ? NULL : &app_icon, |
| 1345 browser)); | 1346 browser)); |
| 1346 } | 1347 } |
| 1347 return items.Pass(); | 1348 return items.Pass(); |
| 1348 } | 1349 } |
| OLD | NEW |