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

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

Issue 2055553004: arc: Support pinned apps across Arc-enabled and Arc-disabled platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "ash/common/shelf/shelf_item_delegate.h" 14 #include "ash/common/shelf/shelf_item_delegate.h"
15 #include "ash/common/shelf/shelf_item_delegate_manager.h" 15 #include "ash/common/shelf/shelf_item_delegate_manager.h"
16 #include "ash/common/shelf/shelf_item_types.h" 16 #include "ash/common/shelf/shelf_item_types.h"
17 #include "ash/common/shelf/shelf_model_observer.h" 17 #include "ash/common/shelf/shelf_model_observer.h"
18 #include "ash/common/shelf/shelf_types.h" 18 #include "ash/common/shelf/shelf_types.h"
19 #include "ash/display/window_tree_host_manager.h" 19 #include "ash/display/window_tree_host_manager.h"
20 #include "ash/shelf/shelf_delegate.h" 20 #include "ash/shelf/shelf_delegate.h"
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/scoped_vector.h" 23 #include "base/memory/scoped_vector.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "chrome/browser/ui/app_icon_loader.h" 25 #include "chrome/browser/ui/app_icon_loader.h"
26 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 26 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
27 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
27 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" 28 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h"
28 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 29 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
29 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" 30 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
30 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" 31 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
31 #include "components/prefs/pref_change_registrar.h" 32 #include "components/prefs/pref_change_registrar.h"
32 #include "components/syncable_prefs/pref_service_syncable_observer.h" 33 #include "components/syncable_prefs/pref_service_syncable_observer.h"
33 #include "extensions/common/constants.h" 34 #include "extensions/common/constants.h"
34 #include "ui/aura/window_observer.h" 35 #include "ui/aura/window_observer.h"
35 36
36 class AppSyncUIState; 37 class AppSyncUIState;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // AppWindowLauncherController. 82 // AppWindowLauncherController.
82 // * Shortcuts have no LauncherItemController. 83 // * Shortcuts have no LauncherItemController.
83 class ChromeLauncherController 84 class ChromeLauncherController
84 : public ash::ShelfDelegate, 85 : public ash::ShelfDelegate,
85 public ash::ShelfModelObserver, 86 public ash::ShelfModelObserver,
86 public ash::WindowTreeHostManager::Observer, 87 public ash::WindowTreeHostManager::Observer,
87 public AppIconLoaderDelegate, 88 public AppIconLoaderDelegate,
88 public syncable_prefs::PrefServiceSyncableObserver, 89 public syncable_prefs::PrefServiceSyncableObserver,
89 public AppSyncUIStateObserver, 90 public AppSyncUIStateObserver,
90 public LauncherAppUpdater::Delegate, 91 public LauncherAppUpdater::Delegate,
91 public ash::ShelfItemDelegateManagerObserver { 92 public ash::ShelfItemDelegateManagerObserver,
93 public app_list::AppListSyncableService::Observer {
92 public: 94 public:
93 // Indicates if a shelf item is incognito or not. 95 // Indicates if a shelf item is incognito or not.
94 enum IncognitoState { 96 enum IncognitoState {
95 STATE_INCOGNITO, 97 STATE_INCOGNITO,
96 STATE_NOT_INCOGNITO, 98 STATE_NOT_INCOGNITO,
97 }; 99 };
98 100
99 // Used to update the state of non plaform apps, as web contents change. 101 // Used to update the state of non plaform apps, as web contents change.
100 enum AppState { 102 enum AppState {
101 APP_STATE_ACTIVE, 103 APP_STATE_ACTIVE,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 virtual bool IsLoggedInAsGuest(); 207 virtual bool IsLoggedInAsGuest();
206 208
207 // Invoked when user clicks on button in the shelf and there is no last 209 // Invoked when user clicks on button in the shelf and there is no last
208 // used window (or CTRL is held with the click). 210 // used window (or CTRL is held with the click).
209 void CreateNewWindow(); 211 void CreateNewWindow();
210 212
211 // Invoked when the user clicks on button in the shelf to create a new 213 // Invoked when the user clicks on button in the shelf to create a new
212 // incognito window. 214 // incognito window.
213 void CreateNewIncognitoWindow(); 215 void CreateNewIncognitoWindow();
214 216
215 // Updates the pinned pref state. The pinned state consists of a list pref. 217 void UpdatePinnedPosition(ash::ShelfID id);
216 // Each item of the list is a dictionary. The key |kAppIDPath| gives the
217 // id of the app.
218 void PersistPinnedState();
219 218
220 // Accessor to the currently loaded profile. Note that in multi profile use 219 // Accessor to the currently loaded profile. Note that in multi profile use
221 // cases this might change over time. 220 // cases this might change over time.
222 Profile* profile(); 221 Profile* profile();
223 222
224 // Notify the controller that the state of an non platform app's tabs 223 // Notify the controller that the state of an non platform app's tabs
225 // have changed, 224 // have changed,
226 void UpdateAppState(content::WebContents* contents, AppState app_state); 225 void UpdateAppState(content::WebContents* contents, AppState app_state);
227 226
228 // Returns ShelfID for |contents|. If |contents| is not an app or is not 227 // Returns ShelfID for |contents|. If |contents| is not an app or is not
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // syncable_prefs::PrefServiceSyncableObserver: 282 // syncable_prefs::PrefServiceSyncableObserver:
284 void OnIsSyncingChanged() override; 283 void OnIsSyncingChanged() override;
285 284
286 // AppSyncUIStateObserver: 285 // AppSyncUIStateObserver:
287 void OnAppSyncUIStatusChanged() override; 286 void OnAppSyncUIStatusChanged() override;
288 287
289 // AppIconLoaderDelegate: 288 // AppIconLoaderDelegate:
290 void OnAppImageUpdated(const std::string& app_id, 289 void OnAppImageUpdated(const std::string& app_id,
291 const gfx::ImageSkia& image) override; 290 const gfx::ImageSkia& image) override;
292 291
292 // app_list::AppListSyncableService::Observer:
293 void OnSyncModelUpdated() override;
294
293 // Called when the active user has changed. 295 // Called when the active user has changed.
294 void ActiveUserChanged(const std::string& user_email); 296 void ActiveUserChanged(const std::string& user_email);
295 297
296 // Called when a user got added to the session. 298 // Called when a user got added to the session.
297 void AdditionalUserAddedToSession(Profile* profile); 299 void AdditionalUserAddedToSession(Profile* profile);
298 300
299 // Get the list of all running incarnations of this item. 301 // Get the list of all running incarnations of this item.
300 // |event_flags| specifies the flags which were set by the event which 302 // |event_flags| specifies the flags which were set by the event which
301 // triggered this menu generation. It can be used to generate different lists. 303 // triggered this menu generation. It can be used to generate different lists.
302 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item, 304 ChromeLauncherAppMenuItems GetApplicationList(const ash::ShelfItem& item,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // Enumerate all Web contents which match a given shortcut |controller|. 453 // Enumerate all Web contents which match a given shortcut |controller|.
452 std::vector<content::WebContents*> GetV1ApplicationsFromController( 454 std::vector<content::WebContents*> GetV1ApplicationsFromController(
453 LauncherItemController* controller); 455 LauncherItemController* controller);
454 456
455 // Create ShelfItem for Browser Shortcut. 457 // Create ShelfItem for Browser Shortcut.
456 ash::ShelfID CreateBrowserShortcutLauncherItem(); 458 ash::ShelfID CreateBrowserShortcutLauncherItem();
457 459
458 // Check if the given |web_contents| is in incognito mode. 460 // Check if the given |web_contents| is in incognito mode.
459 bool IsIncognito(const content::WebContents* web_contents) const; 461 bool IsIncognito(const content::WebContents* web_contents) const;
460 462
461 // Update browser shortcut's index.
462 void PersistChromeItemIndex(int index);
khmel 2016/06/09 21:40:22 No longer used, it position specified by ordinal n
463
464 // Depending on the provided flags, move either the chrome icon, the app icon
465 // or none to the given |target_index|. The provided |chrome_index| and
466 // |app_list_index| locations will get adjusted within this call to finalize
467 // the action and to make sure that the other item can still be moved
468 // afterwards (index adjustments).
469 void MoveChromeOrApplistToFinalPosition(
khmel 2016/06/09 21:40:22 No longer used. App list is always at pos 0 and Ch
470 bool is_chrome,
471 bool is_app_list,
472 int target_index,
473 int* chrome_index,
474 int* app_list_index);
475
476 // Finds the index of where to insert the next item. 463 // Finds the index of where to insert the next item.
477 int FindInsertionPoint(bool is_app_list); 464 int FindInsertionPoint();
478 465
479 // Get the browser shortcut's index in the shelf using the current's systems 466 // Get the browser shortcut's index in the shelf using the current's systems
480 // configuration of pinned and known (but not running) apps. 467 // configuration of pinned and known (but not running) apps.
481 int GetChromeIconIndexForCreation(); 468 int GetChromeIconIndexForCreation();
482 469
483 // Close all windowed V1 applications of a certain extension which was already 470 // Close all windowed V1 applications of a certain extension which was already
484 // deleted. 471 // deleted.
485 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, 472 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id,
486 const Profile* profile); 473 const Profile* profile);
487 474
488 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. 475 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership.
489 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. 476 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|.
490 void SetShelfItemDelegate(ash::ShelfID id, 477 void SetShelfItemDelegate(ash::ShelfID id,
491 ash::ShelfItemDelegate* item_delegate); 478 ash::ShelfItemDelegate* item_delegate);
492 479
493 // Attach to a specific profile. 480 // Attach to a specific profile.
494 void AttachProfile(Profile* proifile); 481 void AttachProfile(Profile* proifile);
495 482
496 // Forget the current profile to allow attaching to a new one. 483 // Forget the current profile to allow attaching to a new one.
497 void ReleaseProfile(); 484 void ReleaseProfile();
498 485
499 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id); 486 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id);
500 487
501 static ChromeLauncherController* instance_; 488 static ChromeLauncherController* instance_;
502 489
503 ash::ShelfModel* model_; 490 ash::ShelfModel* model_;
504 491
505 ash::ShelfItemDelegateManager* item_delegate_manager_; 492 ash::ShelfItemDelegateManager* item_delegate_manager_ = nullptr;
506 493
507 // Profile used for prefs and loading extensions. This is NOT necessarily the 494 // Profile used for prefs and loading extensions. This is NOT necessarily the
508 // profile new windows are created with. 495 // profile new windows are created with.
509 Profile* profile_; 496 Profile* profile_;
510 497
511 // Controller items in this map are owned by |ShelfItemDelegateManager|. 498 // Controller items in this map are owned by |ShelfItemDelegateManager|.
512 IDToItemControllerMap id_to_item_controller_map_; 499 IDToItemControllerMap id_to_item_controller_map_;
513 500
514 // Direct access to app_id for a web contents. 501 // Direct access to app_id for a web contents.
515 WebContentsToAppIDMap web_contents_to_app_id_; 502 WebContentsToAppIDMap web_contents_to_app_id_;
516 503
517 // Used to track app windows. 504 // Used to track app windows.
518 std::vector<std::unique_ptr<AppWindowLauncherController>> 505 std::vector<std::unique_ptr<AppWindowLauncherController>>
519 app_window_controllers_; 506 app_window_controllers_;
520 507
521 // Used to get app info for tabs. 508 // Used to get app info for tabs.
522 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_; 509 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_;
523 510
524 // Used to load the images for app items. 511 // Used to load the images for app items.
525 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; 512 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_;
526 513
527 // Used to handle app load/unload events. 514 // Used to handle app load/unload events.
528 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_; 515 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_;
529 516
530 PrefChangeRegistrar pref_change_registrar_; 517 PrefChangeRegistrar pref_change_registrar_;
531 518
532 AppSyncUIState* app_sync_ui_state_; 519 AppSyncUIState* app_sync_ui_state_ = nullptr;
533 520
534 // The owned browser status monitor. 521 // The owned browser status monitor.
535 std::unique_ptr<BrowserStatusMonitor> browser_status_monitor_; 522 std::unique_ptr<BrowserStatusMonitor> browser_status_monitor_;
536 523
537 // A special observer class to detect user switches. 524 // A special observer class to detect user switches.
538 std::unique_ptr<ChromeLauncherControllerUserSwitchObserver> 525 std::unique_ptr<ChromeLauncherControllerUserSwitchObserver>
539 user_switch_observer_; 526 user_switch_observer_;
540 527
541 std::unique_ptr<ArcAppDeferredLauncherController> arc_deferred_launcher_; 528 std::unique_ptr<ArcAppDeferredLauncherController> arc_deferred_launcher_;
542 529
543 // If true, incoming pinned state changes should be ignored. 530 // If true, incoming pinned state changes should be ignored.
544 bool ignore_persist_pinned_state_change_; 531 bool ignore_persist_pinned_state_change_ = false;
545 532
546 // The list of running & un-pinned applications for different users on hidden 533 // The list of running & un-pinned applications for different users on hidden
547 // desktops. 534 // desktops.
548 typedef std::vector<std::string> RunningAppListIds; 535 typedef std::vector<std::string> RunningAppListIds;
549 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; 536 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap;
550 RunningAppListIdMap last_used_running_application_order_; 537 RunningAppListIdMap last_used_running_application_order_;
551 538
552 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 539 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
553 }; 540 };
554 541
555 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 542 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698