OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 13 #pragma once |
14 | 14 |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 16 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
17 | 18 |
18 class ChromeV8Context; | 19 class ChromeV8Context; |
19 | 20 |
21 using WebKit::WebFrame; | |
22 | |
20 // Implements the chrome.app JavaScript object. | 23 // Implements the chrome.app JavaScript object. |
21 // | 24 // |
22 // TODO(aa): Add unit testing for this class. | 25 // TODO(aa): Add unit testing for this class. |
23 class AppBindings : public ChromeV8Extension { | 26 class AppBindings : public ChromeV8Extension, public ChromeV8ExtensionHandler { |
Aaron Boodman
2012/02/16 01:54:42
This is multiple inheritance, which is typically d
koz (OOO until 15th September)
2012/02/27 01:06:14
It's possible, but it would be quite messy. It's p
Aaron Boodman
2012/02/28 02:42:59
In that case, I prefer the multiple inheritance.
| |
24 public: | 27 public: |
25 explicit AppBindings(ExtensionDispatcher* dispatcher); | 28 explicit AppBindings(ExtensionDispatcher* dispatcher, |
29 ChromeV8Context* context); | |
30 virtual ~AppBindings(); | |
26 | 31 |
27 protected: | 32 // ChromeV8Extension |
28 virtual ChromeV8ExtensionHandler* CreateHandler( | 33 virtual void SetNativeFunctions(v8::Handle<v8::Object> object) OVERRIDE; |
29 ChromeV8Context* context) OVERRIDE; | 34 virtual v8::Handle<v8::Value> HandleNativeFunction( |
35 const std::string& name, | |
36 const v8::Arguments& arguments) OVERRIDE; | |
37 | |
38 // IPC::Channel::Listener | |
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
30 | 40 |
31 private: | 41 private: |
42 v8::Handle<v8::Value> GetIsInstalled(const v8::Arguments& args); | |
43 v8::Handle<v8::Value> Install(const v8::Arguments& args); | |
44 v8::Handle<v8::Value> GetDetails(const v8::Arguments& args); | |
45 v8::Handle<v8::Value> GetDetailsForFrame(const v8::Arguments& args); | |
46 v8::Handle<v8::Value> GetAppNotifyChannel(const v8::Arguments& args); | |
47 | |
48 v8::Handle<v8::Value> GetDetailsForFrameImpl(WebKit::WebFrame* frame); | |
49 | |
50 void OnGetAppNotifyChannelResponse(const std::string& channel_id, | |
51 const std::string& error, | |
52 int callback_id); | |
53 | |
54 ExtensionDispatcher* dispatcher_; | |
32 DISALLOW_COPY_AND_ASSIGN(AppBindings); | 55 DISALLOW_COPY_AND_ASSIGN(AppBindings); |
33 }; | 56 }; |
34 | 57 |
35 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ | 58 #endif // CHROME_RENDERER_EXTENSIONS_APP_BINDINGS_H_ |
OLD | NEW |