| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
| 9 #include "chrome/browser/extensions/extension_shelf_model.h" | 9 #include "chrome/browser/extensions/extension_shelf_model.h" |
| 10 | 10 |
| 11 class Profile; |
| 12 |
| 11 // Function names. | 13 // Function names. |
| 12 namespace extension_toolstrip_api_functions { | 14 namespace extension_toolstrip_api_functions { |
| 13 extern const char kExpandFunction[]; | 15 extern const char kExpandFunction[]; |
| 14 extern const char kCollapseFunction[]; | 16 extern const char kCollapseFunction[]; |
| 15 }; // namespace extension_toolstrip_api_functions | 17 }; // namespace extension_toolstrip_api_functions |
| 16 | 18 |
| 19 namespace extension_toolstrip_api_events { |
| 20 extern const char kOnToolstripExpanded[]; |
| 21 extern const char kOnToolstripCollapsed[]; |
| 22 }; // namespace extension_toolstrip_api_events |
| 23 |
| 17 class ToolstripFunction : public SyncExtensionFunction { | 24 class ToolstripFunction : public SyncExtensionFunction { |
| 18 protected: | 25 protected: |
| 19 virtual bool RunImpl(); | 26 virtual bool RunImpl(); |
| 20 | 27 |
| 21 ExtensionShelfModel* model_; | 28 ExtensionShelfModel* model_; |
| 22 ExtensionShelfModel::iterator toolstrip_; | 29 ExtensionShelfModel::iterator toolstrip_; |
| 23 }; | 30 }; |
| 24 | 31 |
| 25 class ToolstripExpandFunction : public ToolstripFunction { | 32 class ToolstripExpandFunction : public ToolstripFunction { |
| 26 virtual bool RunImpl(); | 33 virtual bool RunImpl(); |
| 27 }; | 34 }; |
| 28 | 35 |
| 29 class ToolstripCollapseFunction : public ToolstripFunction { | 36 class ToolstripCollapseFunction : public ToolstripFunction { |
| 30 virtual bool RunImpl(); | 37 virtual bool RunImpl(); |
| 31 }; | 38 }; |
| 32 | 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 |
| 33 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ | 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_ |
| OLD | NEW |