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