OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 | 24 |
25 // Item controller for an app shortcut. Shortcuts track app and launcher ids, | 25 // Item controller for an app shortcut. Shortcuts track app and launcher ids, |
26 // but do not have any associated windows (opening a shortcut will replace the | 26 // but do not have any associated windows (opening a shortcut will replace the |
27 // item with the appropriate LauncherItemController type). | 27 // item with the appropriate LauncherItemController type). |
28 class AppShortcutLauncherItemController : public LauncherItemController { | 28 class AppShortcutLauncherItemController : public LauncherItemController { |
29 public: | 29 public: |
30 ~AppShortcutLauncherItemController() override; | 30 ~AppShortcutLauncherItemController() override; |
31 | 31 |
32 static AppShortcutLauncherItemController* Create( | 32 static AppShortcutLauncherItemController* Create( |
33 const std::string& app_id, | 33 const std::string& app_id, |
34 const std::string& launch_id, | |
34 ChromeLauncherController* controller); | 35 ChromeLauncherController* controller); |
35 | 36 |
36 std::vector<content::WebContents*> GetRunningApplications(); | 37 std::vector<content::WebContents*> GetRunningApplications(); |
37 | 38 |
38 // LauncherItemController overrides: | 39 // LauncherItemController overrides: |
39 bool IsOpen() const override; | 40 bool IsOpen() const override; |
40 bool IsVisible() const override; | 41 bool IsVisible() const override; |
41 void Launch(ash::LaunchSource source, int event_flags) override; | 42 void Launch(ash::LaunchSource source, int event_flags) override; |
42 ash::ShelfItemDelegate::PerformedAction Activate( | 43 ash::ShelfItemDelegate::PerformedAction Activate( |
43 ash::LaunchSource source) override; | 44 ash::LaunchSource source) override; |
44 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override; | 45 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override; |
45 ash::ShelfItemDelegate::PerformedAction ItemSelected( | 46 ash::ShelfItemDelegate::PerformedAction ItemSelected( |
46 const ui::Event& event) override; | 47 const ui::Event& event) override; |
47 base::string16 GetTitle() override; | 48 base::string16 GetTitle() override; |
48 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override; | 49 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override; |
49 bool IsDraggable() override; | 50 bool IsDraggable() override; |
50 bool CanPin() const override; | 51 bool CanPin() const override; |
51 bool ShouldShowTooltip() override; | 52 bool ShouldShowTooltip() override; |
52 void Close() override; | 53 void Close() override; |
53 | 54 |
54 // Get the refocus url pattern, which can be used to identify this application | 55 // Get the refocus url pattern, which can be used to identify this application |
55 // from a URL link. | 56 // from a URL link. |
56 const GURL& refocus_url() const { return refocus_url_; } | 57 const GURL& refocus_url() const { return refocus_url_; } |
57 // Set the refocus url pattern. Used by unit tests. | 58 // Set the refocus url pattern. Used by unit tests. |
58 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } | 59 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } |
59 | 60 |
60 ChromeLauncherController* controller() { return chrome_launcher_controller_; } | 61 ChromeLauncherController* controller() { return chrome_launcher_controller_; } |
61 | 62 |
63 const std::string& app_id() const { return app_id_; } | |
64 | |
65 const std::string& launch_id() const { return launch_id_; } | |
66 | |
62 protected: | 67 protected: |
63 AppShortcutLauncherItemController(const std::string& app_id, | 68 AppShortcutLauncherItemController(const std::string& app_id, |
69 const std::string& launch_id, | |
64 ChromeLauncherController* controller); | 70 ChromeLauncherController* controller); |
65 | 71 |
66 private: | 72 private: |
67 // Get the last running application. | 73 // Get the last running application. |
68 content::WebContents* GetLRUApplication(); | 74 content::WebContents* GetLRUApplication(); |
69 | 75 |
70 // Returns true if this app matches the given |web_contents|. To accelerate | 76 // Returns true if this app matches the given |web_contents|. To accelerate |
71 // the matching, the app managing |extension| as well as the parsed | 77 // the matching, the app managing |extension| as well as the parsed |
72 // |refocus_pattern| get passed. If |is_app| is true, the application gets | 78 // |refocus_pattern| get passed. If |is_app| is true, the application gets |
73 // first checked against its original URL since a windowed app might have | 79 // first checked against its original URL since a windowed app might have |
(...skipping 19 matching lines...) Expand all Loading... | |
93 bool AllowNextLaunchAttempt(); | 99 bool AllowNextLaunchAttempt(); |
94 | 100 |
95 GURL refocus_url_; | 101 GURL refocus_url_; |
96 | 102 |
97 // Since V2 applications can be undetectable after launching, this timer is | 103 // Since V2 applications can be undetectable after launching, this timer is |
98 // keeping track of the last launch attempt. | 104 // keeping track of the last launch attempt. |
99 base::Time last_launch_attempt_; | 105 base::Time last_launch_attempt_; |
100 | 106 |
101 ChromeLauncherController* chrome_launcher_controller_; | 107 ChromeLauncherController* chrome_launcher_controller_; |
102 | 108 |
109 // The application id associated with this app shortcut. | |
110 const std::string app_id_; | |
111 | |
112 // The launch id associated with this app shortcut. | |
James Cook
2016/09/01 04:27:51
This needs to document what |launch_id_| *means*,
Andra Paraschiv
2016/09/01 08:27:25
Done.
| |
113 const std::string launch_id_; | |
114 | |
103 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); | 115 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); |
104 }; | 116 }; |
105 | 117 |
106 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_ H_ | 118 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_ H_ |
OLD | NEW |