OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/phone_ui/phone_browser_application_delegate.h" | 5 #include "mandoline/ui/phone_ui/phone_browser_application_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "components/mus/public/cpp/view.h" | 8 #include "components/mus/public/cpp/view.h" |
9 #include "components/mus/public/cpp/view_tree_connection.h" | 9 #include "components/mus/public/cpp/view_tree_connection.h" |
10 #include "components/mus/public/cpp/view_tree_host_factory.h" | 10 #include "components/mus/public/cpp/view_tree_host_factory.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 app_ = app; | 40 app_ = app; |
41 | 41 |
42 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 42 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
43 for (const auto& arg : command_line->GetArgs()) { | 43 for (const auto& arg : command_line->GetArgs()) { |
44 GURL url(arg); | 44 GURL url(arg); |
45 if (url.is_valid()) { | 45 if (url.is_valid()) { |
46 default_url_ = url.spec(); | 46 default_url_ = url.spec(); |
47 break; | 47 break; |
48 } | 48 } |
49 } | 49 } |
50 mus::CreateSingleViewTreeHost(app_, this, &host_); | 50 mojo::CreateSingleViewTreeHost(app_, this, &host_); |
51 } | 51 } |
52 | 52 |
53 bool PhoneBrowserApplicationDelegate::ConfigureIncomingConnection( | 53 bool PhoneBrowserApplicationDelegate::ConfigureIncomingConnection( |
54 mojo::ApplicationConnection* connection) { | 54 mojo::ApplicationConnection* connection) { |
55 connection->AddService<LaunchHandler>(this); | 55 connection->AddService<LaunchHandler>(this); |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
60 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: | 60 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: |
61 | 61 |
62 void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) { | 62 void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) { |
63 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 63 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
64 request->url = url; | 64 request->url = url; |
65 web_view_.web_view()->LoadRequest(request.Pass()); | 65 web_view_.web_view()->LoadRequest(request.Pass()); |
66 } | 66 } |
67 | 67 |
68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
69 // PhoneBrowserApplicationDelegate, mus::ViewTreeDelegate implementation: | 69 // PhoneBrowserApplicationDelegate, mojo::ViewTreeDelegate implementation: |
70 | 70 |
71 void PhoneBrowserApplicationDelegate::OnEmbed(mus::View* root) { | 71 void PhoneBrowserApplicationDelegate::OnEmbed(mojo::View* root) { |
72 CHECK(!root_); | 72 CHECK(!root_); |
73 root_ = root; | 73 root_ = root; |
74 content_ = root->connection()->CreateView(); | 74 content_ = root->connection()->CreateView(); |
75 root->AddChild(content_); | 75 root->AddChild(content_); |
76 content_->SetBounds(root->bounds()); | 76 content_->SetBounds(root->bounds()); |
77 content_->SetVisible(true); | 77 content_->SetVisible(true); |
78 root->AddObserver(this); | 78 root->AddObserver(this); |
79 | 79 |
80 host_->SetSize(mojo::Size::From(gfx::Size(320, 640))); | 80 host_->SetSize(mojo::Size::From(gfx::Size(320, 640))); |
81 web_view_.Init(app_, content_); | 81 web_view_.Init(app_, content_); |
82 LaunchURL(default_url_); | 82 LaunchURL(default_url_); |
83 } | 83 } |
84 | 84 |
85 void PhoneBrowserApplicationDelegate::OnConnectionLost( | 85 void PhoneBrowserApplicationDelegate::OnConnectionLost( |
86 mus::ViewTreeConnection* connection) {} | 86 mojo::ViewTreeConnection* connection) { |
| 87 } |
87 | 88 |
88 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
89 // PhoneBrowserApplicationDelegate, mus::ViewObserver implementation: | 90 // PhoneBrowserApplicationDelegate, mojo::ViewObserver implementation: |
90 | 91 |
91 void PhoneBrowserApplicationDelegate::OnViewBoundsChanged( | 92 void PhoneBrowserApplicationDelegate::OnViewBoundsChanged( |
92 mus::View* view, | 93 mojo::View* view, |
93 const mojo::Rect& old_bounds, | 94 const mojo::Rect& old_bounds, |
94 const mojo::Rect& new_bounds) { | 95 const mojo::Rect& new_bounds) { |
95 CHECK_EQ(view, root_); | 96 CHECK_EQ(view, root_); |
96 content_->SetBounds( | 97 content_->SetBounds( |
97 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); | 98 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); |
98 } | 99 } |
99 | 100 |
100 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
101 // PhoneBrowserApplicationDelegate, | 102 // PhoneBrowserApplicationDelegate, |
102 // web_view::mojom::WebViewClient implementation: | 103 // web_view::mojom::WebViewClient implementation: |
(...skipping 26 matching lines...) Expand all Loading... |
129 // PhoneBrowserApplicationDelegate, | 130 // PhoneBrowserApplicationDelegate, |
130 // mojo::InterfaceFactory<LaunchHandler> implementation: | 131 // mojo::InterfaceFactory<LaunchHandler> implementation: |
131 | 132 |
132 void PhoneBrowserApplicationDelegate::Create( | 133 void PhoneBrowserApplicationDelegate::Create( |
133 mojo::ApplicationConnection* connection, | 134 mojo::ApplicationConnection* connection, |
134 mojo::InterfaceRequest<LaunchHandler> request) { | 135 mojo::InterfaceRequest<LaunchHandler> request) { |
135 launch_handler_bindings_.AddBinding(this, request.Pass()); | 136 launch_handler_bindings_.AddBinding(this, request.Pass()); |
136 } | 137 } |
137 | 138 |
138 } // namespace mandoline | 139 } // namespace mandoline |
OLD | NEW |