| 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 10 matching lines...) Expand all  Loading... | 
|  21 class WebUIMojoContextState; |  21 class WebUIMojoContextState; | 
|  22  |  22  | 
|  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(RenderViewImpl* render_view); | 
|  32  |  32  | 
|  33   // Sets the handle to the current WebUI. |  33   // Sets the handle to the current WebUI. | 
|  34   void SetBrowserHandle(mojo::ScopedMessagePipeHandle handle); |  34   void SetBrowserHandle(mojo::ScopedMessagePipeHandle handle); | 
|  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  | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  60   void OnDidFinishDocumentLoad(); |  60   void OnDidFinishDocumentLoad(); | 
|  61  |  61  | 
|  62   // Invokes SetHandle() on the WebUIMojoContextState (if there is one). |  62   // Invokes SetHandle() on the WebUIMojoContextState (if there is one). | 
|  63   void SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle); |  63   void SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle); | 
|  64  |  64  | 
|  65   WebUIMojoContextState* GetContextState(); |  65   WebUIMojoContextState* GetContextState(); | 
|  66  |  66  | 
|  67   // RenderViewObserver overrides: |  67   // RenderViewObserver overrides: | 
|  68   virtual void DidClearWindowObject(blink::WebLocalFrame* frame) OVERRIDE; |  68   virtual void DidClearWindowObject(blink::WebLocalFrame* frame) OVERRIDE; | 
|  69  |  69  | 
 |  70   RenderViewImpl* render_view_impl_; | 
 |  71  | 
|  70   MainFrameObserver main_frame_observer_; |  72   MainFrameObserver main_frame_observer_; | 
|  71  |  73  | 
|  72   // Set to true in DidFinishDocumentLoad(). 'main' is only executed once this |  74   // Set to true in DidFinishDocumentLoad(). 'main' is only executed once this | 
|  73   // happens. |  75   // happens. | 
|  74   bool did_finish_document_load_; |  76   bool did_finish_document_load_; | 
|  75  |  77  | 
|  76   // If SetBrowserHandle() is invoked before the document finishes loading the |  78   // If SetBrowserHandle() is invoked before the document finishes loading the | 
|  77   // MessagePipeHandle is stored here. When the document finishes loading |  79   // MessagePipeHandle is stored here. When the document finishes loading | 
|  78   // SetHandleOnContextState() is invoked to send the handle to the |  80   // SetHandleOnContextState() is invoked to send the handle to the | 
|  79   // WebUIMojoContextState and ultimately the page. |  81   // WebUIMojoContextState and ultimately the page. | 
|  80   mojo::ScopedMessagePipeHandle pending_handle_; |  82   mojo::ScopedMessagePipeHandle pending_handle_; | 
|  81  |  83  | 
|  82   DISALLOW_COPY_AND_ASSIGN(WebUIMojo); |  84   DISALLOW_COPY_AND_ASSIGN(WebUIMojo); | 
|  83 }; |  85 }; | 
|  84  |  86  | 
|  85 }  // namespace content |  87 }  // namespace content | 
|  86  |  88  | 
|  87 #endif  // CONTENT_RENDERER_WEB_UI_MOJO_H_ |  89 #endif  // CONTENT_RENDERER_WEB_UI_MOJO_H_ | 
| OLD | NEW |