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

Side by Side Diff: content/renderer/web_ui_mojo.h

Issue 302573002: Add a Javascript wrapper around ServiceRegistry and expose it to WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-shell
Patch Set: address comments Created 6 years, 4 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
« no previous file with comments | « content/renderer/mojo/service_registry_js_wrapper.cc ('k') | content/renderer/web_ui_mojo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_RENDERER_WEB_UI_MOJO_H_ 5 #ifndef CONTENT_RENDERER_WEB_UI_MOJO_H_
6 #define CONTENT_RENDERER_WEB_UI_MOJO_H_ 6 #define CONTENT_RENDERER_WEB_UI_MOJO_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "content/public/renderer/render_frame_observer.h" 10 #include "content/public/renderer/render_frame_observer.h"
(...skipping 12 matching lines...) Expand all
23 // WebUIMojo is responsible for enabling the renderer side of mojo bindings. 23 // WebUIMojo is responsible for enabling the renderer side of mojo bindings.
24 // It creates (and destroys) a WebUIMojoContextState at the appropriate times 24 // It creates (and destroys) a WebUIMojoContextState at the appropriate times
25 // and handles the necessary browser messages. WebUIMojo destroys itself when 25 // and handles the necessary browser messages. WebUIMojo destroys itself when
26 // the RendererView it is created with is destroyed. 26 // the RendererView it is created with is destroyed.
27 class WebUIMojo 27 class WebUIMojo
28 : public RenderViewObserver, 28 : public RenderViewObserver,
29 public RenderViewObserverTracker<WebUIMojo> { 29 public RenderViewObserverTracker<WebUIMojo> {
30 public: 30 public:
31 explicit WebUIMojo(RenderView* render_view); 31 explicit WebUIMojo(RenderView* render_view);
32 32
33 // Sets the handle to the current WebUI.
34 void SetBrowserHandle(mojo::ScopedMessagePipeHandle handle);
35
36 private: 33 private:
37 class MainFrameObserver : public RenderFrameObserver { 34 class MainFrameObserver : public RenderFrameObserver {
38 public: 35 public:
39 explicit MainFrameObserver(WebUIMojo* web_ui_mojo); 36 explicit MainFrameObserver(WebUIMojo* web_ui_mojo);
40 virtual ~MainFrameObserver(); 37 virtual ~MainFrameObserver();
41 38
42 // RenderFrameObserver overrides: 39 // RenderFrameObserver overrides:
43 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context, 40 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
44 int world_id) OVERRIDE; 41 int world_id) OVERRIDE;
45 virtual void DidFinishDocumentLoad() OVERRIDE; 42 virtual void DidFinishDocumentLoad() OVERRIDE;
46 43
47 private: 44 private:
48 WebUIMojo* web_ui_mojo_; 45 WebUIMojo* web_ui_mojo_;
49 46
50 DISALLOW_COPY_AND_ASSIGN(MainFrameObserver); 47 DISALLOW_COPY_AND_ASSIGN(MainFrameObserver);
51 }; 48 };
52 49
53 virtual ~WebUIMojo(); 50 virtual ~WebUIMojo();
54 51
55 void CreateContextState(); 52 void CreateContextState();
56 void DestroyContextState(v8::Handle<v8::Context> context); 53 void DestroyContextState(v8::Handle<v8::Context> context);
57 54
58 // Invoked when the frame finishes loading. Invokes SetHandleOnContextState() 55 // Invoked when the frame finishes loading. Invokes Run() on the
59 // if necessary. 56 // WebUIMojoContextState.
60 void OnDidFinishDocumentLoad(); 57 void OnDidFinishDocumentLoad();
61 58
62 // Invokes SetHandle() on the WebUIMojoContextState (if there is one).
63 void SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle);
64
65 WebUIMojoContextState* GetContextState(); 59 WebUIMojoContextState* GetContextState();
66 60
67 // RenderViewObserver overrides: 61 // RenderViewObserver overrides:
68 virtual void DidClearWindowObject(blink::WebLocalFrame* frame) OVERRIDE; 62 virtual void DidClearWindowObject(blink::WebLocalFrame* frame) OVERRIDE;
69 63
70 MainFrameObserver main_frame_observer_; 64 MainFrameObserver main_frame_observer_;
71 65
72 // Set to true in DidFinishDocumentLoad(). 'main' is only executed once this
73 // happens.
74 bool did_finish_document_load_;
75
76 // If SetBrowserHandle() is invoked before the document finishes loading the
77 // MessagePipeHandle is stored here. When the document finishes loading
78 // SetHandleOnContextState() is invoked to send the handle to the
79 // WebUIMojoContextState and ultimately the page.
80 mojo::ScopedMessagePipeHandle pending_handle_;
81
82 DISALLOW_COPY_AND_ASSIGN(WebUIMojo); 66 DISALLOW_COPY_AND_ASSIGN(WebUIMojo);
83 }; 67 };
84 68
85 } // namespace content 69 } // namespace content
86 70
87 #endif // CONTENT_RENDERER_WEB_UI_MOJO_H_ 71 #endif // CONTENT_RENDERER_WEB_UI_MOJO_H_
OLDNEW
« no previous file with comments | « content/renderer/mojo/service_registry_js_wrapper.cc ('k') | content/renderer/web_ui_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698