Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 448493002: Avoiding double resize of maximized windows upon user switch due to showing and hiding of the shelf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (local_pref->IsRecommended() || !has_per_display_prefs) 190 if (local_pref->IsRecommended() || !has_per_display_prefs)
191 return value; 191 return value;
192 192
193 const base::Value* default_value = 193 const base::Value* default_value =
194 pref_service->GetDefaultPrefValue(local_path); 194 pref_service->GetDefaultPrefValue(local_path);
195 std::string default_string; 195 std::string default_string;
196 default_value->GetAsString(&default_string); 196 default_value->GetAsString(&default_string);
197 return default_string; 197 return default_string;
198 } 198 }
199 199
200 // Gets the shelf auto hide behavior from prefs for a root window.
201 ash::ShelfAutoHideBehavior GetShelfAutoHideBehaviorFromPrefs(
202 Profile* profile,
203 aura::Window* root_window) {
204 // Don't show the shelf in app mode.
205 if (chrome::IsRunningInAppMode())
206 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
207
208 // See comment in |kShelfAlignment| as to why we consider two prefs.
209 const std::string behavior_value(
210 GetPrefForRootWindow(profile->GetPrefs(),
211 root_window,
212 prefs::kShelfAutoHideBehaviorLocal,
213 prefs::kShelfAutoHideBehavior));
214
215 // Note: To maintain sync compatibility with old images of chrome/chromeos
216 // the set of values that may be encountered includes the now-extinct
217 // "Default" as well as "Never" and "Always", "Default" should now
218 // be treated as "Never" (http://crbug.com/146773).
219 if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
220 return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
221 return ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
222 }
223
224 // Gets the shelf alignment from prefs for a root window.
225 ash::ShelfAlignment GetShelfAlignmentFromPrefs(Profile* profile,
226 aura::Window* root_window) {
227 // See comment in |kShelfAlignment| as to why we consider two prefs.
228 const std::string alignment_value(
229 GetPrefForRootWindow(profile->GetPrefs(),
230 root_window,
231 prefs::kShelfAlignmentLocal,
232 prefs::kShelfAlignment));
233 if (alignment_value == ash::kShelfAlignmentLeft)
234 return ash::SHELF_ALIGNMENT_LEFT;
235 else if (alignment_value == ash::kShelfAlignmentRight)
236 return ash::SHELF_ALIGNMENT_RIGHT;
237 else if (alignment_value == ash::kShelfAlignmentTop)
238 return ash::SHELF_ALIGNMENT_TOP;
239 return ash::SHELF_ALIGNMENT_BOTTOM;
240 }
241
200 // If prefs have synced and no user-set value exists at |local_path|, the value 242 // If prefs have synced and no user-set value exists at |local_path|, the value
201 // from |synced_path| is copied to |local_path|. 243 // from |synced_path| is copied to |local_path|.
202 void MaybePropagatePrefToLocal(PrefServiceSyncable* pref_service, 244 void MaybePropagatePrefToLocal(PrefServiceSyncable* pref_service,
203 const char* local_path, 245 const char* local_path,
204 const char* synced_path) { 246 const char* synced_path) {
205 if (!pref_service->FindPreference(local_path)->HasUserSetting() && 247 if (!pref_service->FindPreference(local_path)->HasUserSetting() &&
206 pref_service->IsSyncing()) { 248 pref_service->IsSyncing()) {
207 // First time the user is using this machine, propagate from remote to 249 // First time the user is using this machine, propagate from remote to
208 // local. 250 // local.
209 pref_service->SetString(local_path, pref_service->GetString(synced_path)); 251 pref_service->SetString(local_path, pref_service->GetString(synced_path));
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 ash::ShelfModel* ChromeLauncherController::model() { 955 ash::ShelfModel* ChromeLauncherController::model() {
914 return model_; 956 return model_;
915 } 957 }
916 958
917 Profile* ChromeLauncherController::profile() { 959 Profile* ChromeLauncherController::profile() {
918 return profile_; 960 return profile_;
919 } 961 }
920 962
921 ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior( 963 ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior(
922 aura::Window* root_window) const { 964 aura::Window* root_window) const {
923 // Don't show the shelf in app mode. 965 return GetShelfAutoHideBehaviorFromPrefs(profile_, root_window);
924 if (chrome::IsRunningInAppMode())
925 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
926
927 // See comment in |kShelfAlignment| as to why we consider two prefs.
928 const std::string behavior_value(
929 GetPrefForRootWindow(profile_->GetPrefs(),
930 root_window,
931 prefs::kShelfAutoHideBehaviorLocal,
932 prefs::kShelfAutoHideBehavior));
933
934 // Note: To maintain sync compatibility with old images of chrome/chromeos
935 // the set of values that may be encountered includes the now-extinct
936 // "Default" as well as "Never" and "Always", "Default" should now
937 // be treated as "Never" (http://crbug.com/146773).
938 if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
939 return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
940 return ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
941 } 966 }
942 967
943 bool ChromeLauncherController::CanUserModifyShelfAutoHideBehavior( 968 bool ChromeLauncherController::CanUserModifyShelfAutoHideBehavior(
944 aura::Window* root_window) const { 969 aura::Window* root_window) const {
945 return profile_->GetPrefs()-> 970 return profile_->GetPrefs()->
946 FindPreference(prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable(); 971 FindPreference(prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable();
947 } 972 }
948 973
949 void ChromeLauncherController::ToggleShelfAutoHideBehavior( 974 void ChromeLauncherController::ToggleShelfAutoHideBehavior(
950 aura::Window* root_window) { 975 aura::Window* root_window) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1456
1432 bool ChromeLauncherController::IsBrowserFromActiveUser(Browser* browser) { 1457 bool ChromeLauncherController::IsBrowserFromActiveUser(Browser* browser) {
1433 // If running multi user mode with separate desktops, we have to check if the 1458 // If running multi user mode with separate desktops, we have to check if the
1434 // browser is from the active user. 1459 // browser is from the active user.
1435 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 1460 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
1436 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) 1461 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
1437 return true; 1462 return true;
1438 return multi_user_util::IsProfileFromActiveUser(browser->profile()); 1463 return multi_user_util::IsProfileFromActiveUser(browser->profile());
1439 } 1464 }
1440 1465
1466 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser(
1467 aura::Window* root_window,
1468 const std::string& user_id) const {
1469 Profile* other_profile = multi_user_util::GetProfileFromUserID(user_id);
1470 DCHECK_NE(other_profile, profile_);
1471
1472 // Note: The Auto hide state from preferences is not the same as the actual
1473 // visibility of the shelf. Depending on all the various states (full screen,
1474 // no window on desktop, multi user, ..) the shelf could be shown - or not.
1475 bool currently_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
1476 GetShelfAutoHideBehaviorFromPrefs(profile_, root_window);
1477 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
1478 GetShelfAutoHideBehaviorFromPrefs(other_profile, root_window);
1479
1480 return currently_shown != other_shown ||
1481 GetShelfAlignmentFromPrefs(profile_, root_window) !=
1482 GetShelfAlignmentFromPrefs(other_profile, root_window);
1483 }
1484
1441 void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) { 1485 void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) {
1442 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); 1486 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
1443 CHECK(iter != id_to_item_controller_map_.end()); 1487 CHECK(iter != id_to_item_controller_map_.end());
1444 CHECK(iter->second); 1488 CHECK(iter->second);
1445 app_icon_loader_->ClearImage(iter->second->app_id()); 1489 app_icon_loader_->ClearImage(iter->second->app_id());
1446 id_to_item_controller_map_.erase(iter); 1490 id_to_item_controller_map_.erase(iter);
1447 int index = model_->ItemIndexByID(id); 1491 int index = model_->ItemIndexByID(id);
1448 // A "browser proxy" is not known to the model and this removal does 1492 // A "browser proxy" is not known to the model and this removal does
1449 // therefore not need to be propagated to the model. 1493 // therefore not need to be propagated to the model.
1450 if (index != -1) 1494 if (index != -1)
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 } 1733 }
1690 1734
1691 void ChromeLauncherController::SetShelfAlignmentFromPrefs() { 1735 void ChromeLauncherController::SetShelfAlignmentFromPrefs() {
1692 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) 1736 if (!ash::ShelfWidget::ShelfAlignmentAllowed())
1693 return; 1737 return;
1694 1738
1695 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); 1739 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
1696 1740
1697 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); 1741 for (aura::Window::Windows::const_iterator iter = root_windows.begin();
1698 iter != root_windows.end(); ++iter) { 1742 iter != root_windows.end(); ++iter) {
1699 // See comment in |kShelfAlignment| as to why we consider two prefs. 1743 ash::Shell::GetInstance()->SetShelfAlignment(
1700 const std::string alignment_value( 1744 GetShelfAlignmentFromPrefs(profile_, *iter), *iter);
1701 GetPrefForRootWindow(profile_->GetPrefs(),
1702 *iter,
1703 prefs::kShelfAlignmentLocal,
1704 prefs::kShelfAlignment));
1705 ash::ShelfAlignment alignment = ash::SHELF_ALIGNMENT_BOTTOM;
1706 if (alignment_value == ash::kShelfAlignmentLeft)
1707 alignment = ash::SHELF_ALIGNMENT_LEFT;
1708 else if (alignment_value == ash::kShelfAlignmentRight)
1709 alignment = ash::SHELF_ALIGNMENT_RIGHT;
1710 else if (alignment_value == ash::kShelfAlignmentTop)
1711 alignment = ash::SHELF_ALIGNMENT_TOP;
1712 ash::Shell::GetInstance()->SetShelfAlignment(alignment, *iter);
1713 } 1745 }
1714 } 1746 }
1715 1747
1716 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() { 1748 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() {
1717 SetShelfAutoHideBehaviorFromPrefs(); 1749 SetShelfAutoHideBehaviorFromPrefs();
1718 SetShelfAlignmentFromPrefs(); 1750 SetShelfAlignmentFromPrefs();
1719 } 1751 }
1720 1752
1721 #if defined(OS_CHROMEOS) 1753 #if defined(OS_CHROMEOS)
1722 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() { 1754 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 } 2094 }
2063 2095
2064 void ChromeLauncherController::ReleaseProfile() { 2096 void ChromeLauncherController::ReleaseProfile() {
2065 if (app_sync_ui_state_) 2097 if (app_sync_ui_state_)
2066 app_sync_ui_state_->RemoveObserver(this); 2098 app_sync_ui_state_->RemoveObserver(this);
2067 2099
2068 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); 2100 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this);
2069 2101
2070 pref_change_registrar_.RemoveAll(); 2102 pref_change_registrar_.RemoveAll();
2071 } 2103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698