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

Side by Side Diff: services/navigation/view_impl.cc

Issue 2585593002: Converts services/navigation to use aura-mus (Closed)
Patch Set: comment Created 4 years 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 | « services/navigation/view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/navigation/view_impl.h" 5 #include "services/navigation/view_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/interstitial_page.h" 10 #include "content/public/browser/interstitial_page.h"
11 #include "content/public/browser/interstitial_page_delegate.h" 11 #include "content/public/browser/interstitial_page_delegate.h"
12 #include "content/public/browser/navigation_controller.h" 12 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/navigation_details.h" 13 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/navigation_entry.h" 14 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "services/service_manager/public/cpp/connector.h" 19 #include "services/service_manager/public/cpp/connector.h"
20 #include "services/ui/public/cpp/window_tree_client.h" 20 #include "ui/aura/mus/window_tree_client.h"
21 #include "ui/aura/mus/window_tree_host_mus.h"
21 #include "ui/views/controls/webview/webview.h" 22 #include "ui/views/controls/webview/webview.h"
22 #include "ui/views/mus/native_widget_mus.h" 23 #include "ui/views/mus/native_widget_mus.h"
23 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 namespace navigation { 27 namespace navigation {
27 namespace { 28 namespace {
28 29
29 class InterstitialPageDelegate : public content::InterstitialPageDelegate { 30 class InterstitialPageDelegate : public content::InterstitialPageDelegate {
30 public: 31 public:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 &web_view_->GetWebContents()->GetController(); 74 &web_view_->GetWebContents()->GetController();
74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 75 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
75 content::Source<content::NavigationController>(controller)); 76 content::Source<content::NavigationController>(controller));
76 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 77 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
77 content::Source<content::NavigationController>(controller)); 78 content::Source<content::NavigationController>(controller));
78 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, 79 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED,
79 content::Source<content::NavigationController>(controller)); 80 content::Source<content::NavigationController>(controller));
80 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, 81 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED,
81 content::Source<content::NavigationController>(controller)); 82 content::Source<content::NavigationController>(controller));
82 } 83 }
83 ViewImpl::~ViewImpl() {} 84
85 ViewImpl::~ViewImpl() {
86 DeleteTreeAndWidget();
87 }
88
89 void ViewImpl::DeleteTreeAndWidget() {
90 widget_.reset();
91 window_tree_host_.reset();
92 window_tree_client_.reset();
93 }
84 94
85 void ViewImpl::NavigateTo(const GURL& url) { 95 void ViewImpl::NavigateTo(const GURL& url) {
86 web_view_->GetWebContents()->GetController().LoadURL( 96 web_view_->GetWebContents()->GetController().LoadURL(
87 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 97 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
88 } 98 }
89 99
90 void ViewImpl::GoBack() { 100 void ViewImpl::GoBack() {
91 web_view_->GetWebContents()->GetController().GoBack(); 101 web_view_->GetWebContents()->GetController().GoBack();
92 } 102 }
93 103
(...skipping 10 matching lines...) Expand all
104 web_view_->GetWebContents()->GetController().Reload(true); 114 web_view_->GetWebContents()->GetController().Reload(true);
105 else 115 else
106 web_view_->GetWebContents()->GetController().ReloadBypassingCache(true); 116 web_view_->GetWebContents()->GetController().ReloadBypassingCache(true);
107 } 117 }
108 118
109 void ViewImpl::Stop() { 119 void ViewImpl::Stop() {
110 web_view_->GetWebContents()->Stop(); 120 web_view_->GetWebContents()->Stop();
111 } 121 }
112 122
113 void ViewImpl::GetWindowTreeClient(ui::mojom::WindowTreeClientRequest request) { 123 void ViewImpl::GetWindowTreeClient(ui::mojom::WindowTreeClientRequest request) {
114 window_tree_client_ = 124 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(
115 base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request)); 125 connector_.get(), this, nullptr, std::move(request));
116 } 126 }
117 127
118 void ViewImpl::ShowInterstitial(const std::string& html) { 128 void ViewImpl::ShowInterstitial(const std::string& html) {
119 content::InterstitialPage* interstitial = 129 content::InterstitialPage* interstitial =
120 content::InterstitialPage::Create(web_view_->GetWebContents(), 130 content::InterstitialPage::Create(web_view_->GetWebContents(),
121 false, 131 false,
122 GURL(), 132 GURL(),
123 new InterstitialPageDelegate(html)); 133 new InterstitialPageDelegate(html));
124 interstitial->Show(); 134 interstitial->Show();
125 } 135 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 content::Details<content::PrunedDetails>(details).ptr(); 261 content::Details<content::PrunedDetails>(details).ptr();
252 client_->NavigationListPruned(pd->from_front, pd->count); 262 client_->NavigationListPruned(pd->from_front, pd->count);
253 break; 263 break;
254 } 264 }
255 default: 265 default:
256 NOTREACHED(); 266 NOTREACHED();
257 break; 267 break;
258 } 268 }
259 } 269 }
260 270
261 void ViewImpl::OnEmbed(ui::Window* root) { 271 void ViewImpl::OnEmbed(
272 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
273 // TODO: Supplying a WindowTreeHostMus isn't particularly ideal in this case.
274 // In particular it would be nice if the WindowTreeClientDelegate could create
275 // its own WindowTreeHostMus, that way this code could directly create a
276 // DesktopWindowTreeTreeHostMus.
277 window_tree_host_ = std::move(window_tree_host);
262 DCHECK(!widget_.get()); 278 DCHECK(!widget_.get());
279 // TODO: fix this. The following won't work if multiple WindowTreeClients
280 // are used at the same time. The best fix is to have the ability to specify
281 // a WindowTreeClient when DesktopNativeWidgetAura is created so that it can
282 // create WindowPortMus with the correct client.
263 widget_.reset(new views::Widget); 283 widget_.reset(new views::Widget);
264 views::Widget::InitParams params( 284 views::Widget::InitParams params(
265 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 285 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
266 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 286 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
267 params.delegate = this; 287 params.delegate = this;
268 params.native_widget = new views::NativeWidgetMus(
269 widget_.get(), root, ui::mojom::CompositorFrameSinkType::DEFAULT);
270 widget_->Init(params); 288 widget_->Init(params);
271 widget_->Show(); 289 widget_->Show();
272 } 290 }
273 291
274 void ViewImpl::OnEmbedRootDestroyed(ui::Window* root) { 292 void ViewImpl::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) {
275 window_tree_client_.reset(); 293 DCHECK_EQ(window_tree_host, window_tree_host_.get());
294 DeleteTreeAndWidget();
276 } 295 }
277 296
278 void ViewImpl::OnLostConnection(ui::WindowTreeClient* client) { 297 void ViewImpl::OnLostConnection(aura::WindowTreeClient* client) {
279 window_tree_client_.reset(); 298 DeleteTreeAndWidget();
280 } 299 }
281 300
282 void ViewImpl::OnPointerEventObserved(const ui::PointerEvent& event, 301 void ViewImpl::OnPointerEventObserved(const ui::PointerEvent& event,
283 ui::Window* target) {} 302 aura::Window* target) {}
303
304 aura::client::CaptureClient* ViewImpl::GetCaptureClient() {
305 // TODO: wire this up. This typically comes from WMState.
306 return nullptr;
307 }
308
309 aura::PropertyConverter* ViewImpl::GetPropertyConverter() {
310 // TODO: wire this up.
311 return nullptr;
312 }
284 313
285 views::View* ViewImpl::GetContentsView() { 314 views::View* ViewImpl::GetContentsView() {
286 return web_view_; 315 return web_view_;
287 } 316 }
288 317
289 views::Widget* ViewImpl::GetWidget() { 318 views::Widget* ViewImpl::GetWidget() {
290 return web_view_->GetWidget(); 319 return web_view_->GetWidget();
291 } 320 }
292 321
293 const views::Widget* ViewImpl::GetWidget() const { 322 const views::Widget* ViewImpl::GetWidget() const {
294 return web_view_->GetWidget(); 323 return web_view_->GetWidget();
295 } 324 }
296 325
297 } // navigation 326 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698