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

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

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for LauncherTest and observing LauncherModel in DelegateManager Created 7 years, 3 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 <set> 10 #include <set>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // windows. Launcher items have a type, an optional app id, and a controller. 68 // windows. Launcher items have a type, an optional app id, and a controller.
69 // This incarnation groups running tabs/windows in application specific lists. 69 // This incarnation groups running tabs/windows in application specific lists.
70 // * Browser app windows have BrowserLauncherItemController, owned by the 70 // * Browser app windows have BrowserLauncherItemController, owned by the
71 // BrowserView instance. 71 // BrowserView instance.
72 // * App shell windows have ShellWindowLauncherItemController, owned by 72 // * App shell windows have ShellWindowLauncherItemController, owned by
73 // ShellWindowLauncherController. 73 // ShellWindowLauncherController.
74 // * Shortcuts have no LauncherItemController. 74 // * Shortcuts have no LauncherItemController.
75 // TODO(simon.hong81): Move LauncherItemDelegate out from 75 // TODO(simon.hong81): Move LauncherItemDelegate out from
76 // ChromeLauncherController and makes separate subclass with it. 76 // ChromeLauncherController and makes separate subclass with it.
77 class ChromeLauncherController : public ash::LauncherDelegate, 77 class ChromeLauncherController : public ash::LauncherDelegate,
78 public ash::LauncherItemDelegate,
79 public ash::LauncherModelObserver, 78 public ash::LauncherModelObserver,
80 public ash::ShellObserver, 79 public ash::ShellObserver,
81 public ash::DisplayController::Observer, 80 public ash::DisplayController::Observer,
82 public content::NotificationObserver, 81 public content::NotificationObserver,
83 public extensions::AppIconLoader::Delegate, 82 public extensions::AppIconLoader::Delegate,
84 public PrefServiceSyncableObserver, 83 public PrefServiceSyncableObserver,
85 public AppSyncUIStateObserver, 84 public AppSyncUIStateObserver,
86 public ExtensionEnableFlowDelegate, 85 public ExtensionEnableFlowDelegate,
87 public ash::ShelfLayoutManagerObserver { 86 public ash::ShelfLayoutManagerObserver {
88 public: 87 public:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; 270 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
272 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE; 271 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE;
273 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE; 272 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE;
274 virtual ash::LauncherID GetLauncherIDForAppID( 273 virtual ash::LauncherID GetLauncherIDForAppID(
275 const std::string& app_id) OVERRIDE; 274 const std::string& app_id) OVERRIDE;
276 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; 275 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE;
277 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; 276 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
278 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; 277 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
279 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; 278 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
280 279
281 // ash::LauncherItemDelegate overrides:
282 virtual void ItemSelected(const ash::LauncherItem& item,
283 const ui::Event& event) OVERRIDE;
284 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE;
285 virtual ui::MenuModel* CreateContextMenu(
286 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE;
287 virtual ash::LauncherMenuModel* CreateApplicationMenu(
288 const ash::LauncherItem& item,
289 int event_flags) OVERRIDE;
290 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
291 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE;
292
293 // ash::LauncherModelObserver overrides: 280 // ash::LauncherModelObserver overrides:
294 virtual void LauncherItemAdded(int index) OVERRIDE; 281 virtual void LauncherItemAdded(int index) OVERRIDE;
295 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 282 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
296 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 283 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
297 virtual void LauncherItemChanged(int index, 284 virtual void LauncherItemChanged(int index,
298 const ash::LauncherItem& old_item) OVERRIDE; 285 const ash::LauncherItem& old_item) OVERRIDE;
299 virtual void LauncherStatusChanged() OVERRIDE; 286 virtual void LauncherStatusChanged() OVERRIDE;
300 287
301 // content::NotificationObserver overrides: 288 // content::NotificationObserver overrides:
302 virtual void Observe(int type, 289 virtual void Observe(int type,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; 344 gfx::Image GetAppListIcon(content::WebContents* web_contents) const;
358 345
359 // Get the title for the applicatoin list entry for |web_contents|. 346 // Get the title for the applicatoin list entry for |web_contents|.
360 // If |web_contents| has not loaded, returns "Net Tab". 347 // If |web_contents| has not loaded, returns "Net Tab".
361 string16 GetAppListTitle(content::WebContents* web_contents) const; 348 string16 GetAppListTitle(content::WebContents* web_contents) const;
362 349
363 // Returns the LauncherItemController of BrowserShortcut. 350 // Returns the LauncherItemController of BrowserShortcut.
364 BrowserShortcutLauncherItemController* 351 BrowserShortcutLauncherItemController*
365 GetBrowserShortcutLauncherItemController(); 352 GetBrowserShortcutLauncherItemController();
366 353
354 LauncherItemController* GetLauncherItemController(const ash::LauncherID id);
355
367 protected: 356 protected:
368 // Creates a new app shortcut item and controller on the launcher at |index|. 357 // Creates a new app shortcut item and controller on the launcher at |index|.
369 // Use kInsertItemAtEnd to add a shortcut as the last item. 358 // Use kInsertItemAtEnd to add a shortcut as the last item.
370 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id, 359 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id,
371 int index); 360 int index);
372 361
373 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. 362 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class.
374 // These are intended for testing. 363 // These are intended for testing.
375 void SetAppTabHelperForTest(AppTabHelper* helper); 364 void SetAppTabHelperForTest(AppTabHelper* helper);
376 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader); 365 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 443
455 // Close all windowed V1 applications of a certain extension which was already 444 // Close all windowed V1 applications of a certain extension which was already
456 // deleted. 445 // deleted.
457 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id); 446 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id);
458 447
459 // Move a launcher item ignoring the pinned state changes from |index| to 448 // Move a launcher item ignoring the pinned state changes from |index| to
460 // |target_index|. 449 // |target_index|.
461 void MoveItemWithoutPinnedStateChangeNotification(int source_index, 450 void MoveItemWithoutPinnedStateChangeNotification(int source_index,
462 int target_index); 451 int target_index);
463 452
464 // Register LauncherItemDelegate. 453 // Register LauncherItemDelegate |item_delegate| for |id|.
465 void RegisterLauncherItemDelegate(); 454 void RegisterLauncherItemDelegate(ash::LauncherID id,
455 ash::LauncherItemDelegate* item_delegate);
456
457 // Update LauncherItemDelegate for |id| with |item_delegate|.
458 void UpdateLauncherItemDelegate(ash::LauncherID id,
459 ash::LauncherItemDelegate* item_delegate);
466 460
467 static ChromeLauncherController* instance_; 461 static ChromeLauncherController* instance_;
468 462
469 ash::LauncherModel* model_; 463 ash::LauncherModel* model_;
470 464
471 // Profile used for prefs and loading extensions. This is NOT necessarily the 465 // Profile used for prefs and loading extensions. This is NOT necessarily the
472 // profile new windows are created with. 466 // profile new windows are created with.
473 Profile* profile_; 467 Profile* profile_;
474 468
475 IDToItemControllerMap id_to_item_controller_map_; 469 IDToItemControllerMap id_to_item_controller_map_;
(...skipping 17 matching lines...) Expand all
493 487
494 PrefChangeRegistrar pref_change_registrar_; 488 PrefChangeRegistrar pref_change_registrar_;
495 489
496 AppSyncUIState* app_sync_ui_state_; 490 AppSyncUIState* app_sync_ui_state_;
497 491
498 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; 492 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
499 493
500 // Launchers that are currently being observed. 494 // Launchers that are currently being observed.
501 std::set<ash::Launcher*> launchers_; 495 std::set<ash::Launcher*> launchers_;
502 496
503 // The owned browser shortcut item.
504 scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_;
505
506 // The owned browser status monitor. 497 // The owned browser status monitor.
507 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; 498 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_;
508 499
509 // If true, incoming pinned state changes should be ignored. 500 // If true, incoming pinned state changes should be ignored.
510 bool ignore_persist_pinned_state_change_; 501 bool ignore_persist_pinned_state_change_;
511 502
512 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 503 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
513 }; 504 };
514 505
515 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 506 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698