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 // The AppObjectExtension is a v8 extension that creates an object | 5 // The AppObjectExtension is a v8 extension that creates an object |
6 // at window.chrome.app. This object allows javascript to get details | 6 // at window.chrome.app. This object allows javascript to get details |
7 // on the app state of the page. | 7 // on the app state of the page. |
8 // The read-only property app.isInstalled is true if the current page is | 8 // The read-only property app.isInstalled is true if the current page is |
9 // within the extent of an installed, enabled app. | 9 // within the extent of an installed, enabled app. |
10 | 10 |
11 #ifndef CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ | 11 #ifndef CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ |
12 #define CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ | 12 #define CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 15 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" |
| 16 #include "extensions/renderer/object_backed_native_handler.h" |
16 #include "third_party/WebKit/public/web/WebFrame.h" | 17 #include "third_party/WebKit/public/web/WebFrame.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 class ChromeV8Context; | 20 class Dispatcher; |
20 | 21 |
21 // Implements the chrome.app JavaScript object. | 22 // Implements the chrome.app JavaScript object. |
22 // | 23 // |
23 // TODO(aa): Add unit testing for this class. | 24 // TODO(aa): Add unit testing for this class. |
24 class AppBindings : public ChromeV8Extension, | 25 class AppBindings : public ObjectBackedNativeHandler, |
25 public ChromeV8ExtensionHandler { | 26 public ChromeV8ExtensionHandler { |
26 public: | 27 public: |
27 AppBindings(Dispatcher* dispatcher, ChromeV8Context* context); | 28 AppBindings(Dispatcher* dispatcher, ScriptContext* context); |
28 | 29 |
29 private: | 30 private: |
30 // IPC::Listener | 31 // IPC::Listener |
31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
32 | 33 |
33 void GetIsInstalled(const v8::FunctionCallbackInfo<v8::Value>& args); | 34 void GetIsInstalled(const v8::FunctionCallbackInfo<v8::Value>& args); |
34 void GetDetails(const v8::FunctionCallbackInfo<v8::Value>& args); | 35 void GetDetails(const v8::FunctionCallbackInfo<v8::Value>& args); |
35 void GetDetailsForFrame(const v8::FunctionCallbackInfo<v8::Value>& args); | 36 void GetDetailsForFrame(const v8::FunctionCallbackInfo<v8::Value>& args); |
36 void GetInstallState(const v8::FunctionCallbackInfo<v8::Value>& args); | 37 void GetInstallState(const v8::FunctionCallbackInfo<v8::Value>& args); |
37 void GetRunningState(const v8::FunctionCallbackInfo<v8::Value>& args); | 38 void GetRunningState(const v8::FunctionCallbackInfo<v8::Value>& args); |
38 | 39 |
39 v8::Handle<v8::Value> GetDetailsForFrameImpl(blink::WebFrame* frame); | 40 v8::Handle<v8::Value> GetDetailsForFrameImpl(blink::WebFrame* frame); |
40 | 41 |
41 void OnAppInstallStateResponse(const std::string& state, int callback_id); | 42 void OnAppInstallStateResponse(const std::string& state, int callback_id); |
42 | 43 |
| 44 // Dispatcher handle. Not owned. |
| 45 Dispatcher* dispatcher_; |
| 46 |
43 DISALLOW_COPY_AND_ASSIGN(AppBindings); | 47 DISALLOW_COPY_AND_ASSIGN(AppBindings); |
44 }; | 48 }; |
45 | 49 |
46 } // namespace extensions | 50 } // namespace extensions |
47 | 51 |
48 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ | 52 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ |
OLD | NEW |