Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / app_shortcut_launcher_item_controller.h
blob38b652b50d4e53db1377daf3d0cd818eb68c642f
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
3 // found in the LICENSE file.
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_
8 #include <string>
10 #include "base/time/time.h"
11 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
12 #include "url/gurl.h"
14 class URLPattern;
16 namespace aura {
17 class Window;
20 namespace extensions {
21 class Extension;
24 class ChromeLauncherController;
26 // Item controller for an app shortcut. Shortcuts track app and launcher ids,
27 // but do not have any associated windows (opening a shortcut will replace the
28 // item with the appropriate LauncherItemController type).
29 class AppShortcutLauncherItemController : public LauncherItemController {
30 public:
31 AppShortcutLauncherItemController(const std::string& app_id,
32 ChromeLauncherController* controller);
34 virtual ~AppShortcutLauncherItemController();
36 std::vector<content::WebContents*> GetRunningApplications();
38 // LauncherItemController overrides:
39 virtual bool IsOpen() const OVERRIDE;
40 virtual bool IsVisible() const OVERRIDE;
41 virtual void Launch(ash::LaunchSource source, int event_flags) OVERRIDE;
42 virtual bool Activate(ash::LaunchSource source) OVERRIDE;
43 virtual ChromeLauncherAppMenuItems GetApplicationList(
44 int event_flags) OVERRIDE;
45 virtual bool ItemSelected(const ui::Event& event) OVERRIDE;
46 virtual base::string16 GetTitle() OVERRIDE;
47 virtual ui::MenuModel* CreateContextMenu(
48 aura::Window* root_window) OVERRIDE;
49 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE;
50 virtual bool IsDraggable() OVERRIDE;
51 virtual bool ShouldShowTooltip() OVERRIDE;
52 virtual void Close() OVERRIDE;
54 // Get the refocus url pattern, which can be used to identify this application
55 // from a URL link.
56 const GURL& refocus_url() const { return refocus_url_; }
57 // Set the refocus url pattern. Used by unit tests.
58 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; }
60 private:
61 // Get the last running application.
62 content::WebContents* GetLRUApplication();
64 // Returns true if this app matches the given |web_contents|. To accelerate
65 // the matching, the app managing |extension| as well as the parsed
66 // |refocus_pattern| get passed. If |is_app| is true, the application gets
67 // first checked against its original URL since a windowed app might have
68 // navigated away from its app domain.
69 bool WebContentMatchesApp(const extensions::Extension* extension,
70 const URLPattern& refocus_pattern,
71 content::WebContents* web_contents,
72 bool is_app);
74 // Activate the browser with the given |content| and show the associated tab.
75 void ActivateContent(content::WebContents* content);
77 // Advance to the next item if an owned item is already active. The function
78 // will return true if it has sucessfully advanced.
79 bool AdvanceToNextApp();
81 // Returns true if the application is a V2 app.
82 bool IsV2App();
84 // Returns true if it is allowed to try starting a V2 app again.
85 bool AllowNextLaunchAttempt();
87 GURL refocus_url_;
89 // Since V2 applications can be undetectable after launching, this timer is
90 // keeping track of the last launch attempt.
91 base::Time last_launch_attempt_;
93 ChromeLauncherController* chrome_launcher_controller_;
95 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController);
98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_