| 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/window.h" | 8 #include "components/mus/public/cpp/window.h" |
| 9 #include "components/mus/public/cpp/window_tree_connection.h" | 9 #include "components/mus/public/cpp/window_tree_connection.h" |
| 10 #include "components/mus/public/cpp/window_tree_host_factory.h" | 10 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 11 #include "mojo/converters/geometry/geometry_type_converters.h" | 11 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 13 #include "mojo/shell/public/cpp/application_connection.h" | 13 #include "mojo/shell/public/cpp/application_connection.h" |
| 14 #include "mojo/shell/public/cpp/application_impl.h" | 14 #include "mojo/shell/public/cpp/shell.h" |
| 15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace mandoline { | 18 namespace mandoline { |
| 19 | 19 |
| 20 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 21 // PhoneBrowserApplicationDelegate, public: | 21 // PhoneBrowserApplicationDelegate, public: |
| 22 | 22 |
| 23 PhoneBrowserApplicationDelegate::PhoneBrowserApplicationDelegate() | 23 PhoneBrowserApplicationDelegate::PhoneBrowserApplicationDelegate() |
| 24 : app_(nullptr), | 24 : shell_(nullptr), |
| 25 root_(nullptr), | 25 root_(nullptr), |
| 26 content_(nullptr), | 26 content_(nullptr), |
| 27 web_view_(this), | 27 web_view_(this), |
| 28 default_url_("http://www.google.com/") { | 28 default_url_("http://www.google.com/") { |
| 29 } | 29 } |
| 30 | 30 |
| 31 PhoneBrowserApplicationDelegate::~PhoneBrowserApplicationDelegate() { | 31 PhoneBrowserApplicationDelegate::~PhoneBrowserApplicationDelegate() { |
| 32 if (root_) | 32 if (root_) |
| 33 root_->RemoveObserver(this); | 33 root_->RemoveObserver(this); |
| 34 } | 34 } |
| 35 | 35 |
| 36 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
| 37 // PhoneBrowserApplicationDelegate, mojo::ApplicationDelegate implementation: | 37 // PhoneBrowserApplicationDelegate, mojo::ApplicationDelegate implementation: |
| 38 | 38 |
| 39 void PhoneBrowserApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { | 39 void PhoneBrowserApplicationDelegate::Initialize(mojo::Shell* shell, |
| 40 app_ = app; | 40 const std::string& url, |
| 41 uint32_t id) { |
| 42 shell_ = shell; |
| 41 | 43 |
| 42 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 43 for (const auto& arg : command_line->GetArgs()) { | 45 for (const auto& arg : command_line->GetArgs()) { |
| 44 GURL url(arg); | 46 GURL url(arg); |
| 45 if (url.is_valid()) { | 47 if (url.is_valid()) { |
| 46 default_url_ = url.spec(); | 48 default_url_ = url.spec(); |
| 47 break; | 49 break; |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 mus::CreateWindowTreeHost(app_, this, &host_, nullptr, nullptr); | 52 mus::CreateWindowTreeHost(shell_, this, &host_, nullptr, nullptr); |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool PhoneBrowserApplicationDelegate::AcceptConnection( | 55 bool PhoneBrowserApplicationDelegate::AcceptConnection( |
| 54 mojo::ApplicationConnection* connection) { | 56 mojo::ApplicationConnection* connection) { |
| 55 connection->AddService<LaunchHandler>(this); | 57 connection->AddService<LaunchHandler>(this); |
| 56 return true; | 58 return true; |
| 57 } | 59 } |
| 58 | 60 |
| 59 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
| 60 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: | 62 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 void PhoneBrowserApplicationDelegate::OnEmbed(mus::Window* root) { | 73 void PhoneBrowserApplicationDelegate::OnEmbed(mus::Window* root) { |
| 72 CHECK(!root_); | 74 CHECK(!root_); |
| 73 root_ = root; | 75 root_ = root; |
| 74 content_ = root->connection()->NewWindow(); | 76 content_ = root->connection()->NewWindow(); |
| 75 root->AddChild(content_); | 77 root->AddChild(content_); |
| 76 content_->SetBounds(root->bounds()); | 78 content_->SetBounds(root->bounds()); |
| 77 content_->SetVisible(true); | 79 content_->SetVisible(true); |
| 78 root->AddObserver(this); | 80 root->AddObserver(this); |
| 79 | 81 |
| 80 host_->SetSize(mojo::Size::From(gfx::Size(320, 640))); | 82 host_->SetSize(mojo::Size::From(gfx::Size(320, 640))); |
| 81 web_view_.Init(app_, content_); | 83 web_view_.Init(shell_, content_); |
| 82 LaunchURL(default_url_); | 84 LaunchURL(default_url_); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void PhoneBrowserApplicationDelegate::OnConnectionLost( | 87 void PhoneBrowserApplicationDelegate::OnConnectionLost( |
| 86 mus::WindowTreeConnection* connection) {} | 88 mus::WindowTreeConnection* connection) {} |
| 87 | 89 |
| 88 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 89 // PhoneBrowserApplicationDelegate, mus::WindowObserver implementation: | 91 // PhoneBrowserApplicationDelegate, mus::WindowObserver implementation: |
| 90 | 92 |
| 91 void PhoneBrowserApplicationDelegate::OnWindowBoundsChanged( | 93 void PhoneBrowserApplicationDelegate::OnWindowBoundsChanged( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // PhoneBrowserApplicationDelegate, | 126 // PhoneBrowserApplicationDelegate, |
| 125 // mojo::InterfaceFactory<LaunchHandler> implementation: | 127 // mojo::InterfaceFactory<LaunchHandler> implementation: |
| 126 | 128 |
| 127 void PhoneBrowserApplicationDelegate::Create( | 129 void PhoneBrowserApplicationDelegate::Create( |
| 128 mojo::ApplicationConnection* connection, | 130 mojo::ApplicationConnection* connection, |
| 129 mojo::InterfaceRequest<LaunchHandler> request) { | 131 mojo::InterfaceRequest<LaunchHandler> request) { |
| 130 launch_handler_bindings_.AddBinding(this, request.Pass()); | 132 launch_handler_bindings_.AddBinding(this, request.Pass()); |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace mandoline | 135 } // namespace mandoline |
| OLD | NEW |