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

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

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_switches.h" 11 #include "ash/ash_switches.h"
12 #include "ash/desktop_background/desktop_background_controller.h" 12 #include "ash/desktop_background/desktop_background_controller.h"
13 #include "ash/multi_profile_uma.h" 13 #include "ash/multi_profile_uma.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
16 #include "ash/shelf/shelf_item_delegate_manager.h" 16 #include "ash/shelf/shelf_item_delegate_manager.h"
17 #include "ash/shelf/shelf_model.h" 17 #include "ash/shelf/shelf_model.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/system/tray/system_tray_delegate.h" 19 #include "ash/system/tray/system_tray_delegate.h"
20 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/strings/pattern.h" 23 #include "base/strings/pattern.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/defaults.h" 30 #include "chrome/browser/defaults.h"
30 #include "chrome/browser/extensions/extension_app_icon_loader.h" 31 #include "chrome/browser/extensions/extension_app_icon_loader.h"
31 #include "chrome/browser/extensions/extension_util.h" 32 #include "chrome/browser/extensions/extension_util.h"
32 #include "chrome/browser/extensions/launch_util.h" 33 #include "chrome/browser/extensions/launch_util.h"
33 #include "chrome/browser/prefs/incognito_mode_prefs.h" 34 #include "chrome/browser/prefs/incognito_mode_prefs.h"
34 #include "chrome/browser/prefs/pref_service_syncable_util.h" 35 #include "chrome/browser/prefs/pref_service_syncable_util.h"
35 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
38 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
39 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
37 #include "chrome/browser/ui/ash/app_sync_ui_state.h" 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h"
38 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 41 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
42 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
39 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h " 43 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
40 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
41 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" 45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
46 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
42 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 47 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
43 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 48 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
44 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 49 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
45 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h " 50 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h "
46 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" 51 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
47 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" 52 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
53 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h"
48 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 54 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
49 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h" 55 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h"
50 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 56 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
57 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h"
58 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
51 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 59 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
52 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 60 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
53 #include "chrome/browser/ui/browser.h" 61 #include "chrome/browser/ui/browser.h"
54 #include "chrome/browser/ui/browser_commands.h" 62 #include "chrome/browser/ui/browser_commands.h"
55 #include "chrome/browser/ui/browser_finder.h" 63 #include "chrome/browser/ui/browser_finder.h"
56 #include "chrome/browser/ui/browser_list.h" 64 #include "chrome/browser/ui/browser_list.h"
57 #include "chrome/browser/ui/browser_tabstrip.h" 65 #include "chrome/browser/ui/browser_tabstrip.h"
58 #include "chrome/browser/ui/browser_window.h" 66 #include "chrome/browser/ui/browser_window.h"
59 #include "chrome/browser/ui/tabs/tab_strip_model.h" 67 #include "chrome/browser/ui/tabs/tab_strip_model.h"
60 #include "chrome/browser/web_applications/web_app.h" 68 #include "chrome/browser/web_applications/web_app.h"
61 #include "chrome/common/chrome_switches.h" 69 #include "chrome/common/chrome_switches.h"
62 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 70 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
63 #include "chrome/common/pref_names.h" 71 #include "chrome/common/pref_names.h"
64 #include "chrome/common/url_constants.h" 72 #include "chrome/common/url_constants.h"
65 #include "chrome/grit/generated_resources.h" 73 #include "chrome/grit/generated_resources.h"
66 #include "components/favicon/content/content_favicon_driver.h" 74 #include "components/favicon/content/content_favicon_driver.h"
67 #include "components/prefs/scoped_user_pref_update.h" 75 #include "components/prefs/scoped_user_pref_update.h"
68 #include "components/signin/core/account_id/account_id.h" 76 #include "components/signin/core/account_id/account_id.h"
69 #include "components/strings/grit/components_strings.h" 77 #include "components/strings/grit/components_strings.h"
70 #include "components/syncable_prefs/pref_service_syncable.h" 78 #include "components/syncable_prefs/pref_service_syncable.h"
79 #include "components/user_manager/user_manager.h"
71 #include "content/public/browser/navigation_entry.h" 80 #include "content/public/browser/navigation_entry.h"
72 #include "content/public/browser/web_contents.h" 81 #include "content/public/browser/web_contents.h"
73 #include "extensions/browser/extension_prefs.h" 82 #include "extensions/browser/extension_prefs.h"
74 #include "extensions/browser/extension_registry.h" 83 #include "extensions/browser/extension_registry.h"
75 #include "extensions/browser/extension_system.h" 84 #include "extensions/browser/extension_system.h"
76 #include "extensions/browser/extension_util.h" 85 #include "extensions/browser/extension_util.h"
77 #include "extensions/common/constants.h" 86 #include "extensions/common/constants.h"
78 #include "extensions/common/extension.h" 87 #include "extensions/common/extension.h"
79 #include "extensions/common/extension_resource.h" 88 #include "extensions/common/extension_resource.h"
80 #include "extensions/common/manifest_handlers/icons_handler.h" 89 #include "extensions/common/manifest_handlers/icons_handler.h"
81 #include "extensions/common/url_pattern.h" 90 #include "extensions/common/url_pattern.h"
82 #include "grit/ash_resources.h" 91 #include "grit/ash_resources.h"
83 #include "grit/theme_resources.h" 92 #include "grit/theme_resources.h"
84 #include "ui/aura/window.h" 93 #include "ui/aura/window.h"
85 #include "ui/aura/window_event_dispatcher.h" 94 #include "ui/aura/window_event_dispatcher.h"
86 #include "ui/base/l10n/l10n_util.h" 95 #include "ui/base/l10n/l10n_util.h"
87 #include "ui/base/resource/resource_bundle.h" 96 #include "ui/base/resource/resource_bundle.h"
88 #include "ui/base/window_open_disposition.h" 97 #include "ui/base/window_open_disposition.h"
89 #include "ui/keyboard/keyboard_util.h" 98 #include "ui/keyboard/keyboard_util.h"
90 #include "ui/resources/grit/ui_resources.h" 99 #include "ui/resources/grit/ui_resources.h"
91 #include "ui/wm/core/window_animations.h" 100 #include "ui/wm/core/window_animations.h"
92 101
93 #if defined(OS_CHROMEOS)
94 #include "chrome/browser/browser_process.h"
95 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
96 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
97 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
98 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
99 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h"
100 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h"
101 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
102 #include "components/user_manager/user_manager.h"
103 #endif
104
105 using extensions::Extension; 102 using extensions::Extension;
106 using extensions::UnloadedExtensionInfo; 103 using extensions::UnloadedExtensionInfo;
107 using extension_misc::kGmailAppId; 104 using extension_misc::kGmailAppId;
108 using content::WebContents; 105 using content::WebContents;
109 106
110 // static 107 // static
111 ChromeLauncherController* ChromeLauncherController::instance_ = NULL; 108 ChromeLauncherController* ChromeLauncherController::instance_ = NULL;
112 109
113 namespace { 110 namespace {
114 111
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (app_id == app_id_) 174 if (app_id == app_id_)
178 return false; 175 return false;
179 } 176 }
180 } 177 }
181 } 178 }
182 // Default, user added new pins 179 // Default, user added new pins
183 return true; 180 return true;
184 } 181 }
185 182
186 const char* const kPinProhibitedExtensionIds[] = { 183 const char* const kPinProhibitedExtensionIds[] = {
187 #if defined(OS_CHROMEOS)
188 "cnbgggchhmkkdmeppjobngjoejnihlei", // Arc Support 184 "cnbgggchhmkkdmeppjobngjoejnihlei", // Arc Support
189 #endif
190 }; 185 };
191 186
192 const size_t kPinProhibitedExtensionIdsLength = 187 const size_t kPinProhibitedExtensionIdsLength =
193 arraysize(kPinProhibitedExtensionIds); 188 arraysize(kPinProhibitedExtensionIds);
194 189
195 } // namespace 190 } // namespace
196 191
197 #if defined(OS_CHROMEOS)
198 // A class to get events from ChromeOS when a user gets changed or added. 192 // A class to get events from ChromeOS when a user gets changed or added.
199 class ChromeLauncherControllerUserSwitchObserver 193 class ChromeLauncherControllerUserSwitchObserver
200 : public user_manager::UserManager::UserSessionStateObserver { 194 : public user_manager::UserManager::UserSessionStateObserver {
201 public: 195 public:
202 ChromeLauncherControllerUserSwitchObserver( 196 ChromeLauncherControllerUserSwitchObserver(
203 ChromeLauncherController* controller) 197 ChromeLauncherController* controller)
204 : controller_(controller) { 198 : controller_(controller) {
205 DCHECK(user_manager::UserManager::IsInitialized()); 199 DCHECK(user_manager::UserManager::IsInitialized());
206 user_manager::UserManager::Get()->AddSessionStateObserver(this); 200 user_manager::UserManager::Get()->AddSessionStateObserver(this);
207 } 201 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 251 }
258 } 252 }
259 } 253 }
260 254
261 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) { 255 void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) {
262 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 256 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
263 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) 257 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
264 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile); 258 chrome::MultiUserWindowManager::GetInstance()->AddUser(profile);
265 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile()); 259 controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile());
266 } 260 }
267 #endif
268 261
269 ChromeLauncherController::ChromeLauncherController(Profile* profile, 262 ChromeLauncherController::ChromeLauncherController(Profile* profile,
270 ash::ShelfModel* model) 263 ash::ShelfModel* model)
271 : model_(model), 264 : model_(model),
272 item_delegate_manager_(NULL), 265 item_delegate_manager_(NULL),
273 profile_(profile), 266 profile_(profile),
274 app_sync_ui_state_(NULL), 267 app_sync_ui_state_(NULL),
275 ignore_persist_pinned_state_change_(false) { 268 ignore_persist_pinned_state_change_(false) {
276 if (!profile_) { 269 if (!profile_) {
277 // If no profile was passed, we take the currently active profile and use it 270 // If no profile was passed, we take the currently active profile and use it
(...skipping 11 matching lines...) Expand all
289 } 282 }
290 283
291 // All profile relevant settings get bound to the current profile. 284 // All profile relevant settings get bound to the current profile.
292 AttachProfile(profile_); 285 AttachProfile(profile_);
293 model_->AddObserver(this); 286 model_->AddObserver(this);
294 287
295 // In multi profile mode we might have a window manager. We try to create it 288 // In multi profile mode we might have a window manager. We try to create it
296 // here. If the instantiation fails, the manager is not needed. 289 // here. If the instantiation fails, the manager is not needed.
297 chrome::MultiUserWindowManager::CreateInstance(); 290 chrome::MultiUserWindowManager::CreateInstance();
298 291
299 #if defined(OS_CHROMEOS)
300 // On Chrome OS using multi profile we want to switch the content of the shelf 292 // On Chrome OS using multi profile we want to switch the content of the shelf
301 // with a user change. Note that for unit tests the instance can be NULL. 293 // with a user change. Note that for unit tests the instance can be NULL.
302 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 294 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
303 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) { 295 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) {
304 user_switch_observer_.reset( 296 user_switch_observer_.reset(
305 new ChromeLauncherControllerUserSwitchObserver(this)); 297 new ChromeLauncherControllerUserSwitchObserver(this));
306 } 298 }
307 299
308 std::unique_ptr<AppWindowLauncherController> extension_app_window_controller; 300 std::unique_ptr<AppWindowLauncherController> extension_app_window_controller;
309 // Create our v1/v2 application / browser monitors which will inform the 301 // Create our v1/v2 application / browser monitors which will inform the
(...skipping 10 matching lines...) Expand all
320 // launcher of status changes. 312 // launcher of status changes.
321 browser_status_monitor_.reset(new BrowserStatusMonitor(this)); 313 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
322 extension_app_window_controller.reset( 314 extension_app_window_controller.reset(
323 new ExtensionAppWindowLauncherController(this)); 315 new ExtensionAppWindowLauncherController(this));
324 } 316 }
325 app_window_controllers_.push_back(std::move(extension_app_window_controller)); 317 app_window_controllers_.push_back(std::move(extension_app_window_controller));
326 318
327 std::unique_ptr<AppWindowLauncherController> arc_app_window_controller; 319 std::unique_ptr<AppWindowLauncherController> arc_app_window_controller;
328 arc_app_window_controller.reset(new ArcAppWindowLauncherController(this)); 320 arc_app_window_controller.reset(new ArcAppWindowLauncherController(this));
329 app_window_controllers_.push_back(std::move(arc_app_window_controller)); 321 app_window_controllers_.push_back(std::move(arc_app_window_controller));
330 #else
331 // Create our v1/v2 application / browser monitors which will inform the
332 // launcher of status changes.
333 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
334 std::unique_ptr<AppWindowLauncherController> extension_app_window_controller;
335 extension_app_window_controller.reset(
336 new ExtensionAppWindowLauncherController(this));
337 app_window_controllers_.push_back(std::move(extension_app_window_controller));
338 #endif
339 322
340 // Right now ash::Shell isn't created for tests. 323 // Right now ash::Shell isn't created for tests.
341 // TODO(mukai): Allows it to observe display change and write tests. 324 // TODO(mukai): Allows it to observe display change and write tests.
342 if (ash::Shell::HasInstance()) { 325 if (ash::Shell::HasInstance()) {
343 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); 326 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
344 // If it got already set, we remove the observer first again and swap the 327 // If it got already set, we remove the observer first again and swap the
345 // ItemDelegateManager. 328 // ItemDelegateManager.
346 if (item_delegate_manager_) 329 if (item_delegate_manager_)
347 item_delegate_manager_->RemoveObserver(this); 330 item_delegate_manager_->RemoveObserver(this);
348 item_delegate_manager_ = 331 item_delegate_manager_ =
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // it appears that it might be intentional that the ChromeLauncherController 374 // it appears that it might be intentional that the ChromeLauncherController
392 // can be re-created. 375 // can be re-created.
393 instance_ = new ChromeLauncherController(profile, model); 376 instance_ = new ChromeLauncherController(profile, model);
394 return instance_; 377 return instance_;
395 } 378 }
396 379
397 void ChromeLauncherController::Init() { 380 void ChromeLauncherController::Init() {
398 CreateBrowserShortcutLauncherItem(); 381 CreateBrowserShortcutLauncherItem();
399 UpdateAppLaunchersFromPref(); 382 UpdateAppLaunchersFromPref();
400 383
401 #if defined(OS_CHROMEOS)
402 // TODO(sky): update unit test so that this test isn't necessary. 384 // TODO(sky): update unit test so that this test isn't necessary.
403 if (ash::Shell::HasInstance()) 385 if (ash::Shell::HasInstance())
404 SetVirtualKeyboardBehaviorFromPrefs(); 386 SetVirtualKeyboardBehaviorFromPrefs();
405 #endif // defined(OS_CHROMEOS)
406 387
407 syncable_prefs::PrefServiceSyncable* prefs = 388 syncable_prefs::PrefServiceSyncable* prefs =
408 PrefServiceSyncableFromProfile(profile_); 389 PrefServiceSyncableFromProfile(profile_);
409 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() || 390 if (!prefs->FindPreference(prefs::kShelfAlignmentLocal)->HasUserSetting() ||
410 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal) 391 !prefs->FindPreference(prefs::kShelfAutoHideBehaviorLocal)
411 ->HasUserSetting()) { 392 ->HasUserSetting()) {
412 // This causes OnIsSyncingChanged to be called when the value of 393 // This causes OnIsSyncingChanged to be called when the value of
413 // PrefService::IsSyncing() changes. 394 // PrefService::IsSyncing() changes.
414 prefs->AddObserver(this); 395 prefs->AddObserver(this);
415 } 396 }
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 // set it as active. 1004 // set it as active.
1024 AttachProfile(ProfileManager::GetActiveUserProfile()); 1005 AttachProfile(ProfileManager::GetActiveUserProfile());
1025 // Update the V1 applications. 1006 // Update the V1 applications.
1026 browser_status_monitor_->ActiveUserChanged(user_email); 1007 browser_status_monitor_->ActiveUserChanged(user_email);
1027 // Switch the running applications to the new user. 1008 // Switch the running applications to the new user.
1028 for (auto& controller : app_window_controllers_) 1009 for (auto& controller : app_window_controllers_)
1029 controller->ActiveUserChanged(user_email); 1010 controller->ActiveUserChanged(user_email);
1030 // Update the user specific shell properties from the new user profile. 1011 // Update the user specific shell properties from the new user profile.
1031 UpdateAppLaunchersFromPref(); 1012 UpdateAppLaunchersFromPref();
1032 SetShelfBehaviorsFromPrefs(); 1013 SetShelfBehaviorsFromPrefs();
1033 #if defined(OS_CHROMEOS)
1034 SetVirtualKeyboardBehaviorFromPrefs(); 1014 SetVirtualKeyboardBehaviorFromPrefs();
1035 #endif // defined(OS_CHROMEOS) 1015
1036 // Restore the order of running, but unpinned applications for the activated 1016 // Restore the order of running, but unpinned applications for the activated
1037 // user. 1017 // user.
1038 RestoreUnpinnedRunningApplicationOrder(user_email); 1018 RestoreUnpinnedRunningApplicationOrder(user_email);
1039 // Inform the system tray of the change. 1019 // Inform the system tray of the change.
1040 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged(); 1020 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged();
1041 // Force on-screen keyboard to reset. 1021 // Force on-screen keyboard to reset.
1042 if (keyboard::IsKeyboardEnabled()) 1022 if (keyboard::IsKeyboardEnabled())
1043 ash::Shell::GetInstance()->CreateKeyboard(); 1023 ash::Shell::GetInstance()->CreateKeyboard();
1044 } 1024 }
1045 1025
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 ash::GetShelfAutoHideBehaviorPref(prefs, display); 1320 ash::GetShelfAutoHideBehaviorPref(prefs, display);
1341 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER == 1321 bool other_shown = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER ==
1342 ash::GetShelfAutoHideBehaviorPref(other_prefs, display); 1322 ash::GetShelfAutoHideBehaviorPref(other_prefs, display);
1343 1323
1344 return currently_shown != other_shown || 1324 return currently_shown != other_shown ||
1345 ash::GetShelfAlignmentPref(prefs, display) != 1325 ash::GetShelfAlignmentPref(prefs, display) !=
1346 ash::GetShelfAlignmentPref(other_prefs, display); 1326 ash::GetShelfAlignmentPref(other_prefs, display);
1347 } 1327 }
1348 1328
1349 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) { 1329 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) {
1350 #if defined(OS_CHROMEOS)
1351 if (user_switch_observer_.get()) 1330 if (user_switch_observer_.get())
1352 user_switch_observer_->OnUserProfileReadyToSwitch(profile); 1331 user_switch_observer_->OnUserProfileReadyToSwitch(profile);
1353 #endif
1354 } 1332 }
1355 1333
1356 void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) { 1334 void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) {
1357 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); 1335 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
1358 CHECK(iter != id_to_item_controller_map_.end()); 1336 CHECK(iter != id_to_item_controller_map_.end());
1359 CHECK(iter->second); 1337 CHECK(iter->second);
1360 const std::string& app_id = iter->second->app_id(); 1338 const std::string& app_id = iter->second->app_id();
1361 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 1339 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
1362 if (app_icon_loader) 1340 if (app_icon_loader)
1363 app_icon_loader->ClearImage(app_id); 1341 app_icon_loader->ClearImage(app_id);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 profile_->GetPrefs(), GetDisplayIDForShelf(shelf))); 1569 profile_->GetPrefs(), GetDisplayIDForShelf(shelf)));
1592 } 1570 }
1593 } 1571 }
1594 } 1572 }
1595 1573
1596 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() { 1574 void ChromeLauncherController::SetShelfBehaviorsFromPrefs() {
1597 SetShelfAutoHideBehaviorFromPrefs(); 1575 SetShelfAutoHideBehaviorFromPrefs();
1598 SetShelfAlignmentFromPrefs(); 1576 SetShelfAlignmentFromPrefs();
1599 } 1577 }
1600 1578
1601 #if defined(OS_CHROMEOS)
1602 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() { 1579 void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() {
1603 const PrefService* service = profile_->GetPrefs(); 1580 const PrefService* service = profile_->GetPrefs();
1604 const bool was_enabled = keyboard::IsKeyboardEnabled(); 1581 const bool was_enabled = keyboard::IsKeyboardEnabled();
1605 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) { 1582 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) {
1606 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE); 1583 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE);
1607 } else { 1584 } else {
1608 const bool enable = service->GetBoolean( 1585 const bool enable = service->GetBoolean(
1609 prefs::kTouchVirtualKeyboardEnabled); 1586 prefs::kTouchVirtualKeyboardEnabled);
1610 keyboard::SetKeyboardShowOverride( 1587 keyboard::SetKeyboardShowOverride(
1611 enable ? keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED 1588 enable ? keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED
1612 : keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED); 1589 : keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED);
1613 } 1590 }
1614 const bool is_enabled = keyboard::IsKeyboardEnabled(); 1591 const bool is_enabled = keyboard::IsKeyboardEnabled();
1615 if (was_enabled && !is_enabled) 1592 if (was_enabled && !is_enabled)
1616 ash::Shell::GetInstance()->DeactivateKeyboard(); 1593 ash::Shell::GetInstance()->DeactivateKeyboard();
1617 else if (is_enabled && !was_enabled) 1594 else if (is_enabled && !was_enabled)
1618 ash::Shell::GetInstance()->CreateKeyboard(); 1595 ash::Shell::GetInstance()->CreateKeyboard();
1619 } 1596 }
1620 #endif // defined(OS_CHROMEOS)
1621 1597
1622 ash::ShelfItemStatus ChromeLauncherController::GetAppState( 1598 ash::ShelfItemStatus ChromeLauncherController::GetAppState(
1623 const std::string& app_id) { 1599 const std::string& app_id) {
1624 ash::ShelfItemStatus status = ash::STATUS_CLOSED; 1600 ash::ShelfItemStatus status = ash::STATUS_CLOSED;
1625 for (WebContentsToAppIDMap::iterator it = web_contents_to_app_id_.begin(); 1601 for (WebContentsToAppIDMap::iterator it = web_contents_to_app_id_.begin();
1626 it != web_contents_to_app_id_.end(); 1602 it != web_contents_to_app_id_.end();
1627 ++it) { 1603 ++it) {
1628 if (it->second == app_id) { 1604 if (it->second == app_id) {
1629 Browser* browser = chrome::FindBrowserWithWebContents(it->first); 1605 Browser* browser = chrome::FindBrowserWithWebContents(it->first);
1630 // Usually there should never be an item in our |web_contents_to_app_id_| 1606 // Usually there should never be an item in our |web_contents_to_app_id_|
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded 1814 // TODO(skuhne): The AppIconLoaderImpl has the same problem. Each loaded
1839 // image is associated with a profile (its loader requires the profile). 1815 // image is associated with a profile (its loader requires the profile).
1840 // Since icon size changes are possible, the icon could be requested to be 1816 // Since icon size changes are possible, the icon could be requested to be
1841 // reloaded. However - having it not multi profile aware would cause problems 1817 // reloaded. However - having it not multi profile aware would cause problems
1842 // if the icon cache gets deleted upon user switch. 1818 // if the icon cache gets deleted upon user switch.
1843 std::unique_ptr<AppIconLoader> extension_app_icon_loader( 1819 std::unique_ptr<AppIconLoader> extension_app_icon_loader(
1844 new extensions::ExtensionAppIconLoader( 1820 new extensions::ExtensionAppIconLoader(
1845 profile_, extension_misc::EXTENSION_ICON_SMALL, this)); 1821 profile_, extension_misc::EXTENSION_ICON_SMALL, this));
1846 app_icon_loaders_.push_back(std::move(extension_app_icon_loader)); 1822 app_icon_loaders_.push_back(std::move(extension_app_icon_loader));
1847 1823
1848 #if defined(OS_CHROMEOS)
1849 std::unique_ptr<AppIconLoader> arc_app_icon_loader(new ArcAppIconLoader( 1824 std::unique_ptr<AppIconLoader> arc_app_icon_loader(new ArcAppIconLoader(
1850 profile_, extension_misc::EXTENSION_ICON_SMALL, this)); 1825 profile_, extension_misc::EXTENSION_ICON_SMALL, this));
1851 app_icon_loaders_.push_back(std::move(arc_app_icon_loader)); 1826 app_icon_loaders_.push_back(std::move(arc_app_icon_loader));
1852 #endif
1853 1827
1854 pref_change_registrar_.Init(profile_->GetPrefs()); 1828 pref_change_registrar_.Init(profile_->GetPrefs());
1855 pref_change_registrar_.Add( 1829 pref_change_registrar_.Add(
1856 prefs::kPinnedLauncherApps, 1830 prefs::kPinnedLauncherApps,
1857 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, 1831 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref,
1858 base::Unretained(this))); 1832 base::Unretained(this)));
1859 pref_change_registrar_.Add( 1833 pref_change_registrar_.Add(
1860 prefs::kPolicyPinnedLauncherApps, 1834 prefs::kPolicyPinnedLauncherApps,
1861 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, 1835 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref,
1862 base::Unretained(this))); 1836 base::Unretained(this)));
1863 pref_change_registrar_.Add( 1837 pref_change_registrar_.Add(
1864 prefs::kShelfAlignmentLocal, 1838 prefs::kShelfAlignmentLocal,
1865 base::Bind(&ChromeLauncherController::SetShelfAlignmentFromPrefs, 1839 base::Bind(&ChromeLauncherController::SetShelfAlignmentFromPrefs,
1866 base::Unretained(this))); 1840 base::Unretained(this)));
1867 pref_change_registrar_.Add( 1841 pref_change_registrar_.Add(
1868 prefs::kShelfAutoHideBehaviorLocal, 1842 prefs::kShelfAutoHideBehaviorLocal,
1869 base::Bind(&ChromeLauncherController:: 1843 base::Bind(&ChromeLauncherController::
1870 SetShelfAutoHideBehaviorFromPrefs, 1844 SetShelfAutoHideBehaviorFromPrefs,
1871 base::Unretained(this))); 1845 base::Unretained(this)));
1872 pref_change_registrar_.Add( 1846 pref_change_registrar_.Add(
1873 prefs::kShelfPreferences, 1847 prefs::kShelfPreferences,
1874 base::Bind(&ChromeLauncherController::SetShelfBehaviorsFromPrefs, 1848 base::Bind(&ChromeLauncherController::SetShelfBehaviorsFromPrefs,
1875 base::Unretained(this))); 1849 base::Unretained(this)));
1876 #if defined(OS_CHROMEOS)
1877 pref_change_registrar_.Add( 1850 pref_change_registrar_.Add(
1878 prefs::kTouchVirtualKeyboardEnabled, 1851 prefs::kTouchVirtualKeyboardEnabled,
1879 base::Bind(&ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs, 1852 base::Bind(&ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs,
1880 base::Unretained(this))); 1853 base::Unretained(this)));
1881 #endif // defined(OS_CHROMEOS)
1882 1854
1883 std::unique_ptr<LauncherAppUpdater> extension_app_updater( 1855 std::unique_ptr<LauncherAppUpdater> extension_app_updater(
1884 new LauncherExtensionAppUpdater(this, profile_)); 1856 new LauncherExtensionAppUpdater(this, profile_));
1885 app_updaters_.push_back(std::move(extension_app_updater)); 1857 app_updaters_.push_back(std::move(extension_app_updater));
1886 1858
1887 #if defined(OS_CHROMEOS)
1888 std::unique_ptr<LauncherAppUpdater> arc_app_updater( 1859 std::unique_ptr<LauncherAppUpdater> arc_app_updater(
1889 new LauncherArcAppUpdater(this, profile_)); 1860 new LauncherArcAppUpdater(this, profile_));
1890 app_updaters_.push_back(std::move(arc_app_updater)); 1861 app_updaters_.push_back(std::move(arc_app_updater));
1891 #endif
1892 } 1862 }
1893 1863
1894 void ChromeLauncherController::ReleaseProfile() { 1864 void ChromeLauncherController::ReleaseProfile() {
1895 if (app_sync_ui_state_) 1865 if (app_sync_ui_state_)
1896 app_sync_ui_state_->RemoveObserver(this); 1866 app_sync_ui_state_->RemoveObserver(this);
1897 1867
1898 app_updaters_.clear(); 1868 app_updaters_.clear();
1899 1869
1900 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this); 1870 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this);
1901 1871
1902 pref_change_registrar_.RemoveAll(); 1872 pref_change_registrar_.RemoveAll();
1903 } 1873 }
1904 1874
1905 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( 1875 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
1906 const std::string& app_id) { 1876 const std::string& app_id) {
1907 for (const auto& app_icon_loader : app_icon_loaders_) { 1877 for (const auto& app_icon_loader : app_icon_loaders_) {
1908 if (app_icon_loader->CanLoadImageForApp(app_id)) 1878 if (app_icon_loader->CanLoadImageForApp(app_id))
1909 return app_icon_loader.get(); 1879 return app_icon_loader.get();
1910 } 1880 }
1911 1881
1912 return nullptr; 1882 return nullptr;
1913 } 1883 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698