| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 class MainFrameObserver : public RenderFrameObserver { | 37 class MainFrameObserver : public RenderFrameObserver { |
| 38 public: | 38 public: |
| 39 explicit MainFrameObserver(WebUIMojo* web_ui_mojo); | 39 explicit MainFrameObserver(WebUIMojo* web_ui_mojo); |
| 40 virtual ~MainFrameObserver(); | 40 virtual ~MainFrameObserver(); |
| 41 | 41 |
| 42 // RenderFrameObserver overrides: | 42 // RenderFrameObserver overrides: |
| 43 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context, | 43 virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context, |
| 44 int world_id) OVERRIDE; | 44 int world_id) OVERRIDE; |
| 45 virtual void DidFinishDocumentLoad() OVERRIDE; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 WebUIMojo* web_ui_mojo_; | 48 WebUIMojo* web_ui_mojo_; |
| 48 | 49 |
| 49 DISALLOW_COPY_AND_ASSIGN(MainFrameObserver); | 50 DISALLOW_COPY_AND_ASSIGN(MainFrameObserver); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 virtual ~WebUIMojo(); | 53 virtual ~WebUIMojo(); |
| 53 | 54 |
| 54 void CreateContextState(); | 55 void CreateContextState(); |
| 55 void DestroyContextState(v8::Handle<v8::Context> context); | 56 void DestroyContextState(v8::Handle<v8::Context> context); |
| 56 | 57 |
| 58 // Invoked when the frame finishes loading. Invokes SetHandleOnContextState() |
| 59 // if necessary. |
| 60 void OnDidFinishDocumentLoad(); |
| 61 |
| 62 // Invokes SetHandle() on the WebUIMojoContextState (if there is one). |
| 63 void SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle); |
| 64 |
| 57 WebUIMojoContextState* GetContextState(); | 65 WebUIMojoContextState* GetContextState(); |
| 58 | 66 |
| 59 // RenderViewObserver overrides: | 67 // RenderViewObserver overrides: |
| 60 virtual void DidClearWindowObject(blink::WebFrame* frame, | 68 virtual void DidClearWindowObject(blink::WebFrame* frame, |
| 61 int world_id) OVERRIDE; | 69 int world_id) OVERRIDE; |
| 62 | 70 |
| 63 MainFrameObserver main_frame_observer_; | 71 MainFrameObserver main_frame_observer_; |
| 64 | 72 |
| 73 // Set to true in DidFinishDocumentLoad(). 'main' is only executed once this |
| 74 // happens. |
| 75 bool did_finish_document_load_; |
| 76 |
| 77 // If SetBrowserHandle() is invoked before the document finishes loading the |
| 78 // MessagePipeHandle is stored here. When the document finishes loading |
| 79 // SetHandleOnContextState() is invoked to send the handle to the |
| 80 // WebUIMojoContextState and ultimately the page. |
| 81 mojo::ScopedMessagePipeHandle pending_handle_; |
| 82 |
| 65 DISALLOW_COPY_AND_ASSIGN(WebUIMojo); | 83 DISALLOW_COPY_AND_ASSIGN(WebUIMojo); |
| 66 }; | 84 }; |
| 67 | 85 |
| 68 } // namespace content | 86 } // namespace content |
| 69 | 87 |
| 70 #endif // CONTENT_RENDERER_WEB_UI_MOJO_H_ | 88 #endif // CONTENT_RENDERER_WEB_UI_MOJO_H_ |
| OLD | NEW |