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 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "mojo/public/cpp/application/application_connection.h" | 6 #include "mojo/public/cpp/application/application_connection.h" |
7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
9 #include "mojo/public/cpp/application/interface_factory_impl.h" | 9 #include "mojo/public/cpp/application/interface_factory_impl.h" |
10 #include "mojo/services/html_viewer/blink_platform_impl.h" | 10 #include "mojo/services/html_viewer/blink_platform_impl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 public: | 43 public: |
44 HTMLViewer() | 44 HTMLViewer() |
45 : application_impl_(NULL), | 45 : application_impl_(NULL), |
46 document_view_(NULL), | 46 document_view_(NULL), |
47 navigator_factory_(this), | 47 navigator_factory_(this), |
48 view_manager_client_factory_(this) {} | 48 view_manager_client_factory_(this) {} |
49 virtual ~HTMLViewer() { | 49 virtual ~HTMLViewer() { |
50 blink::shutdown(); | 50 blink::shutdown(); |
51 } | 51 } |
52 | 52 |
53 void Load(URLResponsePtr response) { | 53 void Load(ResponseDetailsPtr response_details) { |
54 // Need to wait for OnEmbed. | 54 // Need to wait for OnEmbed. |
55 response_ = response.Pass(); | 55 response_details_ = response_details.Pass(); |
56 MaybeLoad(); | 56 MaybeLoad(); |
57 } | 57 } |
58 | 58 |
59 private: | 59 private: |
60 // Overridden from ApplicationDelegate: | 60 // Overridden from ApplicationDelegate: |
61 virtual void Initialize(ApplicationImpl* app) OVERRIDE { | 61 virtual void Initialize(ApplicationImpl* app) OVERRIDE { |
62 application_impl_ = app; | 62 application_impl_ = app; |
63 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); | 63 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); |
64 blink::initialize(blink_platform_impl_.get()); | 64 blink::initialize(blink_platform_impl_.get()); |
65 } | 65 } |
(...skipping 12 matching lines...) Expand all Loading... |
78 GetServiceProvider(), | 78 GetServiceProvider(), |
79 view_manager); | 79 view_manager); |
80 document_view_->AttachToNode(root); | 80 document_view_->AttachToNode(root); |
81 MaybeLoad(); | 81 MaybeLoad(); |
82 } | 82 } |
83 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { | 83 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { |
84 base::MessageLoop::current()->Quit(); | 84 base::MessageLoop::current()->Quit(); |
85 } | 85 } |
86 | 86 |
87 void MaybeLoad() { | 87 void MaybeLoad() { |
88 if (document_view_ && response_) | 88 if (document_view_ && response_details_) |
89 document_view_->Load(response_.Pass()); | 89 document_view_->Load(response_details_->response.Pass()); |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; | 92 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; |
93 ApplicationImpl* application_impl_; | 93 ApplicationImpl* application_impl_; |
94 | 94 |
95 // TODO(darin): Figure out proper ownership of this instance. | 95 // TODO(darin): Figure out proper ownership of this instance. |
96 HTMLDocumentView* document_view_; | 96 HTMLDocumentView* document_view_; |
97 URLResponsePtr response_; | 97 ResponseDetailsPtr response_details_; |
98 InterfaceFactoryImplWithContext<NavigatorImpl, HTMLViewer> navigator_factory_; | 98 InterfaceFactoryImplWithContext<NavigatorImpl, HTMLViewer> navigator_factory_; |
99 ViewManagerClientFactory view_manager_client_factory_; | 99 ViewManagerClientFactory view_manager_client_factory_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 101 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
102 }; | 102 }; |
103 | 103 |
104 void NavigatorImpl::Navigate( | 104 void NavigatorImpl::Navigate( |
105 uint32_t node_id, | 105 uint32_t node_id, |
106 NavigationDetailsPtr navigation_details, | 106 NavigationDetailsPtr navigation_details, |
107 ResponseDetailsPtr response_details) { | 107 ResponseDetailsPtr response_details) { |
108 viewer_->Load(response_details->response.Pass()); | 108 viewer_->Load(response_details.Pass()); |
109 } | 109 } |
110 | 110 |
111 // static | 111 // static |
112 ApplicationDelegate* ApplicationDelegate::Create() { | 112 ApplicationDelegate* ApplicationDelegate::Create() { |
113 return new HTMLViewer; | 113 return new HTMLViewer; |
114 } | 114 } |
115 | 115 |
116 } | 116 } |
OLD | NEW |