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

Side by Side Diff: mojo/services/html_viewer/html_viewer.cc

Issue 460863002: Rename Node to View in the View Manager mojom & client lib. Service TBD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 | Annotate | Revision Log
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 #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"
11 #include "mojo/services/html_viewer/html_document_view.h" 11 #include "mojo/services/html_viewer/html_document_view.h"
12 #include "mojo/services/public/cpp/view_manager/node.h"
13 #include "mojo/services/public/cpp/view_manager/types.h" 12 #include "mojo/services/public/cpp/view_manager/types.h"
13 #include "mojo/services/public/cpp/view_manager/view.h"
14 #include "mojo/services/public/cpp/view_manager/view_manager.h" 14 #include "mojo/services/public/cpp/view_manager/view_manager.h"
15 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" 15 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
17 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" 17 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
18 #include "third_party/WebKit/public/web/WebKit.h" 18 #include "third_party/WebKit/public/web/WebKit.h"
19 19
20 namespace mojo { 20 namespace mojo {
21 21
22 class HTMLViewer; 22 class HTMLViewer;
23 23
24 class NavigatorImpl : public InterfaceImpl<Navigator> { 24 class NavigatorImpl : public InterfaceImpl<Navigator> {
25 public: 25 public:
26 explicit NavigatorImpl(HTMLViewer* viewer) : viewer_(viewer) {} 26 explicit NavigatorImpl(HTMLViewer* viewer) : viewer_(viewer) {}
27 virtual ~NavigatorImpl() {} 27 virtual ~NavigatorImpl() {}
28 28
29 private: 29 private:
30 // Overridden from Navigator: 30 // Overridden from Navigator:
31 virtual void Navigate( 31 virtual void Navigate(
32 uint32_t node_id, 32 uint32_t view_id,
33 NavigationDetailsPtr navigation_details, 33 NavigationDetailsPtr navigation_details,
34 ResponseDetailsPtr response_details) OVERRIDE; 34 ResponseDetailsPtr response_details) OVERRIDE;
35 35
36 HTMLViewer* viewer_; 36 HTMLViewer* viewer_;
37 37
38 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); 38 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
39 }; 39 };
40 40
41 class HTMLViewer : public ApplicationDelegate, public ViewManagerDelegate { 41 class HTMLViewer : public ApplicationDelegate, public ViewManagerDelegate {
42 public: 42 public:
(...skipping 22 matching lines...) Expand all
65 65
66 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 66 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
67 OVERRIDE { 67 OVERRIDE {
68 connection->AddService(&navigator_factory_); 68 connection->AddService(&navigator_factory_);
69 connection->AddService(&view_manager_client_factory_); 69 connection->AddService(&view_manager_client_factory_);
70 return true; 70 return true;
71 } 71 }
72 72
73 // Overridden from ViewManagerDelegate: 73 // Overridden from ViewManagerDelegate:
74 virtual void OnEmbed(ViewManager* view_manager, 74 virtual void OnEmbed(ViewManager* view_manager,
75 Node* root, 75 View* root,
76 ServiceProviderImpl* exported_services, 76 ServiceProviderImpl* exported_services,
77 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { 77 scoped_ptr<ServiceProvider> imported_services) OVERRIDE {
78 document_view_ = new HTMLDocumentView( 78 document_view_ = new HTMLDocumentView(
79 application_impl_->ConnectToApplication("mojo://mojo_window_manager/")-> 79 application_impl_->ConnectToApplication("mojo://mojo_window_manager/")->
80 GetServiceProvider(), 80 GetServiceProvider(),
81 view_manager); 81 view_manager);
82 document_view_->AttachToNode(root); 82 document_view_->AttachToView(root);
83 MaybeLoad(); 83 MaybeLoad();
84 } 84 }
85 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { 85 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
86 base::MessageLoop::current()->Quit(); 86 base::MessageLoop::current()->Quit();
87 } 87 }
88 88
89 void MaybeLoad() { 89 void MaybeLoad() {
90 if (document_view_ && response_details_) 90 if (document_view_ && response_details_)
91 document_view_->Load(response_details_->response.Pass()); 91 document_view_->Load(response_details_->response.Pass());
92 } 92 }
93 93
94 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; 94 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
95 ApplicationImpl* application_impl_; 95 ApplicationImpl* application_impl_;
96 96
97 // TODO(darin): Figure out proper ownership of this instance. 97 // TODO(darin): Figure out proper ownership of this instance.
98 HTMLDocumentView* document_view_; 98 HTMLDocumentView* document_view_;
99 ResponseDetailsPtr response_details_; 99 ResponseDetailsPtr response_details_;
100 InterfaceFactoryImplWithContext<NavigatorImpl, HTMLViewer> navigator_factory_; 100 InterfaceFactoryImplWithContext<NavigatorImpl, HTMLViewer> navigator_factory_;
101 ViewManagerClientFactory view_manager_client_factory_; 101 ViewManagerClientFactory view_manager_client_factory_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); 103 DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
104 }; 104 };
105 105
106 void NavigatorImpl::Navigate( 106 void NavigatorImpl::Navigate(
107 uint32_t node_id, 107 uint32_t view_id,
108 NavigationDetailsPtr navigation_details, 108 NavigationDetailsPtr navigation_details,
109 ResponseDetailsPtr response_details) { 109 ResponseDetailsPtr response_details) {
110 viewer_->Load(response_details.Pass()); 110 viewer_->Load(response_details.Pass());
111 } 111 }
112 112
113 // static 113 // static
114 ApplicationDelegate* ApplicationDelegate::Create() { 114 ApplicationDelegate* ApplicationDelegate::Create() {
115 return new HTMLViewer; 115 return new HTMLViewer;
116 } 116 }
117 117
118 } 118 }
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/html_document_view.cc ('k') | mojo/services/public/cpp/view_manager/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698