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

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

Issue 1823923002: arc: Support running Arc app in shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased + few nits Created 4 years, 8 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
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "ui/keyboard/keyboard_util.h" 96 #include "ui/keyboard/keyboard_util.h"
97 #include "ui/resources/grit/ui_resources.h" 97 #include "ui/resources/grit/ui_resources.h"
98 #include "ui/wm/core/window_animations.h" 98 #include "ui/wm/core/window_animations.h"
99 99
100 #if defined(OS_CHROMEOS) 100 #if defined(OS_CHROMEOS)
101 #include "chrome/browser/browser_process.h" 101 #include "chrome/browser/browser_process.h"
102 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" 102 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
103 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 103 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
104 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 104 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
105 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 105 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
106 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
106 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" 107 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h"
107 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h" 108 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h"
108 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" 109 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
109 #include "components/user_manager/user_manager.h" 110 #include "components/user_manager/user_manager.h"
110 #endif 111 #endif
111 112
112 using extensions::Extension; 113 using extensions::Extension;
113 using extensions::UnloadedExtensionInfo; 114 using extensions::UnloadedExtensionInfo;
114 using extension_misc::kGmailAppId; 115 using extension_misc::kGmailAppId;
115 using content::WebContents; 116 using content::WebContents;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 454
454 #if defined(OS_CHROMEOS) 455 #if defined(OS_CHROMEOS)
455 // On Chrome OS using multi profile we want to switch the content of the shelf 456 // On Chrome OS using multi profile we want to switch the content of the shelf
456 // with a user change. Note that for unit tests the instance can be NULL. 457 // with a user change. Note that for unit tests the instance can be NULL.
457 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 458 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
458 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) { 459 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) {
459 user_switch_observer_.reset( 460 user_switch_observer_.reset(
460 new ChromeLauncherControllerUserSwitchObserver(this)); 461 new ChromeLauncherControllerUserSwitchObserver(this));
461 } 462 }
462 463
464 scoped_ptr<AppWindowLauncherController> extension_app_window_controller;
463 // Create our v1/v2 application / browser monitors which will inform the 465 // Create our v1/v2 application / browser monitors which will inform the
464 // launcher of status changes. 466 // launcher of status changes.
465 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 467 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
466 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { 468 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
467 // If running in separated destkop mode, we create the multi profile version 469 // If running in separated destkop mode, we create the multi profile version
468 // of status monitor. 470 // of status monitor.
469 browser_status_monitor_.reset(new MultiProfileBrowserStatusMonitor(this)); 471 browser_status_monitor_.reset(new MultiProfileBrowserStatusMonitor(this));
470 app_window_controller_.reset( 472 extension_app_window_controller.reset(
471 new MultiProfileAppWindowLauncherController(this)); 473 new MultiProfileAppWindowLauncherController(this));
472 } else { 474 } else {
473 // Create our v1/v2 application / browser monitors which will inform the 475 // Create our v1/v2 application / browser monitors which will inform the
474 // launcher of status changes. 476 // launcher of status changes.
475 browser_status_monitor_.reset(new BrowserStatusMonitor(this)); 477 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
476 app_window_controller_.reset(new AppWindowLauncherController(this)); 478 extension_app_window_controller.reset(
479 new ExtensionAppWindowLauncherController(this));
477 } 480 }
481 app_window_controllers_.push_back(std::move(extension_app_window_controller));
482
483 scoped_ptr<AppWindowLauncherController> arc_app_window_controller;
484 arc_app_window_controller.reset(new ArcAppWindowLauncherController(this));
485 app_window_controllers_.push_back(std::move(arc_app_window_controller));
478 #else 486 #else
479 // Create our v1/v2 application / browser monitors which will inform the 487 // Create our v1/v2 application / browser monitors which will inform the
480 // launcher of status changes. 488 // launcher of status changes.
481 browser_status_monitor_.reset(new BrowserStatusMonitor(this)); 489 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
482 app_window_controller_.reset(new AppWindowLauncherController(this)); 490 scoped_ptr<AppWindowLauncherController> extension_app_window_controller;
491 extension_app_window_controller.reset(
492 new ExtensionAppWindowLauncherController(this));
493 app_window_controllers_.push_back(std::move(extension_app_window_controller));
483 #endif 494 #endif
484 495
485 // Right now ash::Shell isn't created for tests. 496 // Right now ash::Shell isn't created for tests.
486 // TODO(mukai): Allows it to observe display change and write tests. 497 // TODO(mukai): Allows it to observe display change and write tests.
487 if (ash::Shell::HasInstance()) { 498 if (ash::Shell::HasInstance()) {
488 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); 499 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
489 // If it got already set, we remove the observer first again and swap the 500 // If it got already set, we remove the observer first again and swap the
490 // ItemDelegateManager. 501 // ItemDelegateManager.
491 if (item_delegate_manager_) 502 if (item_delegate_manager_)
492 item_delegate_manager_->RemoveObserver(this); 503 item_delegate_manager_->RemoveObserver(this);
493 item_delegate_manager_ = 504 item_delegate_manager_ =
494 ash::Shell::GetInstance()->shelf_item_delegate_manager(); 505 ash::Shell::GetInstance()->shelf_item_delegate_manager();
495 item_delegate_manager_->AddObserver(this); 506 item_delegate_manager_->AddObserver(this);
496 } 507 }
497 } 508 }
498 509
499 ChromeLauncherController::~ChromeLauncherController() { 510 ChromeLauncherController::~ChromeLauncherController() {
500 if (item_delegate_manager_) 511 if (item_delegate_manager_)
501 item_delegate_manager_->RemoveObserver(this); 512 item_delegate_manager_->RemoveObserver(this);
502 513
503 // Reset the BrowserStatusMonitor as it has a weak pointer to this. 514 // Reset the BrowserStatusMonitor as it has a weak pointer to this.
504 browser_status_monitor_.reset(); 515 browser_status_monitor_.reset();
505 516
506 // Reset the app window controller here since it has a weak pointer to this. 517 // Reset the app window controllers here since it has a weak pointer to this.
507 app_window_controller_.reset(); 518 app_window_controllers_.clear();
508 519
509 for (auto iter : shelves_) 520 for (auto iter : shelves_)
510 iter->shelf_layout_manager()->RemoveObserver(this); 521 iter->shelf_layout_manager()->RemoveObserver(this);
511 522
512 model_->RemoveObserver(this); 523 model_->RemoveObserver(this);
513 if (ash::Shell::HasInstance()) 524 if (ash::Shell::HasInstance())
514 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 525 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
515 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); 526 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
516 i != id_to_item_controller_map_.end(); ++i) { 527 i != id_to_item_controller_map_.end(); ++i) {
517 int index = model_->ItemIndexByID(i->first); 528 int index = model_->ItemIndexByID(i->first);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 RememberUnpinnedRunningApplicationOrder(); 1207 RememberUnpinnedRunningApplicationOrder();
1197 // Coming here the default profile is already switched. All profile specific 1208 // Coming here the default profile is already switched. All profile specific
1198 // resources get released and the new profile gets attached instead. 1209 // resources get released and the new profile gets attached instead.
1199 ReleaseProfile(); 1210 ReleaseProfile();
1200 // When coming here, the active user has already be changed so that we can 1211 // When coming here, the active user has already be changed so that we can
1201 // set it as active. 1212 // set it as active.
1202 AttachProfile(ProfileManager::GetActiveUserProfile()); 1213 AttachProfile(ProfileManager::GetActiveUserProfile());
1203 // Update the V1 applications. 1214 // Update the V1 applications.
1204 browser_status_monitor_->ActiveUserChanged(user_email); 1215 browser_status_monitor_->ActiveUserChanged(user_email);
1205 // Switch the running applications to the new user. 1216 // Switch the running applications to the new user.
1206 app_window_controller_->ActiveUserChanged(user_email); 1217 for (auto& controller : app_window_controllers_)
1218 controller->ActiveUserChanged(user_email);
1207 // Update the user specific shell properties from the new user profile. 1219 // Update the user specific shell properties from the new user profile.
1208 UpdateAppLaunchersFromPref(); 1220 UpdateAppLaunchersFromPref();
1209 SetShelfAlignmentFromPrefs(); 1221 SetShelfAlignmentFromPrefs();
1210 SetShelfAutoHideBehaviorFromPrefs(); 1222 SetShelfAutoHideBehaviorFromPrefs();
1211 SetShelfBehaviorsFromPrefs(); 1223 SetShelfBehaviorsFromPrefs();
1212 #if defined(OS_CHROMEOS) 1224 #if defined(OS_CHROMEOS)
1213 SetVirtualKeyboardBehaviorFromPrefs(); 1225 SetVirtualKeyboardBehaviorFromPrefs();
1214 #endif // defined(OS_CHROMEOS) 1226 #endif // defined(OS_CHROMEOS)
1215 // Restore the order of running, but unpinned applications for the activated 1227 // Restore the order of running, but unpinned applications for the activated
1216 // user. 1228 // user.
1217 RestoreUnpinnedRunningApplicationOrder(user_email); 1229 RestoreUnpinnedRunningApplicationOrder(user_email);
1218 // Inform the system tray of the change. 1230 // Inform the system tray of the change.
1219 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged(); 1231 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged();
1220 // Force on-screen keyboard to reset. 1232 // Force on-screen keyboard to reset.
1221 if (keyboard::IsKeyboardEnabled()) 1233 if (keyboard::IsKeyboardEnabled())
1222 ash::Shell::GetInstance()->CreateKeyboard(); 1234 ash::Shell::GetInstance()->CreateKeyboard();
1223 } 1235 }
1224 1236
1225 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { 1237 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) {
1226 // Switch the running applications to the new user. 1238 // Switch the running applications to the new user.
1227 app_window_controller_->AdditionalUserAddedToSession(profile); 1239 for (auto& controller : app_window_controllers_)
1240 controller->AdditionalUserAddedToSession(profile);
1228 } 1241 }
1229 1242
1230 void ChromeLauncherController::OnAppInstalled( 1243 void ChromeLauncherController::OnAppInstalled(
1231 content::BrowserContext* browser_context, 1244 content::BrowserContext* browser_context,
1232 const std::string& app_id) { 1245 const std::string& app_id) {
1233 if (IsAppPinned(app_id)) { 1246 if (IsAppPinned(app_id)) {
1234 // Clear and re-fetch to ensure icon is up-to-date. 1247 // Clear and re-fetch to ensure icon is up-to-date.
1235 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 1248 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
1236 if (app_icon_loader) { 1249 if (app_icon_loader) {
1237 app_icon_loader->ClearImage(app_id); 1250 app_icon_loader->ClearImage(app_id);
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 2241
2229 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( 2242 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
2230 const std::string& app_id) { 2243 const std::string& app_id) {
2231 for (const auto& app_icon_loader : app_icon_loaders_) { 2244 for (const auto& app_icon_loader : app_icon_loaders_) {
2232 if (app_icon_loader->CanLoadImageForApp(app_id)) 2245 if (app_icon_loader->CanLoadImageForApp(app_id))
2233 return app_icon_loader.get(); 2246 return app_icon_loader.get();
2234 } 2247 }
2235 2248
2236 return nullptr; 2249 return nullptr;
2237 } 2250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698