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_browser.
h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.
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/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/app_mode/app_mode_utils.h" |
15 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
18 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 19 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" | 24 #include "chrome/browser/ui/ash/app_icon_loader_impl.h" |
24 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 25 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
25 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
27 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" | 28 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" |
28 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 29 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
29 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 30 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
30 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" | 31 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" |
31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
33 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
34 #include "chrome/browser/ui/browser_tabstrip.h" | 35 #include "chrome/browser/ui/browser_tabstrip.h" |
35 #include "chrome/browser/ui/browser_window.h" | 36 #include "chrome/browser/ui/browser_window.h" |
36 #include "chrome/browser/ui/extensions/application_launch.h" | 37 #include "chrome/browser/ui/extensions/application_launch.h" |
37 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 38 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
39 #include "chrome/browser/web_applications/web_app.h" | 40 #include "chrome/browser/web_applications/web_app.h" |
40 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
| 42 #include "chrome/common/chrome_switches.h" |
41 #include "chrome/common/extensions/extension.h" | 43 #include "chrome/common/extensions/extension.h" |
42 #include "chrome/common/extensions/extension_resource.h" | 44 #include "chrome/common/extensions/extension_resource.h" |
43 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
45 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
46 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
47 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
48 #include "extensions/common/url_pattern.h" | 50 #include "extensions/common/url_pattern.h" |
49 #include "grit/theme_resources.h" | 51 #include "grit/theme_resources.h" |
50 #include "ui/aura/root_window.h" | 52 #include "ui/aura/root_window.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 653 |
652 bool ChromeLauncherControllerPerBrowser::CanPin() const { | 654 bool ChromeLauncherControllerPerBrowser::CanPin() const { |
653 const PrefService::Preference* pref = | 655 const PrefService::Preference* pref = |
654 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps); | 656 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps); |
655 return pref && pref->IsUserModifiable(); | 657 return pref && pref->IsUserModifiable(); |
656 } | 658 } |
657 | 659 |
658 ash::ShelfAutoHideBehavior | 660 ash::ShelfAutoHideBehavior |
659 ChromeLauncherControllerPerBrowser::GetShelfAutoHideBehavior( | 661 ChromeLauncherControllerPerBrowser::GetShelfAutoHideBehavior( |
660 aura::RootWindow* root_window) const { | 662 aura::RootWindow* root_window) const { |
| 663 // Don't show the shelf in the app mode. |
| 664 if (chrome::IsRunningInAppMode()) |
| 665 return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; |
| 666 |
661 // See comment in |kShelfAlignment| as to why we consider two prefs. | 667 // See comment in |kShelfAlignment| as to why we consider two prefs. |
662 const std::string behavior_value( | 668 const std::string behavior_value( |
663 GetPrefForRootWindow(profile_->GetPrefs(), | 669 GetPrefForRootWindow(profile_->GetPrefs(), |
664 root_window, | 670 root_window, |
665 prefs::kShelfAutoHideBehaviorLocal, | 671 prefs::kShelfAutoHideBehaviorLocal, |
666 prefs::kShelfAutoHideBehavior)); | 672 prefs::kShelfAutoHideBehavior)); |
667 | 673 |
668 // Note: To maintain sync compatibility with old images of chrome/chromeos | 674 // Note: To maintain sync compatibility with old images of chrome/chromeos |
669 // the set of values that may be encountered includes the now-extinct | 675 // the set of values that may be encountered includes the now-extinct |
670 // "Default" as well as "Never" and "Always", "Default" should now | 676 // "Default" as well as "Never" and "Always", "Default" should now |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 ash::ShelfAutoHideBehavior behavior, | 1129 ash::ShelfAutoHideBehavior behavior, |
1124 aura::RootWindow* root_window) { | 1130 aura::RootWindow* root_window) { |
1125 const char* value = NULL; | 1131 const char* value = NULL; |
1126 switch (behavior) { | 1132 switch (behavior) { |
1127 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | 1133 case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
1128 value = ash::kShelfAutoHideBehaviorAlways; | 1134 value = ash::kShelfAutoHideBehaviorAlways; |
1129 break; | 1135 break; |
1130 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 1136 case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
1131 value = ash::kShelfAutoHideBehaviorNever; | 1137 value = ash::kShelfAutoHideBehaviorNever; |
1132 break; | 1138 break; |
| 1139 case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 1140 // This one should not be a valid preference option for now. We only want |
| 1141 // to completely hide it when we run app mode. |
| 1142 NOTREACHED(); |
| 1143 return; |
1133 } | 1144 } |
1134 | 1145 |
1135 UpdatePerDisplayPref( | 1146 UpdatePerDisplayPref( |
1136 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value); | 1147 profile_->GetPrefs(), root_window, prefs::kShelfAutoHideBehavior, value); |
1137 | 1148 |
1138 if (root_window == ash::Shell::GetPrimaryRootWindow()) { | 1149 if (root_window == ash::Shell::GetPrimaryRootWindow()) { |
1139 // See comment in |kShelfAlignment| about why we have two prefs here. | 1150 // See comment in |kShelfAlignment| about why we have two prefs here. |
1140 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); | 1151 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value); |
1141 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); | 1152 profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value); |
1142 } | 1153 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( | 1263 void ChromeLauncherControllerPerBrowser::SetAppIconLoaderForTest( |
1253 ash::AppIconLoader* loader) { | 1264 ash::AppIconLoader* loader) { |
1254 app_icon_loader_.reset(loader); | 1265 app_icon_loader_.reset(loader); |
1255 } | 1266 } |
1256 | 1267 |
1257 const std::string& | 1268 const std::string& |
1258 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( | 1269 ChromeLauncherControllerPerBrowser::GetAppIdFromLauncherIdForTest( |
1259 ash::LauncherID id) { | 1270 ash::LauncherID id) { |
1260 return id_to_item_controller_map_[id]->app_id(); | 1271 return id_to_item_controller_map_[id]->app_id(); |
1261 } | 1272 } |
OLD | NEW |