| 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/connection.h" |
| 14 #include "mojo/shell/public/cpp/shell.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 : shell_(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::ShellClient implementation: |
| 38 | 38 |
| 39 void PhoneBrowserApplicationDelegate::Initialize(mojo::Shell* shell, | 39 void PhoneBrowserApplicationDelegate::Initialize(mojo::Shell* shell, |
| 40 const std::string& url, | 40 const std::string& url, |
| 41 uint32_t id) { | 41 uint32_t id) { |
| 42 shell_ = shell; | 42 shell_ = shell; |
| 43 | 43 |
| 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 45 for (const auto& arg : command_line->GetArgs()) { | 45 for (const auto& arg : command_line->GetArgs()) { |
| 46 GURL url(arg); | 46 GURL url(arg); |
| 47 if (url.is_valid()) { | 47 if (url.is_valid()) { |
| 48 default_url_ = url.spec(); | 48 default_url_ = url.spec(); |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 mus::CreateWindowTreeHost(shell_, this, &host_, nullptr, nullptr); | 52 mus::CreateWindowTreeHost(shell_, this, &host_, nullptr, nullptr); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool PhoneBrowserApplicationDelegate::AcceptConnection( | 55 bool PhoneBrowserApplicationDelegate::AcceptConnection( |
| 56 mojo::ApplicationConnection* connection) { | 56 mojo::Connection* connection) { |
| 57 connection->AddService<LaunchHandler>(this); | 57 connection->AddService<LaunchHandler>(this); |
| 58 return true; | 58 return true; |
| 59 } | 59 } |
| 60 | 60 |
| 61 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
| 62 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: | 62 // PhoneBrowserApplicationDelegate, LaunchHandler implementation: |
| 63 | 63 |
| 64 void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) { | 64 void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) { |
| 65 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 65 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 66 request->url = url; | 66 request->url = url; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 void PhoneBrowserApplicationDelegate::TitleChanged(const mojo::String& title) { | 121 void PhoneBrowserApplicationDelegate::TitleChanged(const mojo::String& title) { |
| 122 // ... | 122 // ... |
| 123 } | 123 } |
| 124 | 124 |
| 125 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
| 126 // PhoneBrowserApplicationDelegate, | 126 // PhoneBrowserApplicationDelegate, |
| 127 // mojo::InterfaceFactory<LaunchHandler> implementation: | 127 // mojo::InterfaceFactory<LaunchHandler> implementation: |
| 128 | 128 |
| 129 void PhoneBrowserApplicationDelegate::Create( | 129 void PhoneBrowserApplicationDelegate::Create( |
| 130 mojo::ApplicationConnection* connection, | 130 mojo::Connection* connection, |
| 131 mojo::InterfaceRequest<LaunchHandler> request) { | 131 mojo::InterfaceRequest<LaunchHandler> request) { |
| 132 launch_handler_bindings_.AddBinding(this, request.Pass()); | 132 launch_handler_bindings_.AddBinding(this, request.Pass()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace mandoline | 135 } // namespace mandoline |
| OLD | NEW |