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

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

Issue 166903006: Move *ShellWindowLauncher* to *AppWindowLauncher* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed a spot Created 6 years, 10 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 20 matching lines...) Expand all
31 #include "chrome/browser/extensions/extension_util.h" 31 #include "chrome/browser/extensions/extension_util.h"
32 #include "chrome/browser/extensions/launch_util.h" 32 #include "chrome/browser/extensions/launch_util.h"
33 #include "chrome/browser/favicon/favicon_tab_helper.h" 33 #include "chrome/browser/favicon/favicon_tab_helper.h"
34 #include "chrome/browser/prefs/incognito_mode_prefs.h" 34 #include "chrome/browser/prefs/incognito_mode_prefs.h"
35 #include "chrome/browser/prefs/pref_service_syncable.h" 35 #include "chrome/browser/prefs/pref_service_syncable.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
38 #include "chrome/browser/ui/ash/app_sync_ui_state.h" 38 #include "chrome/browser/ui/ash/app_sync_ui_state.h"
39 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 39 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
40 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h " 40 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
41 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
42 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
41 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 43 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
42 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 44 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
43 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 45 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
44 #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_browser.h "
45 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" 47 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
46 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" 48 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
47 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" 49 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h"
48 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 50 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
49 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h"
50 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h "
51 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 51 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
52 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 52 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
53 #include "chrome/browser/ui/browser.h" 53 #include "chrome/browser/ui/browser.h"
54 #include "chrome/browser/ui/browser_commands.h" 54 #include "chrome/browser/ui/browser_commands.h"
55 #include "chrome/browser/ui/browser_finder.h" 55 #include "chrome/browser/ui/browser_finder.h"
56 #include "chrome/browser/ui/browser_list.h" 56 #include "chrome/browser/ui/browser_list.h"
57 #include "chrome/browser/ui/browser_tabstrip.h" 57 #include "chrome/browser/ui/browser_tabstrip.h"
58 #include "chrome/browser/ui/browser_window.h" 58 #include "chrome/browser/ui/browser_window.h"
59 #include "chrome/browser/ui/extensions/application_launch.h" 59 #include "chrome/browser/ui/extensions/application_launch.h"
60 #include "chrome/browser/ui/extensions/extension_enable_flow.h" 60 #include "chrome/browser/ui/extensions/extension_enable_flow.h"
(...skipping 21 matching lines...) Expand all
82 #include "net/base/url_util.h" 82 #include "net/base/url_util.h"
83 #include "ui/aura/root_window.h" 83 #include "ui/aura/root_window.h"
84 #include "ui/aura/window.h" 84 #include "ui/aura/window.h"
85 #include "ui/base/l10n/l10n_util.h" 85 #include "ui/base/l10n/l10n_util.h"
86 #include "ui/views/corewm/window_animations.h" 86 #include "ui/views/corewm/window_animations.h"
87 87
88 #if defined(OS_CHROMEOS) 88 #if defined(OS_CHROMEOS)
89 #include "chrome/browser/browser_process.h" 89 #include "chrome/browser/browser_process.h"
90 #include "chrome/browser/chromeos/login/user_manager.h" 90 #include "chrome/browser/chromeos/login/user_manager.h"
91 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 91 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
92 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h"
92 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" 93 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
93 #include "chrome/browser/ui/ash/launcher/multi_profile_shell_window_launcher_con troller.h"
94 #endif 94 #endif
95 95
96 using extensions::Extension; 96 using extensions::Extension;
97 using extensions::UnloadedExtensionInfo; 97 using extensions::UnloadedExtensionInfo;
98 using extension_misc::kGmailAppId; 98 using extension_misc::kGmailAppId;
99 using content::WebContents; 99 using content::WebContents;
100 100
101 // static 101 // static
102 ChromeLauncherController* ChromeLauncherController::instance_ = NULL; 102 ChromeLauncherController* ChromeLauncherController::instance_ = NULL;
103 103
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 new ChromeLauncherControllerUserSwitchObserverChromeOS(this)); 348 new ChromeLauncherControllerUserSwitchObserverChromeOS(this));
349 } 349 }
350 350
351 // Create our v1/v2 application / browser monitors which will inform the 351 // Create our v1/v2 application / browser monitors which will inform the
352 // launcher of status changes. 352 // launcher of status changes.
353 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 353 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
354 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { 354 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
355 // If running in separated destkop mode, we create the multi profile version 355 // If running in separated destkop mode, we create the multi profile version
356 // of status monitor. 356 // of status monitor.
357 browser_status_monitor_.reset(new MultiProfileBrowserStatusMonitor(this)); 357 browser_status_monitor_.reset(new MultiProfileBrowserStatusMonitor(this));
358 shell_window_controller_.reset( 358 app_window_controller_.reset(
359 new MultiProfileShellWindowLauncherController(this)); 359 new MultiProfileAppWindowLauncherController(this));
360 } else { 360 } else {
361 // Create our v1/v2 application / browser monitors which will inform the 361 // Create our v1/v2 application / browser monitors which will inform the
362 // launcher of status changes. 362 // launcher of status changes.
363 browser_status_monitor_.reset(new BrowserStatusMonitor(this)); 363 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
364 shell_window_controller_.reset(new ShellWindowLauncherController(this)); 364 app_window_controller_.reset(new AppWindowLauncherController(this));
365 } 365 }
366 #else 366 #else
367 // Create our v1/v2 application / browser monitors which will inform the 367 // Create our v1/v2 application / browser monitors which will inform the
368 // launcher of status changes. 368 // launcher of status changes.
369 browser_status_monitor_.reset(new BrowserStatusMonitor(this)); 369 browser_status_monitor_.reset(new BrowserStatusMonitor(this));
370 shell_window_controller_.reset(new ShellWindowLauncherController(this)); 370 app_window_controller_.reset(new AppWindowLauncherController(this));
371 #endif 371 #endif
372 372
373 // Right now ash::Shell isn't created for tests. 373 // Right now ash::Shell isn't created for tests.
374 // TODO(mukai): Allows it to observe display change and write tests. 374 // TODO(mukai): Allows it to observe display change and write tests.
375 if (ash::Shell::HasInstance()) { 375 if (ash::Shell::HasInstance()) {
376 ash::Shell::GetInstance()->display_controller()->AddObserver(this); 376 ash::Shell::GetInstance()->display_controller()->AddObserver(this);
377 item_delegate_manager_ = 377 item_delegate_manager_ =
378 ash::Shell::GetInstance()->shelf_item_delegate_manager(); 378 ash::Shell::GetInstance()->shelf_item_delegate_manager();
379 } 379 }
380 380
381 notification_registrar_.Add(this, 381 notification_registrar_.Add(this,
382 chrome::NOTIFICATION_EXTENSION_LOADED, 382 chrome::NOTIFICATION_EXTENSION_LOADED,
383 content::Source<Profile>(profile_)); 383 content::Source<Profile>(profile_));
384 notification_registrar_.Add(this, 384 notification_registrar_.Add(this,
385 chrome::NOTIFICATION_EXTENSION_UNLOADED, 385 chrome::NOTIFICATION_EXTENSION_UNLOADED,
386 content::Source<Profile>(profile_)); 386 content::Source<Profile>(profile_));
387 } 387 }
388 388
389 ChromeLauncherController::~ChromeLauncherController() { 389 ChromeLauncherController::~ChromeLauncherController() {
390 // Reset the BrowserStatusMonitor as it has a weak pointer to this. 390 // Reset the BrowserStatusMonitor as it has a weak pointer to this.
391 browser_status_monitor_.reset(); 391 browser_status_monitor_.reset();
392 392
393 // Reset the shell window controller here since it has a weak pointer to this. 393 // Reset the app window controller here since it has a weak pointer to this.
394 shell_window_controller_.reset(); 394 app_window_controller_.reset();
395 395
396 for (std::set<ash::Shelf*>::iterator iter = shelves_.begin(); 396 for (std::set<ash::Shelf*>::iterator iter = shelves_.begin();
397 iter != shelves_.end(); 397 iter != shelves_.end();
398 ++iter) 398 ++iter)
399 (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this); 399 (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this);
400 400
401 model_->RemoveObserver(this); 401 model_->RemoveObserver(this);
402 if (ash::Shell::HasInstance()) 402 if (ash::Shell::HasInstance())
403 ash::Shell::GetInstance()->display_controller()->RemoveObserver(this); 403 ash::Shell::GetInstance()->display_controller()->RemoveObserver(this);
404 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); 404 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 RememberUnpinnedRunningApplicationOrder(); 1124 RememberUnpinnedRunningApplicationOrder();
1125 // Coming here the default profile is already switched. All profile specific 1125 // Coming here the default profile is already switched. All profile specific
1126 // resources get released and the new profile gets attached instead. 1126 // resources get released and the new profile gets attached instead.
1127 ReleaseProfile(); 1127 ReleaseProfile();
1128 // When coming here, the active user has already be changed so that we can 1128 // When coming here, the active user has already be changed so that we can
1129 // set it as active. 1129 // set it as active.
1130 AttachProfile(ProfileManager::GetActiveUserProfile()); 1130 AttachProfile(ProfileManager::GetActiveUserProfile());
1131 // Update the V1 applications. 1131 // Update the V1 applications.
1132 browser_status_monitor_->ActiveUserChanged(user_email); 1132 browser_status_monitor_->ActiveUserChanged(user_email);
1133 // Switch the running applications to the new user. 1133 // Switch the running applications to the new user.
1134 shell_window_controller_->ActiveUserChanged(user_email); 1134 app_window_controller_->ActiveUserChanged(user_email);
1135 // Update the user specific shell properties from the new user profile. 1135 // Update the user specific shell properties from the new user profile.
1136 UpdateAppLaunchersFromPref(); 1136 UpdateAppLaunchersFromPref();
1137 SetShelfAlignmentFromPrefs(); 1137 SetShelfAlignmentFromPrefs();
1138 SetShelfAutoHideBehaviorFromPrefs(); 1138 SetShelfAutoHideBehaviorFromPrefs();
1139 SetShelfBehaviorsFromPrefs(); 1139 SetShelfBehaviorsFromPrefs();
1140 // Restore the order of running, but unpinned applications for the activated 1140 // Restore the order of running, but unpinned applications for the activated
1141 // user. 1141 // user.
1142 RestoreUnpinnedRunningApplicationOrder(user_email); 1142 RestoreUnpinnedRunningApplicationOrder(user_email);
1143 // Inform the system tray of the change. 1143 // Inform the system tray of the change.
1144 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged(); 1144 ash::Shell::GetInstance()->system_tray_delegate()->ActiveUserWasChanged();
1145 } 1145 }
1146 1146
1147 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) { 1147 void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) {
1148 // Switch the running applications to the new user. 1148 // Switch the running applications to the new user.
1149 shell_window_controller_->AdditionalUserAddedToSession(profile); 1149 app_window_controller_->AdditionalUserAddedToSession(profile);
1150 } 1150 }
1151 1151
1152 void ChromeLauncherController::Observe( 1152 void ChromeLauncherController::Observe(
1153 int type, 1153 int type,
1154 const content::NotificationSource& source, 1154 const content::NotificationSource& source,
1155 const content::NotificationDetails& details) { 1155 const content::NotificationDetails& details) {
1156 switch (type) { 1156 switch (type) {
1157 case chrome::NOTIFICATION_EXTENSION_LOADED: { 1157 case chrome::NOTIFICATION_EXTENSION_LOADED: {
1158 const Extension* extension = 1158 const Extension* extension =
1159 content::Details<const Extension>(details).ptr(); 1159 content::Details<const Extension>(details).ptr();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 } 1279 }
1280 return std::vector<content::WebContents*>(); 1280 return std::vector<content::WebContents*>();
1281 } 1281 }
1282 1282
1283 void ChromeLauncherController::ActivateShellApp(const std::string& app_id, 1283 void ChromeLauncherController::ActivateShellApp(const std::string& app_id,
1284 int index) { 1284 int index) {
1285 ash::ShelfID id = GetShelfIDForAppID(app_id); 1285 ash::ShelfID id = GetShelfIDForAppID(app_id);
1286 if (id) { 1286 if (id) {
1287 LauncherItemController* controller = id_to_item_controller_map_[id]; 1287 LauncherItemController* controller = id_to_item_controller_map_[id];
1288 if (controller->type() == LauncherItemController::TYPE_APP) { 1288 if (controller->type() == LauncherItemController::TYPE_APP) {
1289 ShellWindowLauncherItemController* shell_window_controller = 1289 AppWindowLauncherItemController* app_window_controller =
1290 static_cast<ShellWindowLauncherItemController*>(controller); 1290 static_cast<AppWindowLauncherItemController*>(controller);
1291 shell_window_controller->ActivateIndexedApp(index); 1291 app_window_controller->ActivateIndexedApp(index);
1292 } 1292 }
1293 } 1293 }
1294 } 1294 }
1295 1295
1296 bool ChromeLauncherController::IsWebContentHandledByApplication( 1296 bool ChromeLauncherController::IsWebContentHandledByApplication(
1297 content::WebContents* web_contents, 1297 content::WebContents* web_contents,
1298 const std::string& app_id) { 1298 const std::string& app_id) {
1299 if ((web_contents_to_app_id_.find(web_contents) != 1299 if ((web_contents_to_app_id_.find(web_contents) !=
1300 web_contents_to_app_id_.end()) && 1300 web_contents_to_app_id_.end()) &&
1301 (web_contents_to_app_id_[web_contents] == app_id)) 1301 (web_contents_to_app_id_[web_contents] == app_id))
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 } 2058 }
2059 2059
2060 void ChromeLauncherController::ReleaseProfile() { 2060 void ChromeLauncherController::ReleaseProfile() {
2061 if (app_sync_ui_state_) 2061 if (app_sync_ui_state_)
2062 app_sync_ui_state_->RemoveObserver(this); 2062 app_sync_ui_state_->RemoveObserver(this);
2063 2063
2064 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); 2064 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this);
2065 2065
2066 pref_change_registrar_.RemoveAll(); 2066 pref_change_registrar_.RemoveAll();
2067 } 2067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698