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

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

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: cleanup Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "ash/public/cpp/shelf_item_delegate.h" 11 #include "ash/public/cpp/shelf_item_delegate.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
15 15
16 class ChromeLauncherController;
17
16 namespace aura { 18 namespace aura {
17 class Window; 19 class Window;
18 } 20 }
19 21
20 namespace ui { 22 namespace ui {
21 class BaseWindow; 23 class BaseWindow;
22 } 24 }
23 25
24 // This is a ShelfItemDelegate for abstract app windows (extension or ARC). 26 // This is a ShelfItemDelegate for abstract app windows (extension or ARC).
25 // There is one instance per app, per launcher id. For apps with multiple 27 // There is one instance per app, per launcher id. For apps with multiple
(...skipping 27 matching lines...) Expand all
53 void OnWindowPropertyChanged(aura::Window* window, 55 void OnWindowPropertyChanged(aura::Window* window,
54 const void* key, 56 const void* key,
55 intptr_t old) override; 57 intptr_t old) override;
56 58
57 // Get the number of running applications/incarnations of this. 59 // Get the number of running applications/incarnations of this.
58 size_t window_count() const { return windows_.size(); } 60 size_t window_count() const { return windows_.size(); }
59 61
60 // Activates the window at position |index|. 62 // Activates the window at position |index|.
61 void ActivateIndexedApp(size_t index); 63 void ActivateIndexedApp(size_t index);
62 64
63 // Called when launcher item may need to be updated, eg. label or icon.
64 // TODO(khmel): Use aura::Window property and observe property change
65 // http://crbug.com/724292
66 virtual void UpdateLauncherItem() {}
67
68 const WindowList& windows() const { return windows_; } 65 const WindowList& windows() const { return windows_; }
69 66
70 protected: 67 protected:
71 explicit AppWindowLauncherItemController(const ash::ShelfID& shelf_id); 68 AppWindowLauncherItemController(const ash::ShelfID& shelf_id,
69 ChromeLauncherController* owner);
72 70
73 // Returns the action performed. Should be one of SHELF_ACTION_NONE, 71 // Returns the action performed. Should be one of SHELF_ACTION_NONE,
74 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. 72 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED.
75 ash::ShelfAction ShowAndActivateOrMinimize(ui::BaseWindow* window); 73 ash::ShelfAction ShowAndActivateOrMinimize(ui::BaseWindow* window);
76 74
77 // Activate the given |window_to_show|, or - if already selected - advance to 75 // Activate the given |window_to_show|, or - if already selected - advance to
78 // the next window of similar type. 76 // the next window of similar type.
79 // Returns the action performed. Should be one of SHELF_ACTION_NONE, 77 // Returns the action performed. Should be one of SHELF_ACTION_NONE,
80 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. 78 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED.
81 ash::ShelfAction ActivateOrAdvanceToNextAppWindow( 79 ash::ShelfAction ActivateOrAdvanceToNextAppWindow(
82 ui::BaseWindow* window_to_show); 80 ui::BaseWindow* window_to_show);
83 81
84 // Returns last active window in the controller or first window. 82 // Returns last active window in the controller or first window.
85 ui::BaseWindow* GetLastActiveWindow(); 83 ui::BaseWindow* GetLastActiveWindow();
86 84
85 ChromeLauncherController* owner() { return owner_; }
86
87 private: 87 private:
88 WindowList::iterator GetFromNativeWindow(aura::Window* window); 88 WindowList::iterator GetFromNativeWindow(aura::Window* window);
89 89
90 void UpdateLauncherItem();
msw 2017/05/23 00:02:29 nit: comment (or inline in OnWindowPropertyChanged
khmel 2017/05/23 16:11:43 Done. Inlining is not very possible because it is
91
92 // Unowned pointer.
93 ChromeLauncherController* const owner_;
94
90 // List of associated app windows 95 // List of associated app windows
91 WindowList windows_; 96 WindowList windows_;
92 97
93 // Pointer to the most recently active app window 98 // Pointer to the most recently active app window
94 // TODO(khmel): Get rid of |last_active_window_| and provide more reliable 99 // TODO(khmel): Get rid of |last_active_window_| and provide more reliable
95 // way to determine active window. 100 // way to determine active window.
96 ui::BaseWindow* last_active_window_ = nullptr; 101 ui::BaseWindow* last_active_window_ = nullptr;
97 102
98 // Scoped list of observed windows (for removal on destruction) 103 // Scoped list of observed windows (for removal on destruction)
99 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; 104 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_;
100 105
101 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); 106 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController);
102 }; 107 };
103 108
104 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ 109 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698