OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 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. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | |
7 #pragma once | |
8 | |
9 #include "chrome/browser/extensions/extension_function.h" | |
10 #include "chrome/browser/extensions/extension_shelf_model.h" | |
11 | |
12 class Profile; | |
13 | |
14 namespace extension_toolstrip_api_events { | |
15 extern const char kOnToolstripExpanded[]; | |
16 extern const char kOnToolstripCollapsed[]; | |
17 }; // namespace extension_toolstrip_api_events | |
18 | |
19 class ToolstripFunction : public SyncExtensionFunction { | |
20 protected: | |
21 virtual ~ToolstripFunction() {} | |
22 virtual bool RunImpl(); | |
23 | |
24 ExtensionShelfModel* model_; | |
25 ExtensionShelfModel::iterator toolstrip_; | |
26 }; | |
27 | |
28 class ToolstripExpandFunction : public ToolstripFunction { | |
29 ~ToolstripExpandFunction() {} | |
30 virtual bool RunImpl(); | |
31 DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.expand") | |
32 }; | |
33 | |
34 class ToolstripCollapseFunction : public ToolstripFunction { | |
35 ~ToolstripCollapseFunction() {} | |
36 virtual bool RunImpl(); | |
37 DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.collapse") | |
38 }; | |
39 | |
40 class ToolstripEventRouter { | |
41 public: | |
42 // Toolstrip events. | |
43 static void OnToolstripExpanded(Profile* profile, | |
44 int routing_id, | |
45 const GURL& url, | |
46 int height); | |
47 static void OnToolstripCollapsed(Profile* profile, | |
48 int routing_id, | |
49 const GURL& url); | |
50 | |
51 private: | |
52 // Helper to actually dispatch an event to extension listeners. | |
53 static void DispatchEvent(Profile* profile, | |
54 int routing_id, | |
55 const char* event_name, | |
56 const Value& json); | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ToolstripEventRouter); | |
59 }; | |
60 | |
61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | |
OLD | NEW |