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

Side by Side Diff: mandoline/ui/phone_ui/phone_browser_application_delegate.cc

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 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
« no previous file with comments | « mandoline/ui/phone_ui/phone_browser_application_delegate.h ('k') | mash/wm/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mandoline/ui/phone_ui/phone_browser_application_delegate.h"
6
7 #include "base/command_line.h"
8 #include "components/mus/public/cpp/window.h"
9 #include "components/mus/public/cpp/window_tree_connection.h"
10 #include "components/mus/public/cpp/window_tree_host_factory.h"
11 #include "mojo/converters/geometry/geometry_type_converters.h"
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
13 #include "mojo/shell/public/cpp/connection.h"
14 #include "mojo/shell/public/cpp/shell.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "url/gurl.h"
17
18 namespace mandoline {
19
20 ////////////////////////////////////////////////////////////////////////////////
21 // PhoneBrowserApplicationDelegate, public:
22
23 PhoneBrowserApplicationDelegate::PhoneBrowserApplicationDelegate()
24 : shell_(nullptr),
25 root_(nullptr),
26 content_(nullptr),
27 web_view_(this),
28 default_url_("http://www.google.com/") {
29 }
30
31 PhoneBrowserApplicationDelegate::~PhoneBrowserApplicationDelegate() {
32 if (root_)
33 root_->RemoveObserver(this);
34 }
35
36 ////////////////////////////////////////////////////////////////////////////////
37 // PhoneBrowserApplicationDelegate, mojo::ShellClient implementation:
38
39 void PhoneBrowserApplicationDelegate::Initialize(mojo::Shell* shell,
40 const std::string& url,
41 uint32_t id) {
42 shell_ = shell;
43
44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
45 for (const auto& arg : command_line->GetArgs()) {
46 GURL url(arg);
47 if (url.is_valid()) {
48 default_url_ = url.spec();
49 break;
50 }
51 }
52 mus::CreateWindowTreeHost(shell_, this, &host_, nullptr, nullptr);
53 }
54
55 bool PhoneBrowserApplicationDelegate::AcceptConnection(
56 mojo::Connection* connection) {
57 connection->AddService<LaunchHandler>(this);
58 return true;
59 }
60
61 ////////////////////////////////////////////////////////////////////////////////
62 // PhoneBrowserApplicationDelegate, LaunchHandler implementation:
63
64 void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) {
65 mojo::URLRequestPtr request(mojo::URLRequest::New());
66 request->url = url;
67 web_view_.web_view()->LoadRequest(request.Pass());
68 }
69
70 ////////////////////////////////////////////////////////////////////////////////
71 // PhoneBrowserApplicationDelegate, mus::WindowTreeDelegate implementation:
72
73 void PhoneBrowserApplicationDelegate::OnEmbed(mus::Window* root) {
74 CHECK(!root_);
75 root_ = root;
76 content_ = root->connection()->NewWindow();
77 root->AddChild(content_);
78 content_->SetBounds(root->bounds());
79 content_->SetVisible(true);
80 root->AddObserver(this);
81
82 host_->SetSize(mojo::Size::From(gfx::Size(320, 640)));
83 web_view_.Init(shell_, content_);
84 LaunchURL(default_url_);
85 }
86
87 void PhoneBrowserApplicationDelegate::OnConnectionLost(
88 mus::WindowTreeConnection* connection) {}
89
90 ////////////////////////////////////////////////////////////////////////////////
91 // PhoneBrowserApplicationDelegate, mus::WindowObserver implementation:
92
93 void PhoneBrowserApplicationDelegate::OnWindowBoundsChanged(
94 mus::Window* view,
95 const gfx::Rect& old_bounds,
96 const gfx::Rect& new_bounds) {
97 CHECK_EQ(view, root_);
98 content_->SetBounds(gfx::Rect(new_bounds.size()));
99 }
100
101 ////////////////////////////////////////////////////////////////////////////////
102 // PhoneBrowserApplicationDelegate,
103 // web_view::mojom::WebViewClient implementation:
104
105 void PhoneBrowserApplicationDelegate::TopLevelNavigateRequest(
106 mojo::URLRequestPtr request) {
107 web_view_.web_view()->LoadRequest(request.Pass());
108 }
109
110 void PhoneBrowserApplicationDelegate::TopLevelNavigationStarted(
111 const mojo::String& url) {}
112 void PhoneBrowserApplicationDelegate::LoadingStateChanged(bool is_loading,
113 double progress) {}
114
115 void PhoneBrowserApplicationDelegate::BackForwardChanged(
116 web_view::mojom::ButtonState back_button,
117 web_view::mojom::ButtonState forward_button) {
118 // ...
119 }
120
121 void PhoneBrowserApplicationDelegate::TitleChanged(const mojo::String& title) {
122 // ...
123 }
124
125 ////////////////////////////////////////////////////////////////////////////////
126 // PhoneBrowserApplicationDelegate,
127 // mojo::InterfaceFactory<LaunchHandler> implementation:
128
129 void PhoneBrowserApplicationDelegate::Create(
130 mojo::Connection* connection,
131 mojo::InterfaceRequest<LaunchHandler> request) {
132 launch_handler_bindings_.AddBinding(this, request.Pass());
133 }
134
135 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/ui/phone_ui/phone_browser_application_delegate.h ('k') | mash/wm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698