| 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 "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/common/extensions/mojo/inline_install.mojom.h" |
| 11 #include "chrome/common/extensions/mojo/inline_install_status.mojom.h" |
| 10 #include "chrome/common/extensions/webstore_install_result.h" | 12 #include "chrome/common/extensions/webstore_install_result.h" |
| 11 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" | 13 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" |
| 12 #include "extensions/renderer/object_backed_native_handler.h" | 14 #include "extensions/renderer/object_backed_native_handler.h" |
| 13 | 15 |
| 14 namespace blink { | 16 namespace blink { |
| 15 class WebLocalFrame; | 17 class WebLocalFrame; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace extensions { | 20 namespace extensions { |
| 19 | 21 |
| 20 // A V8 extension that creates an object at window.chrome.webstore. This object | 22 // A V8 extension that creates an object at window.chrome.webstore. This object |
| 21 // allows JavaScript to initiate inline installs of apps that are listed in the | 23 // allows JavaScript to initiate inline installs of apps that are listed in the |
| 22 // Chrome Web Store (CWS). | 24 // Chrome Web Store (CWS). |
| 23 class WebstoreBindings : public ObjectBackedNativeHandler, | 25 class WebstoreBindings : public ObjectBackedNativeHandler, |
| 24 public ChromeV8ExtensionHandler { | 26 public ChromeV8ExtensionHandler, |
| 27 public mojom::InlineInstallStatus { |
| 25 public: | 28 public: |
| 26 explicit WebstoreBindings(ScriptContext* context); | 29 explicit WebstoreBindings(ScriptContext* context); |
| 30 ~WebstoreBindings() override; |
| 27 | 31 |
| 28 // IPC::Listener | 32 // IPC::Listener |
| 29 bool OnMessageReceived(const IPC::Message& message) override; | 33 bool OnMessageReceived(const IPC::Message& message) override; |
| 30 | 34 |
| 35 static void BindInlineInstallStatusRequest( |
| 36 ScriptContext* context, |
| 37 mojom::InlineInstallStatusRequest request); |
| 38 |
| 31 private: | 39 private: |
| 32 void Install(const v8::FunctionCallbackInfo<v8::Value>& args); | 40 void Install(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 33 | 41 |
| 34 void OnInlineWebstoreInstallResponse(int install_id, | 42 // mojom::InlineInstallStatus |
| 35 bool success, | 43 void InlineWebstoreInstallResponse(int install_id, |
| 36 const std::string& error, | 44 bool success, |
| 37 webstore_install::Result result); | 45 const std::string& error, |
| 46 webstore_install::Result result) override; |
| 38 | 47 |
| 39 void OnInlineInstallStageChanged(int stage); | 48 void InlineInstallStageChanged(api::webstore::InstallStage stage) override; |
| 40 | 49 |
| 41 void OnInlineInstallDownloadProgress(int percent_downloaded); | 50 void InlineInstallDownloadProgress(int percent_downloaded) override; |
| 42 | 51 |
| 43 // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" | 52 // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" |
| 44 // href="https://chrome.google.com/webstore/detail/id"> node found in the | 53 // href="https://chrome.google.com/webstore/detail/id"> node found in the |
| 45 // frame. On success, true will be returned and the |webstore_item_id| | 54 // frame. On success, true will be returned and the |webstore_item_id| |
| 46 // parameter will be populated with the ID. On failure, false will be returned | 55 // parameter will be populated with the ID. On failure, false will be returned |
| 47 // and |error| will be populated with the error. | 56 // and |error| will be populated with the error. |
| 48 static bool GetWebstoreItemIdFromFrame( | 57 static bool GetWebstoreItemIdFromFrame( |
| 49 blink::WebLocalFrame* frame, | 58 blink::WebLocalFrame* frame, |
| 50 const std::string& preferred_store_link_url, | 59 const std::string& preferred_store_link_url, |
| 51 std::string* webstore_item_id, | 60 std::string* webstore_item_id, |
| 52 std::string* error); | 61 std::string* error); |
| 53 | 62 |
| 63 extensions::mojom::InlineInstallPtr inline_install_; |
| 64 |
| 54 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings); | 65 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings); |
| 55 }; | 66 }; |
| 56 | 67 |
| 57 } // namespace extensions | 68 } // namespace extensions |
| 58 | 69 |
| 59 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ | 70 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ |
| OLD | NEW |