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.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 class ChromeV8Context; | 19 class ChromeV8Context; |
20 | 20 |
21 // Implements the chrome.app JavaScript object. | 21 // Implements the chrome.app JavaScript object. |
22 // | 22 // |
23 // TODO(aa): Add unit testing for this class. | 23 // TODO(aa): Add unit testing for this class. |
24 class AppBindings : public ChromeV8Extension, | 24 class AppBindings : public ChromeV8Extension, |
25 public ChromeV8ExtensionHandler { | 25 public ChromeV8ExtensionHandler { |
26 public: | 26 public: |
27 explicit AppBindings(Dispatcher* dispatcher, | 27 AppBindings(Dispatcher* dispatcher, |
28 ChromeV8Context* context); | 28 ChromeV8Context* context); |
29 | 29 |
30 private: | 30 private: |
31 // IPC::Listener | 31 // IPC::Listener |
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
33 | 33 |
34 v8::Handle<v8::Value> GetIsInstalled(const v8::Arguments& args); | 34 v8::Handle<v8::Value> GetIsInstalled(const v8::Arguments& args); |
35 v8::Handle<v8::Value> Install(const v8::Arguments& args); | 35 v8::Handle<v8::Value> Install(const v8::Arguments& args); |
36 v8::Handle<v8::Value> GetDetails(const v8::Arguments& args); | 36 v8::Handle<v8::Value> GetDetails(const v8::Arguments& args); |
37 v8::Handle<v8::Value> GetDetailsForFrame(const v8::Arguments& args); | 37 v8::Handle<v8::Value> GetDetailsForFrame(const v8::Arguments& args); |
38 v8::Handle<v8::Value> GetAppNotifyChannel(const v8::Arguments& args); | 38 v8::Handle<v8::Value> GetAppNotifyChannel(const v8::Arguments& args); |
39 v8::Handle<v8::Value> GetInstallState(const v8::Arguments& args); | 39 v8::Handle<v8::Value> GetInstallState(const v8::Arguments& args); |
40 v8::Handle<v8::Value> GetRunningState(const v8::Arguments& args); | 40 v8::Handle<v8::Value> GetRunningState(const v8::Arguments& args); |
41 | 41 |
42 v8::Handle<v8::Value> GetDetailsForFrameImpl(WebKit::WebFrame* frame); | 42 v8::Handle<v8::Value> GetDetailsForFrameImpl(WebKit::WebFrame* frame); |
43 | 43 |
44 void OnGetAppNotifyChannelResponse(const std::string& channel_id, | 44 void OnGetAppNotifyChannelResponse(const std::string& channel_id, |
45 const std::string& error, | 45 const std::string& error, |
46 int callback_id); | 46 int callback_id); |
47 void OnAppInstallStateResponse(const std::string& state, int callback_id); | 47 void OnAppInstallStateResponse(const std::string& state, int callback_id); |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(AppBindings); | 49 DISALLOW_COPY_AND_ASSIGN(AppBindings); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace extensions | 52 } // namespace extensions |
53 | 53 |
54 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ | 54 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ |
OLD | NEW |