| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 ash::ShelfModel* ChromeLauncherController::model() { | 1016 ash::ShelfModel* ChromeLauncherController::model() { |
| 1017 return model_; | 1017 return model_; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 Profile* ChromeLauncherController::profile() { | 1020 Profile* ChromeLauncherController::profile() { |
| 1021 return profile_; | 1021 return profile_; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior( | |
| 1025 aura::Window* root_window) const { | |
| 1026 return GetShelfAutoHideBehaviorFromPrefs(profile_, root_window); | |
| 1027 } | |
| 1028 | |
| 1029 bool ChromeLauncherController::CanUserModifyShelfAutoHideBehavior( | |
| 1030 aura::Window* root_window) const { | |
| 1031 #if defined(OS_WIN) | |
| 1032 // Disable shelf auto-hide behavior on screen sides in Metro mode. | |
| 1033 if (ash::Shell::GetInstance()->GetShelfAlignment(root_window) != | |
| 1034 ash::SHELF_ALIGNMENT_BOTTOM) { | |
| 1035 return false; | |
| 1036 } | |
| 1037 #endif | |
| 1038 return profile_->GetPrefs()-> | |
| 1039 FindPreference(prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable(); | |
| 1040 } | |
| 1041 | |
| 1042 void ChromeLauncherController::ToggleShelfAutoHideBehavior( | |
| 1043 aura::Window* root_window) { | |
| 1044 ash::ShelfAutoHideBehavior behavior = GetShelfAutoHideBehavior(root_window) == | |
| 1045 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? | |
| 1046 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : | |
| 1047 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | |
| 1048 SetShelfAutoHideBehaviorPrefs(behavior, root_window); | |
| 1049 return; | |
| 1050 } | |
| 1051 | |
| 1052 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, | 1024 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, |
| 1053 AppState app_state) { | 1025 AppState app_state) { |
| 1054 std::string app_id = app_tab_helper_->GetAppID(contents); | 1026 std::string app_id = app_tab_helper_->GetAppID(contents); |
| 1055 | 1027 |
| 1056 // Check if the gMail app is loaded and it matches the given content. | 1028 // Check if the gMail app is loaded and it matches the given content. |
| 1057 // This special treatment is needed to address crbug.com/234268. | 1029 // This special treatment is needed to address crbug.com/234268. |
| 1058 if (app_id.empty() && ContentCanBeHandledByGmailApp(contents)) | 1030 if (app_id.empty() && ContentCanBeHandledByGmailApp(contents)) |
| 1059 app_id = kGmailAppId; | 1031 app_id = kGmailAppId; |
| 1060 | 1032 |
| 1061 // Check the old |app_id| for a tab. If the contents has changed we need to | 1033 // Check the old |app_id| for a tab. If the contents has changed we need to |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 | 1801 |
| 1830 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 1802 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
| 1831 // See comment in |kShelfAlignment| about why we have two prefs here. | 1803 // See comment in |kShelfAlignment| about why we have two prefs here. |
| 1832 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); | 1804 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); |
| 1833 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); | 1805 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); |
| 1834 } | 1806 } |
| 1835 } | 1807 } |
| 1836 | 1808 |
| 1837 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() { | 1809 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() { |
| 1838 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 1810 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 1839 | 1811 for (auto i = root_windows.begin(); i != root_windows.end(); ++i) { |
| 1840 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | |
| 1841 iter != root_windows.end(); ++iter) { | |
| 1842 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( | 1812 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( |
| 1843 GetShelfAutoHideBehavior(*iter), *iter); | 1813 GetShelfAutoHideBehaviorFromPrefs(profile_, *i), *i); |
| 1844 } | 1814 } |
| 1845 } | 1815 } |
| 1846 | 1816 |
| 1847 void ChromeLauncherController::SetShelfAlignmentFromPrefs() { | 1817 void ChromeLauncherController::SetShelfAlignmentFromPrefs() { |
| 1848 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) | 1818 if (!ash::ShelfWidget::ShelfAlignmentAllowed()) |
| 1849 return; | 1819 return; |
| 1850 | 1820 |
| 1851 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 1821 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| 1852 | 1822 for (auto i = root_windows.begin(); i != root_windows.end(); ++i) { |
| 1853 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | |
| 1854 iter != root_windows.end(); ++iter) { | |
| 1855 ash::Shell::GetInstance()->SetShelfAlignment( | 1823 ash::Shell::GetInstance()->SetShelfAlignment( |
| 1856 GetShelfAlignmentFromPrefs(profile_, *iter), *iter); | 1824 GetShelfAlignmentFromPrefs(profile_, *i), *i); |
| 1857 } | 1825 } |
| 1858 } | 1826 } |
| 1859 | 1827 |
| 1860 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() { | 1828 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() { |
| 1861 SetShelfAutoHideBehaviorFromPrefs(); | 1829 SetShelfAutoHideBehaviorFromPrefs(); |
| 1862 SetShelfAlignmentFromPrefs(); | 1830 SetShelfAlignmentFromPrefs(); |
| 1863 } | 1831 } |
| 1864 | 1832 |
| 1865 #if defined(OS_CHROMEOS) | 1833 #if defined(OS_CHROMEOS) |
| 1866 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() { | 1834 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 | 2217 |
| 2250 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( | 2218 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( |
| 2251 const std::string& app_id) { | 2219 const std::string& app_id) { |
| 2252 for (const auto& app_icon_loader : app_icon_loaders_) { | 2220 for (const auto& app_icon_loader : app_icon_loaders_) { |
| 2253 if (app_icon_loader->CanLoadImageForApp(app_id)) | 2221 if (app_icon_loader->CanLoadImageForApp(app_id)) |
| 2254 return app_icon_loader.get(); | 2222 return app_icon_loader.get(); |
| 2255 } | 2223 } |
| 2256 | 2224 |
| 2257 return nullptr; | 2225 return nullptr; |
| 2258 } | 2226 } |
| OLD | NEW |