Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1141)

Side by Side Diff: chrome/renderer/extensions/webstore_bindings.h

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: Rebase master; Addressed Ken's and mostly palmer's comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/mojom/inline_install.mojom.h"
10 #include "chrome/common/extensions/webstore_install_result.h" 11 #include "chrome/common/extensions/webstore_install_result.h"
11 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" 12 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h"
12 #include "extensions/renderer/object_backed_native_handler.h" 13 #include "extensions/renderer/object_backed_native_handler.h"
14 #include "mojo/public/cpp/bindings/binding_set.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 {
21 class ScriptContext;
19 22
20 // A V8 extension that creates an object at window.chrome.webstore. This object 23 // 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 24 // allows JavaScript to initiate inline installs of apps that are listed in the
22 // Chrome Web Store (CWS). 25 // Chrome Web Store (CWS).
23 class WebstoreBindings : public ObjectBackedNativeHandler, 26 class WebstoreBindings : public ObjectBackedNativeHandler,
24 public ChromeV8ExtensionHandler { 27 public ChromeV8ExtensionHandler,
28 public mojom::InlineInstallProgressListener {
25 public: 29 public:
26 explicit WebstoreBindings(ScriptContext* context); 30 explicit WebstoreBindings(ScriptContext* context);
31 ~WebstoreBindings() override;
27 32
28 // IPC::Listener 33 // IPC::Listener:
29 bool OnMessageReceived(const IPC::Message& message) override; 34 bool OnMessageReceived(const IPC::Message& message) override;
30 35
36 void InlineInstallResponse(int install_id,
Devlin 2017/05/24 21:33:59 nit: This can be private
catmullings 2017/05/25 00:14:45 Done.
37 bool success,
38 const std::string& error,
39 webstore_install::Result result);
40
41 // mojom::InlineInstallProgressListener:
42 void InlineInstallStageChanged(api::webstore::InstallStage stage) override;
43 void InlineInstallDownloadProgress(int percent_downloaded) override;
44
31 private: 45 private:
32 void Install(const v8::FunctionCallbackInfo<v8::Value>& args); 46 void Install(const v8::FunctionCallbackInfo<v8::Value>& args);
33 47
34 void OnInlineWebstoreInstallResponse(int install_id,
35 bool success,
36 const std::string& error,
37 webstore_install::Result result);
38
39 void OnInlineInstallStageChanged(int stage);
40
41 void OnInlineInstallDownloadProgress(int percent_downloaded);
42
43 // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" 48 // 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 49 // 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| 50 // 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 51 // parameter will be populated with the ID. On failure, false will be returned
47 // and |error| will be populated with the error. 52 // and |error| will be populated with the error.
48 static bool GetWebstoreItemIdFromFrame( 53 static bool GetWebstoreItemIdFromFrame(
49 blink::WebLocalFrame* frame, 54 blink::WebLocalFrame* frame,
50 const std::string& preferred_store_link_url, 55 const std::string& preferred_store_link_url,
51 std::string* webstore_item_id, 56 std::string* webstore_item_id,
52 std::string* error); 57 std::string* error);
53 58
59 mojom::InlineInstallerAssociatedPtr inline_installer_;
60
61 mojo::BindingSet<mojom::InlineInstallProgressListener>
62 install_progress_listener_bindings_;
63
54 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings); 64 DISALLOW_COPY_AND_ASSIGN(WebstoreBindings);
55 }; 65 };
56 66
57 } // namespace extensions 67 } // namespace extensions
58 68
59 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ 69 #endif // CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698