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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.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: chrome_mash_shelf_controller.cc update due namespace renaming 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_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/common/shelf/shelf_item_delegate_manager.h" 11 #include "ash/common/shelf/shelf_item_delegate_manager.h"
12 #include "ash/common/shelf/shelf_model_observer.h" 12 #include "ash/common/shelf/shelf_model_observer.h"
13 #include "ash/common/shelf/shelf_types.h" 13 #include "ash/common/shelf/shelf_types.h"
14 #include "ash/display/window_tree_host_manager.h" 14 #include "ash/display/window_tree_host_manager.h"
15 #include "ash/shelf/shelf_delegate.h" 15 #include "ash/shelf/shelf_delegate.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/ui/app_icon_loader.h" 19 #include "chrome/browser/ui/app_icon_loader.h"
20 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
20 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" 21 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h"
21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
22 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" 23 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
23 #include "components/prefs/pref_change_registrar.h" 24 #include "components/prefs/pref_change_registrar.h"
24 #include "ui/aura/window_observer.h" 25 #include "ui/aura/window_observer.h"
25 26
26 class AppSyncUIState; 27 class AppSyncUIState;
27 class BrowserStatusMonitor; 28 class BrowserStatusMonitor;
28 class LauncherControllerHelper; 29 class LauncherControllerHelper;
29 class Profile; 30 class Profile;
30 class AppWindowLauncherController; 31 class AppWindowLauncherController;
31 class TabContents; 32 class TabContents;
32 33
33 namespace ash { 34 namespace ash {
34 class ChromeLauncherPrefsObserver;
35 class ShelfItemDelegateManager; 35 class ShelfItemDelegateManager;
36 class ShelfModel; 36 class ShelfModel;
37 namespace launcher {
38 class ChromeLauncherPrefsObserver;
39 }
37 } 40 }
38 41
39 namespace aura { 42 namespace aura {
40 class Window; 43 class Window;
41 } 44 }
42 45
43 namespace content { 46 namespace content {
44 class BrowserContext; 47 class BrowserContext;
45 } 48 }
46 49
47 namespace extensions { 50 namespace extensions {
48 class Extension; 51 class Extension;
49 } 52 }
50 53
51 class ChromeLauncherControllerUserSwitchObserver; 54 class ChromeLauncherControllerUserSwitchObserver;
52 55
53 // Implementation of ChromeLauncherController, used for classic Ash. 56 // Implementation of ChromeLauncherController, used for classic Ash.
54 // In addition to implementing ChromeLauncherController, this class performs 57 // In addition to implementing ChromeLauncherController, this class performs
55 // a lot of other responsibilities, such as implementing ash::ShelfDelegate, 58 // a lot of other responsibilities, such as implementing ash::ShelfDelegate,
56 // updating the UI state and the shelf model when apps are uninstalled, etc. 59 // updating the UI state and the shelf model when apps are uninstalled, etc.
57 class ChromeLauncherControllerImpl 60 class ChromeLauncherControllerImpl
58 : public ChromeLauncherController, 61 : public ChromeLauncherController,
59 public ash::ShelfDelegate, 62 public ash::ShelfDelegate,
60 public LauncherAppUpdater::Delegate, 63 public LauncherAppUpdater::Delegate,
61 private ash::ShelfModelObserver, 64 private ash::ShelfModelObserver,
62 private ash::WindowTreeHostManager::Observer, 65 private ash::WindowTreeHostManager::Observer,
63 private AppIconLoaderDelegate, 66 private AppIconLoaderDelegate,
64 private AppSyncUIStateObserver, 67 private AppSyncUIStateObserver,
65 private ash::ShelfItemDelegateManagerObserver { 68 private ash::ShelfItemDelegateManagerObserver,
69 private app_list::AppListSyncableService::Observer {
66 public: 70 public:
67 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model); 71 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model);
68 ~ChromeLauncherControllerImpl() override; 72 ~ChromeLauncherControllerImpl() override;
69 73
70 // Create ChromeLauncherControllerImpl instance and set is as the 74 // Create ChromeLauncherControllerImpl instance and set is as the
71 // ChromeLauncherController singleton. 75 // ChromeLauncherController singleton.
72 static ChromeLauncherControllerImpl* CreateInstance(Profile* profile, 76 static ChromeLauncherControllerImpl* CreateInstance(Profile* profile,
73 ash::ShelfModel* model); 77 ash::ShelfModel* model);
74 78
75 // ChromeLauncherController: 79 // ChromeLauncherController:
(...skipping 21 matching lines...) Expand all
97 int event_flags) override; 101 int event_flags) override;
98 void ActivateApp(const std::string& app_id, 102 void ActivateApp(const std::string& app_id,
99 ash::LaunchSource source, 103 ash::LaunchSource source,
100 int event_flags) override; 104 int event_flags) override;
101 extensions::LaunchType GetLaunchType(ash::ShelfID id) override; 105 extensions::LaunchType GetLaunchType(ash::ShelfID id) override;
102 void SetLauncherItemImage(ash::ShelfID shelf_id, 106 void SetLauncherItemImage(ash::ShelfID shelf_id,
103 const gfx::ImageSkia& image) override; 107 const gfx::ImageSkia& image) override;
104 bool IsWindowedAppInLauncher(const std::string& app_id) override; 108 bool IsWindowedAppInLauncher(const std::string& app_id) override;
105 void SetLaunchType(ash::ShelfID id, 109 void SetLaunchType(ash::ShelfID id,
106 extensions::LaunchType launch_type) override; 110 extensions::LaunchType launch_type) override;
107 void PersistPinnedState() override;
108 Profile* GetProfile() override; 111 Profile* GetProfile() override;
109 void UpdateAppState(content::WebContents* contents, 112 void UpdateAppState(content::WebContents* contents,
110 AppState app_state) override; 113 AppState app_state) override;
111 ash::ShelfID GetShelfIDForWebContents( 114 ash::ShelfID GetShelfIDForWebContents(
112 content::WebContents* contents) override; 115 content::WebContents* contents) override;
113 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url) override; 116 void SetRefocusURLPatternForTest(ash::ShelfID id, const GURL& url) override;
114 const extensions::Extension* GetExtensionForAppID( 117 const extensions::Extension* GetExtensionForAppID(
115 const std::string& app_id) const override; 118 const std::string& app_id) const override;
116 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive( 119 ash::ShelfItemDelegate::PerformedAction ActivateWindowOrMinimizeIfActive(
117 ui::BaseWindow* window, 120 ui::BaseWindow* window,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 228
226 // Pin a running app with |shelf_id| internally to |index|. It returns 229 // Pin a running app with |shelf_id| internally to |index|. It returns
227 // the index where the item was pinned. 230 // the index where the item was pinned.
228 int PinRunningAppInternal(int index, ash::ShelfID shelf_id); 231 int PinRunningAppInternal(int index, ash::ShelfID shelf_id);
229 232
230 // Unpin a locked application. This is an internal call which converts the 233 // Unpin a locked application. This is an internal call which converts the
231 // model type of the given app index from a shortcut into an unpinned running 234 // model type of the given app index from a shortcut into an unpinned running
232 // app. 235 // app.
233 void UnpinRunningAppInternal(int index); 236 void UnpinRunningAppInternal(int index);
234 237
235 // Re-syncs shelf model with prefs::kPinnedLauncherApps. 238 // Updates pin position for the item specified by |id| in sync model.
239 void SyncPinPosition(ash::ShelfID id);
240
241 // Re-syncs shelf model.
236 void UpdateAppLaunchersFromPref(); 242 void UpdateAppLaunchersFromPref();
237 243
238 // Sets the shelf auto-hide behavior from prefs. 244 // Sets the shelf auto-hide behavior from prefs.
239 void SetShelfAutoHideBehaviorFromPrefs(); 245 void SetShelfAutoHideBehaviorFromPrefs();
240 246
241 // Sets the shelf alignment from prefs. 247 // Sets the shelf alignment from prefs.
242 void SetShelfAlignmentFromPrefs(); 248 void SetShelfAlignmentFromPrefs();
243 249
244 // Sets both of auto-hide behavior and alignment from prefs. 250 // Sets both of auto-hide behavior and alignment from prefs.
245 void SetShelfBehaviorsFromPrefs(); 251 void SetShelfBehaviorsFromPrefs();
(...skipping 18 matching lines...) Expand all
264 // Enumerate all Web contents which match a given shortcut |controller|. 270 // Enumerate all Web contents which match a given shortcut |controller|.
265 std::vector<content::WebContents*> GetV1ApplicationsFromController( 271 std::vector<content::WebContents*> GetV1ApplicationsFromController(
266 LauncherItemController* controller); 272 LauncherItemController* controller);
267 273
268 // Create ShelfItem for Browser Shortcut. 274 // Create ShelfItem for Browser Shortcut.
269 ash::ShelfID CreateBrowserShortcutLauncherItem(); 275 ash::ShelfID CreateBrowserShortcutLauncherItem();
270 276
271 // Check if the given |web_contents| is in incognito mode. 277 // Check if the given |web_contents| is in incognito mode.
272 bool IsIncognito(const content::WebContents* web_contents) const; 278 bool IsIncognito(const content::WebContents* web_contents) const;
273 279
274 // Update browser shortcut's index.
275 void PersistChromeItemIndex(int index);
276
277 // Depending on the provided flags, move either the chrome icon, the app icon
278 // or none to the given |target_index|. The provided |chrome_index| and
279 // |app_list_index| locations will get adjusted within this call to finalize
280 // the action and to make sure that the other item can still be moved
281 // afterwards (index adjustments).
282 void MoveChromeOrApplistToFinalPosition(bool is_chrome,
283 bool is_app_list,
284 int target_index,
285 int* chrome_index,
286 int* app_list_index);
287
288 // Finds the index of where to insert the next item. 280 // Finds the index of where to insert the next item.
289 int FindInsertionPoint(bool is_app_list); 281 int FindInsertionPoint();
290
291 // Get the browser shortcut's index in the shelf using the current's systems
292 // configuration of pinned and known (but not running) apps.
293 int GetChromeIconIndexForCreation();
294 282
295 // Close all windowed V1 applications of a certain extension which was already 283 // Close all windowed V1 applications of a certain extension which was already
296 // deleted. 284 // deleted.
297 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id, 285 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id,
298 const Profile* profile); 286 const Profile* profile);
299 287
300 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership. 288 // Set ShelfItemDelegate |item_delegate| for |id| and take an ownership.
301 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. 289 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|.
302 void SetShelfItemDelegate(ash::ShelfID id, 290 void SetShelfItemDelegate(ash::ShelfID id,
303 ash::ShelfItemDelegate* item_delegate); 291 ash::ShelfItemDelegate* item_delegate);
(...skipping 19 matching lines...) Expand all
323 // ash::WindowTreeHostManager::Observer: 311 // ash::WindowTreeHostManager::Observer:
324 void OnDisplayConfigurationChanged() override; 312 void OnDisplayConfigurationChanged() override;
325 313
326 // AppSyncUIStateObserver: 314 // AppSyncUIStateObserver:
327 void OnAppSyncUIStatusChanged() override; 315 void OnAppSyncUIStatusChanged() override;
328 316
329 // AppIconLoaderDelegate: 317 // AppIconLoaderDelegate:
330 void OnAppImageUpdated(const std::string& app_id, 318 void OnAppImageUpdated(const std::string& app_id,
331 const gfx::ImageSkia& image) override; 319 const gfx::ImageSkia& image) override;
332 320
321 // app_list::AppListSyncableService::Observer:
322 void OnSyncModelUpdated() override;
323
333 ash::ShelfModel* model_; 324 ash::ShelfModel* model_;
334 325
335 ash::ShelfItemDelegateManager* item_delegate_manager_; 326 ash::ShelfItemDelegateManager* item_delegate_manager_ = nullptr;
336 327
337 // Profile used for prefs and loading extensions. This is NOT necessarily the 328 // Profile used for prefs and loading extensions. This is NOT necessarily the
338 // profile new windows are created with. 329 // profile new windows are created with.
339 Profile* profile_; 330 Profile* profile_;
340 331
341 // Controller items in this map are owned by |ShelfItemDelegateManager|. 332 // Controller items in this map are owned by |ShelfItemDelegateManager|.
342 IDToItemControllerMap id_to_item_controller_map_; 333 IDToItemControllerMap id_to_item_controller_map_;
343 334
344 // Direct access to app_id for a web contents. 335 // Direct access to app_id for a web contents.
345 WebContentsToAppIDMap web_contents_to_app_id_; 336 WebContentsToAppIDMap web_contents_to_app_id_;
346 337
347 // Used to track app windows. 338 // Used to track app windows.
348 std::vector<std::unique_ptr<AppWindowLauncherController>> 339 std::vector<std::unique_ptr<AppWindowLauncherController>>
349 app_window_controllers_; 340 app_window_controllers_;
350 341
351 // Used to get app info for tabs. 342 // Used to get app info for tabs.
352 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_; 343 std::unique_ptr<LauncherControllerHelper> launcher_controller_helper_;
353 344
354 // Used to load the images for app items. 345 // Used to load the images for app items.
355 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; 346 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_;
356 347
357 // Used to handle app load/unload events. 348 // Used to handle app load/unload events.
358 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_; 349 std::vector<std::unique_ptr<LauncherAppUpdater>> app_updaters_;
359 350
360 PrefChangeRegistrar pref_change_registrar_; 351 PrefChangeRegistrar pref_change_registrar_;
361 352
362 AppSyncUIState* app_sync_ui_state_; 353 AppSyncUIState* app_sync_ui_state_ = nullptr;
363 354
364 // The owned browser status monitor. 355 // The owned browser status monitor.
365 std::unique_ptr<BrowserStatusMonitor> browser_status_monitor_; 356 std::unique_ptr<BrowserStatusMonitor> browser_status_monitor_;
366 357
367 // A special observer class to detect user switches. 358 // A special observer class to detect user switches.
368 std::unique_ptr<ChromeLauncherControllerUserSwitchObserver> 359 std::unique_ptr<ChromeLauncherControllerUserSwitchObserver>
369 user_switch_observer_; 360 user_switch_observer_;
370 361
371 std::unique_ptr<ash::ChromeLauncherPrefsObserver> prefs_observer_; 362 std::unique_ptr<ash::launcher::ChromeLauncherPrefsObserver> prefs_observer_;
372 363
373 std::unique_ptr<ArcAppDeferredLauncherController> arc_deferred_launcher_; 364 std::unique_ptr<ArcAppDeferredLauncherController> arc_deferred_launcher_;
374 365
375 // If true, incoming pinned state changes should be ignored. 366 // If true, incoming pinned state changes should be ignored.
376 bool ignore_persist_pinned_state_change_; 367 bool ignore_persist_pinned_state_change_ = false;
377 368
378 // The list of running & un-pinned applications for different users on hidden 369 // The list of running & un-pinned applications for different users on hidden
379 // desktops. 370 // desktops.
380 typedef std::vector<std::string> RunningAppListIds; 371 typedef std::vector<std::string> RunningAppListIds;
381 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; 372 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap;
382 RunningAppListIdMap last_used_running_application_order_; 373 RunningAppListIdMap last_used_running_application_order_;
383 374
384 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl); 375 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl);
385 }; 376 };
386 377
387 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ 378 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698