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

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

Issue 1973603002: arc: Make Play Store item persistance in shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 (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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 class Browser; 16 class Browser;
17 class URLPattern; 17 class URLPattern;
18 18
19 namespace extensions { 19 namespace extensions {
20 class Extension; 20 class Extension;
21 } 21 }
22 22
23 class ChromeLauncherController; 23 class ChromeLauncherController;
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(const std::string& app_id, 30 ~AppShortcutLauncherItemController() override;
31 ChromeLauncherController* controller);
32 31
33 ~AppShortcutLauncherItemController() override; 32 static AppShortcutLauncherItemController* Create(
33 const std::string& app_id,
34 ChromeLauncherController* controller);
35
36 ChromeLauncherController* controller() { return chrome_launcher_controller_; }
xiyuan 2016/05/11 22:10:08 nit: move this with other accessors, around line 6
khmel 2016/05/12 18:28:06 Done.
34 37
35 std::vector<content::WebContents*> GetRunningApplications(); 38 std::vector<content::WebContents*> GetRunningApplications();
36 39
37 // LauncherItemController overrides: 40 // LauncherItemController overrides:
38 bool IsOpen() const override; 41 bool IsOpen() const override;
39 bool IsVisible() const override; 42 bool IsVisible() const override;
40 void Launch(ash::LaunchSource source, int event_flags) override; 43 void Launch(ash::LaunchSource source, int event_flags) override;
41 ash::ShelfItemDelegate::PerformedAction Activate( 44 ash::ShelfItemDelegate::PerformedAction Activate(
42 ash::LaunchSource source) override; 45 ash::LaunchSource source) override;
43 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override; 46 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override;
44 ash::ShelfItemDelegate::PerformedAction ItemSelected( 47 ash::ShelfItemDelegate::PerformedAction ItemSelected(
45 const ui::Event& event) override; 48 const ui::Event& event) override;
46 base::string16 GetTitle() override; 49 base::string16 GetTitle() override;
47 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override; 50 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override;
48 bool IsDraggable() override; 51 bool IsDraggable() override;
49 bool CanPin() const override; 52 bool CanPin() const override;
50 bool ShouldShowTooltip() override; 53 bool ShouldShowTooltip() override;
51 void Close() override; 54 void Close() override;
52 55
53 // Get the refocus url pattern, which can be used to identify this application 56 // Get the refocus url pattern, which can be used to identify this application
54 // from a URL link. 57 // from a URL link.
55 const GURL& refocus_url() const { return refocus_url_; } 58 const GURL& refocus_url() const { return refocus_url_; }
56 // Set the refocus url pattern. Used by unit tests. 59 // Set the refocus url pattern. Used by unit tests.
57 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } 60 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; }
58 61
62 protected:
63 AppShortcutLauncherItemController(const std::string& app_id,
64 ChromeLauncherController* controller);
65
59 private: 66 private:
60 // Get the last running application. 67 // Get the last running application.
61 content::WebContents* GetLRUApplication(); 68 content::WebContents* GetLRUApplication();
62 69
63 // Returns true if this app matches the given |web_contents|. To accelerate 70 // Returns true if this app matches the given |web_contents|. To accelerate
64 // the matching, the app managing |extension| as well as the parsed 71 // the matching, the app managing |extension| as well as the parsed
65 // |refocus_pattern| get passed. If |is_app| is true, the application gets 72 // |refocus_pattern| get passed. If |is_app| is true, the application gets
66 // first checked against its original URL since a windowed app might have 73 // first checked against its original URL since a windowed app might have
67 // navigated away from its app domain. 74 // navigated away from its app domain.
68 bool WebContentMatchesApp(const extensions::Extension* extension, 75 bool WebContentMatchesApp(const extensions::Extension* extension,
(...skipping 21 matching lines...) Expand all
90 // Since V2 applications can be undetectable after launching, this timer is 97 // Since V2 applications can be undetectable after launching, this timer is
91 // keeping track of the last launch attempt. 98 // keeping track of the last launch attempt.
92 base::Time last_launch_attempt_; 99 base::Time last_launch_attempt_;
93 100
94 ChromeLauncherController* chrome_launcher_controller_; 101 ChromeLauncherController* chrome_launcher_controller_;
95 102
96 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); 103 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController);
97 }; 104 };
98 105
99 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_ H_ 106 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698