| 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 mojo::CreateSingleViewTreeHost(app_, this, &host_); | 50 mus::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, mojo::ViewTreeDelegate implementation: | 69 // PhoneBrowserApplicationDelegate, mus::ViewTreeDelegate implementation: |
| 70 | 70 |
| 71 void PhoneBrowserApplicationDelegate::OnEmbed(mojo::View* root) { | 71 void PhoneBrowserApplicationDelegate::OnEmbed(mus::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 mojo::ViewTreeConnection* connection) { | 86 mus::ViewTreeConnection* connection) {} |
| 87 } | |
| 88 | 87 |
| 89 //////////////////////////////////////////////////////////////////////////////// | 88 //////////////////////////////////////////////////////////////////////////////// |
| 90 // PhoneBrowserApplicationDelegate, mojo::ViewObserver implementation: | 89 // PhoneBrowserApplicationDelegate, mus::ViewObserver implementation: |
| 91 | 90 |
| 92 void PhoneBrowserApplicationDelegate::OnViewBoundsChanged( | 91 void PhoneBrowserApplicationDelegate::OnViewBoundsChanged( |
| 93 mojo::View* view, | 92 mus::View* view, |
| 94 const mojo::Rect& old_bounds, | 93 const mojo::Rect& old_bounds, |
| 95 const mojo::Rect& new_bounds) { | 94 const mojo::Rect& new_bounds) { |
| 96 CHECK_EQ(view, root_); | 95 CHECK_EQ(view, root_); |
| 97 content_->SetBounds( | 96 content_->SetBounds( |
| 98 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); | 97 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); |
| 99 } | 98 } |
| 100 | 99 |
| 101 //////////////////////////////////////////////////////////////////////////////// | 100 //////////////////////////////////////////////////////////////////////////////// |
| 102 // PhoneBrowserApplicationDelegate, | 101 // PhoneBrowserApplicationDelegate, |
| 103 // web_view::mojom::WebViewClient implementation: | 102 // web_view::mojom::WebViewClient implementation: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 // PhoneBrowserApplicationDelegate, | 123 // PhoneBrowserApplicationDelegate, |
| 125 // mojo::InterfaceFactory<LaunchHandler> implementation: | 124 // mojo::InterfaceFactory<LaunchHandler> implementation: |
| 126 | 125 |
| 127 void PhoneBrowserApplicationDelegate::Create( | 126 void PhoneBrowserApplicationDelegate::Create( |
| 128 mojo::ApplicationConnection* connection, | 127 mojo::ApplicationConnection* connection, |
| 129 mojo::InterfaceRequest<LaunchHandler> request) { | 128 mojo::InterfaceRequest<LaunchHandler> request) { |
| 130 launch_handler_bindings_.AddBinding(this, request.Pass()); | 129 launch_handler_bindings_.AddBinding(this, request.Pass()); |
| 131 } | 130 } |
| 132 | 131 |
| 133 } // namespace mandoline | 132 } // namespace mandoline |
| OLD | NEW |