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 #ifndef CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 9 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" |
| 10 #include "extensions/renderer/object_backed_native_handler.h" |
10 #include "third_party/WebKit/public/web/WebFrame.h" | 11 #include "third_party/WebKit/public/web/WebFrame.h" |
11 | 12 |
12 namespace extensions { | 13 namespace extensions { |
13 class ChromeV8Context; | |
14 | 14 |
15 // A V8 extension that creates an object at window.chrome.webstore. This object | 15 // A V8 extension that creates an object at window.chrome.webstore. This object |
16 // allows JavaScript to initiate inline installs of apps that are listed in the | 16 // allows JavaScript to initiate inline installs of apps that are listed in the |
17 // Chrome Web Store (CWS). | 17 // Chrome Web Store (CWS). |
18 class WebstoreBindings : public ChromeV8Extension, | 18 class WebstoreBindings : public ObjectBackedNativeHandler, |
19 public ChromeV8ExtensionHandler { | 19 public ChromeV8ExtensionHandler { |
20 public: | 20 public: |
21 explicit WebstoreBindings(Dispatcher* dispatcher, | 21 explicit WebstoreBindings(ScriptContext* context); |
22 ChromeV8Context* context); | |
23 | 22 |
24 // IPC::Listener | 23 // IPC::Listener |
25 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 24 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
26 | 25 |
27 private: | 26 private: |
28 void Install(const v8::FunctionCallbackInfo<v8::Value>& args); | 27 void Install(const v8::FunctionCallbackInfo<v8::Value>& args); |
29 | 28 |
30 void OnInlineWebstoreInstallResponse( | 29 void OnInlineWebstoreInstallResponse( |
31 int install_id, bool success, const std::string& error); | 30 int install_id, bool success, const std::string& error); |
32 | 31 |
33 void OnInlineInstallStageChanged(int stage); | 32 void OnInlineInstallStageChanged(int stage); |
34 | 33 |
35 void OnInlineInstallDownloadProgress(int percent_downloaded); | 34 void OnInlineInstallDownloadProgress(int percent_downloaded); |
36 | 35 |
37 // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" | 36 // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" |
38 // href="https://chrome.google.com/webstore/detail/id"> node found in the | 37 // href="https://chrome.google.com/webstore/detail/id"> node found in the |
39 // frame. On success, true will be returned and the |webstore_item_id| | 38 // frame. On success, true will be returned and the |webstore_item_id| |
40 // parameter will be populated with the ID. On failure, false will be returned | 39 // parameter will be populated with the ID. On failure, false will be returned |
41 // and |error| will be populated with the error. | 40 // and |error| will be populated with the error. |
42 static bool GetWebstoreItemIdFromFrame( | 41 static bool GetWebstoreItemIdFromFrame( |
43 blink::WebFrame* frame, const std::string& preferred_store_link_url, | 42 blink::WebFrame* frame, const std::string& preferred_store_link_url, |
44 std::string* webstore_item_id, std::string* error); | 43 std::string* webstore_item_id, std::string* error); |
45 | 44 |
46 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings); | 45 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings); |
47 }; | 46 }; |
48 | 47 |
49 } // namespace extensions | 48 } // namespace extensions |
50 | 49 |
51 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ | 50 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ |
OLD | NEW |