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

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

Issue 25716004: Revert 226547 "Refactor LauncherItemController and LauncherItemD..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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 #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 28 matching lines...) Expand all
39 class BrowserShortcutLauncherItemController; 39 class BrowserShortcutLauncherItemController;
40 class BrowserStatusMonitor; 40 class BrowserStatusMonitor;
41 class ExtensionEnableFlow; 41 class ExtensionEnableFlow;
42 class GURL; 42 class GURL;
43 class LauncherItemController; 43 class LauncherItemController;
44 class Profile; 44 class Profile;
45 class ShellWindowLauncherController; 45 class ShellWindowLauncherController;
46 class TabContents; 46 class TabContents;
47 47
48 namespace ash { 48 namespace ash {
49 class LauncherItemDelegateManager;
50 class LauncherModel; 49 class LauncherModel;
51 } 50 }
52 51
53 namespace aura { 52 namespace aura {
54 class Window; 53 class Window;
55 } 54 }
56 55
57 namespace content { 56 namespace content {
58 class NotificationRegistrar; 57 class NotificationRegistrar;
59 class WebContents; 58 class WebContents;
(...skipping 19 matching lines...) Expand all
79 }; 78 };
80 79
81 // ChromeLauncherController manages the launcher items needed for content 80 // ChromeLauncherController manages the launcher items needed for content
82 // windows. Launcher items have a type, an optional app id, and a controller. 81 // windows. Launcher items have a type, an optional app id, and a controller.
83 // This incarnation groups running tabs/windows in application specific lists. 82 // This incarnation groups running tabs/windows in application specific lists.
84 // * Browser app windows have BrowserLauncherItemController, owned by the 83 // * Browser app windows have BrowserLauncherItemController, owned by the
85 // BrowserView instance. 84 // BrowserView instance.
86 // * App shell windows have ShellWindowLauncherItemController, owned by 85 // * App shell windows have ShellWindowLauncherItemController, owned by
87 // ShellWindowLauncherController. 86 // ShellWindowLauncherController.
88 // * Shortcuts have no LauncherItemController. 87 // * Shortcuts have no LauncherItemController.
88 // TODO(simon.hong81): Move LauncherItemDelegate out from
89 // ChromeLauncherController and makes separate subclass with it.
89 class ChromeLauncherController : public ash::LauncherDelegate, 90 class ChromeLauncherController : public ash::LauncherDelegate,
91 public ash::LauncherItemDelegate,
90 public ash::LauncherModelObserver, 92 public ash::LauncherModelObserver,
91 public ash::ShellObserver, 93 public ash::ShellObserver,
92 public ash::DisplayController::Observer, 94 public ash::DisplayController::Observer,
93 public content::NotificationObserver, 95 public content::NotificationObserver,
94 public extensions::AppIconLoader::Delegate, 96 public extensions::AppIconLoader::Delegate,
95 public PrefServiceSyncableObserver, 97 public PrefServiceSyncableObserver,
96 public AppSyncUIStateObserver, 98 public AppSyncUIStateObserver,
97 public ExtensionEnableFlowDelegate, 99 public ExtensionEnableFlowDelegate,
98 public ash::ShelfLayoutManagerObserver { 100 public ash::ShelfLayoutManagerObserver {
99 public: 101 public:
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE; 289 virtual void OnLauncherCreated(ash::Launcher* launcher) OVERRIDE;
288 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE; 290 virtual void OnLauncherDestroyed(ash::Launcher* launcher) OVERRIDE;
289 virtual ash::LauncherID GetLauncherIDForAppID( 291 virtual ash::LauncherID GetLauncherIDForAppID(
290 const std::string& app_id) OVERRIDE; 292 const std::string& app_id) OVERRIDE;
291 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE; 293 virtual const std::string& GetAppIDForLauncherID(ash::LauncherID id) OVERRIDE;
292 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; 294 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
293 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; 295 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
294 virtual bool CanPin() const OVERRIDE; 296 virtual bool CanPin() const OVERRIDE;
295 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; 297 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
296 298
299 // ash::LauncherItemDelegate overrides:
300 virtual void ItemSelected(const ash::LauncherItem& item,
301 const ui::Event& event) OVERRIDE;
302 virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE;
303 virtual ui::MenuModel* CreateContextMenu(
304 const ash::LauncherItem& item, aura::RootWindow* root) OVERRIDE;
305 virtual ash::LauncherMenuModel* CreateApplicationMenu(
306 const ash::LauncherItem& item,
307 int event_flags) OVERRIDE;
308 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
309 virtual bool ShouldShowTooltip(const ash::LauncherItem& item) OVERRIDE;
310
297 // ash::LauncherModelObserver overrides: 311 // ash::LauncherModelObserver overrides:
298 virtual void LauncherItemAdded(int index) OVERRIDE; 312 virtual void LauncherItemAdded(int index) OVERRIDE;
299 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE; 313 virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE;
300 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; 314 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
301 virtual void LauncherItemChanged(int index, 315 virtual void LauncherItemChanged(int index,
302 const ash::LauncherItem& old_item) OVERRIDE; 316 const ash::LauncherItem& old_item) OVERRIDE;
303 virtual void LauncherStatusChanged() OVERRIDE; 317 virtual void LauncherStatusChanged() OVERRIDE;
304 318
305 // content::NotificationObserver overrides: 319 // content::NotificationObserver overrides:
306 virtual void Observe(int type, 320 virtual void Observe(int type,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 gfx::Image GetAppListIcon(content::WebContents* web_contents) const; 378 gfx::Image GetAppListIcon(content::WebContents* web_contents) const;
365 379
366 // Get the title for the applicatoin list entry for |web_contents|. 380 // Get the title for the applicatoin list entry for |web_contents|.
367 // If |web_contents| has not loaded, returns "Net Tab". 381 // If |web_contents| has not loaded, returns "Net Tab".
368 string16 GetAppListTitle(content::WebContents* web_contents) const; 382 string16 GetAppListTitle(content::WebContents* web_contents) const;
369 383
370 // Returns the LauncherItemController of BrowserShortcut. 384 // Returns the LauncherItemController of BrowserShortcut.
371 BrowserShortcutLauncherItemController* 385 BrowserShortcutLauncherItemController*
372 GetBrowserShortcutLauncherItemController(); 386 GetBrowserShortcutLauncherItemController();
373 387
374 LauncherItemController* GetLauncherItemController(const ash::LauncherID id);
375
376 protected: 388 protected:
377 // Creates a new app shortcut item and controller on the launcher at |index|. 389 // Creates a new app shortcut item and controller on the launcher at |index|.
378 // Use kInsertItemAtEnd to add a shortcut as the last item. 390 // Use kInsertItemAtEnd to add a shortcut as the last item.
379 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id, 391 ash::LauncherID CreateAppShortcutLauncherItem(const std::string& app_id,
380 int index); 392 int index);
381 393
382 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class. 394 // Sets the AppTabHelper/AppIconLoader, taking ownership of the helper class.
383 // These are intended for testing. 395 // These are intended for testing.
384 void SetAppTabHelperForTest(AppTabHelper* helper); 396 void SetAppTabHelperForTest(AppTabHelper* helper);
385 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader); 397 void SetAppIconLoaderForTest(extensions::AppIconLoader* loader);
386 const std::string& GetAppIdFromLauncherIdForTest(ash::LauncherID id); 398 const std::string& GetAppIdFromLauncherIdForTest(ash::LauncherID id);
387 399
388 // Sets the ash::LauncherItemDelegateManager only for unittests and doesn't
389 // take an ownership of it.
390 void SetLauncherItemDelegateManagerForTest(
391 ash::LauncherItemDelegateManager* manager);
392
393 private: 400 private:
394 friend class ChromeLauncherControllerTest; 401 friend class ChromeLauncherControllerTest;
395 friend class LauncherAppBrowserTest; 402 friend class LauncherAppBrowserTest;
396 friend class LauncherPlatformAppBrowserTest; 403 friend class LauncherPlatformAppBrowserTest;
397 404
398 typedef std::map<ash::LauncherID, LauncherItemController*> 405 typedef std::map<ash::LauncherID, LauncherItemController*>
399 IDToItemControllerMap; 406 IDToItemControllerMap;
400 typedef std::list<content::WebContents*> WebContentsList; 407 typedef std::list<content::WebContents*> WebContentsList;
401 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap; 408 typedef std::map<std::string, WebContentsList> AppIDToWebContentsListMap;
402 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; 409 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // configuration of pinned and known (but not running) apps. 501 // configuration of pinned and known (but not running) apps.
495 int GetChromeIconIndexForCreation(); 502 int GetChromeIconIndexForCreation();
496 503
497 // Get the list of pinned programs from the preferences. 504 // Get the list of pinned programs from the preferences.
498 std::vector<std::string> GetListOfPinnedAppsAndBrowser(); 505 std::vector<std::string> GetListOfPinnedAppsAndBrowser();
499 506
500 // Close all windowed V1 applications of a certain extension which was already 507 // Close all windowed V1 applications of a certain extension which was already
501 // deleted. 508 // deleted.
502 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id); 509 void CloseWindowedAppsFromRemovedExtension(const std::string& app_id);
503 510
504 // Set LauncherItemDelegate |item_delegate| for |id| and take an ownership. 511 // Register LauncherItemDelegate.
505 // TODO(simon.hong81): Make this take a scoped_ptr of |item_delegate|. 512 void RegisterLauncherItemDelegate();
506 void SetLauncherItemDelegate(ash::LauncherID id,
507 ash::LauncherItemDelegate* item_delegate);
508 513
509 // Attach to a specific profile. 514 // Attach to a specific profile.
510 void AttachProfile(Profile* proifile); 515 void AttachProfile(Profile* proifile);
511 516
512 // Forget the current profile to allow attaching to a new one. 517 // Forget the current profile to allow attaching to a new one.
513 void ReleaseProfile(); 518 void ReleaseProfile();
514 519
515 static ChromeLauncherController* instance_; 520 static ChromeLauncherController* instance_;
516 521
517 ash::LauncherModel* model_; 522 ash::LauncherModel* model_;
518 523
519 ash::LauncherItemDelegateManager* item_delegate_manager_;
520
521 // Profile used for prefs and loading extensions. This is NOT necessarily the 524 // Profile used for prefs and loading extensions. This is NOT necessarily the
522 // profile new windows are created with. 525 // profile new windows are created with.
523 Profile* profile_; 526 Profile* profile_;
524 527
525 IDToItemControllerMap id_to_item_controller_map_; 528 IDToItemControllerMap id_to_item_controller_map_;
526 529
527 // Maintains activation order of web contents for each app. 530 // Maintains activation order of web contents for each app.
528 AppIDToWebContentsListMap app_id_to_web_contents_list_; 531 AppIDToWebContentsListMap app_id_to_web_contents_list_;
529 532
530 // Direct access to app_id for a web contents. 533 // Direct access to app_id for a web contents.
(...skipping 12 matching lines...) Expand all
543 546
544 PrefChangeRegistrar pref_change_registrar_; 547 PrefChangeRegistrar pref_change_registrar_;
545 548
546 AppSyncUIState* app_sync_ui_state_; 549 AppSyncUIState* app_sync_ui_state_;
547 550
548 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; 551 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
549 552
550 // Launchers that are currently being observed. 553 // Launchers that are currently being observed.
551 std::set<ash::Launcher*> launchers_; 554 std::set<ash::Launcher*> launchers_;
552 555
556 // The owned browser shortcut item.
557 scoped_ptr<BrowserShortcutLauncherItemController> browser_item_controller_;
558
553 // The owned browser status monitor. 559 // The owned browser status monitor.
554 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_; 560 scoped_ptr<BrowserStatusMonitor> browser_status_monitor_;
555 561
556 // A special observer class to detect user switches. 562 // A special observer class to detect user switches.
557 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_; 563 scoped_ptr<ChromeLauncherControllerUserSwitchObserver> user_switch_observer_;
558 564
559 // If true, incoming pinned state changes should be ignored. 565 // If true, incoming pinned state changes should be ignored.
560 bool ignore_persist_pinned_state_change_; 566 bool ignore_persist_pinned_state_change_;
561 567
562 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController); 568 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherController);
563 }; 569 };
564 570
565 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_ 571 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698