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

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

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 | « services/navigation/view_impl.h ('k') | services/shell/public/cpp/connection.h » ('j') | 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/interstitial_page.h" 9 #include "content/public/browser/interstitial_page.h"
10 #include "content/public/browser/interstitial_page_delegate.h" 10 #include "content/public/browser/interstitial_page_delegate.h"
11 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "services/shell/public/cpp/connector.h"
18 #include "services/ui/public/cpp/window_tree_client.h" 19 #include "services/ui/public/cpp/window_tree_client.h"
19 #include "ui/views/controls/webview/webview.h" 20 #include "ui/views/controls/webview/webview.h"
20 #include "ui/views/mus/native_widget_mus.h" 21 #include "ui/views/mus/native_widget_mus.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 namespace navigation { 25 namespace navigation {
25 namespace { 26 namespace {
26 27
27 class InterstitialPageDelegate : public content::InterstitialPageDelegate { 28 class InterstitialPageDelegate : public content::InterstitialPageDelegate {
(...skipping 21 matching lines...) Expand all
49 mojom::NavigationEntryPtr entry_ptr(mojom::NavigationEntry::New()); 50 mojom::NavigationEntryPtr entry_ptr(mojom::NavigationEntry::New());
50 entry_ptr->id = entry.GetUniqueID(); 51 entry_ptr->id = entry.GetUniqueID();
51 entry_ptr->url = entry.GetURL(); 52 entry_ptr->url = entry.GetURL();
52 entry_ptr->title = base::UTF16ToUTF8(entry.GetTitle()); 53 entry_ptr->title = base::UTF16ToUTF8(entry.GetTitle());
53 entry_ptr->redirect_chain = entry.GetRedirectChain(); 54 entry_ptr->redirect_chain = entry.GetRedirectChain();
54 return entry_ptr; 55 return entry_ptr;
55 } 56 }
56 57
57 } // namespace 58 } // namespace
58 59
59 ViewImpl::ViewImpl(shell::Connector* connector, 60 ViewImpl::ViewImpl(std::unique_ptr<shell::Connector> connector,
60 const std::string& client_user_id, 61 const std::string& client_user_id,
61 mojom::ViewClientPtr client, 62 mojom::ViewClientPtr client,
62 mojom::ViewRequest request, 63 mojom::ViewRequest request,
63 std::unique_ptr<shell::ServiceContextRef> ref) 64 std::unique_ptr<shell::ServiceContextRef> ref)
64 : connector_(connector), 65 : connector_(std::move(connector)),
65 binding_(this, std::move(request)), 66 binding_(this, std::move(request)),
66 client_(std::move(client)), 67 client_(std::move(client)),
67 ref_(std::move(ref)), 68 ref_(std::move(ref)),
68 web_view_(new views::WebView( 69 web_view_(new views::WebView(
69 content::BrowserContext::GetBrowserContextForShellUserId( 70 content::BrowserContext::GetBrowserContextForShellUserId(
70 client_user_id))) { 71 client_user_id))) {
71 web_view_->GetWebContents()->SetDelegate(this); 72 web_view_->GetWebContents()->SetDelegate(this);
72 const content::NavigationController* controller = 73 const content::NavigationController* controller =
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,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 bool* was_blocked) { 142 bool* was_blocked) {
142 mojom::ViewClientPtr client; 143 mojom::ViewClientPtr client;
143 mojom::ViewPtr view; 144 mojom::ViewPtr view;
144 mojom::ViewRequest view_request = GetProxy(&view); 145 mojom::ViewRequest view_request = GetProxy(&view);
145 client_->ViewCreated(std::move(view), GetProxy(&client), 146 client_->ViewCreated(std::move(view), GetProxy(&client),
146 disposition == NEW_POPUP, initial_rect, user_gesture); 147 disposition == NEW_POPUP, initial_rect, user_gesture);
147 148
148 const std::string new_user_id = 149 const std::string new_user_id =
149 content::BrowserContext::GetShellUserIdFor( 150 content::BrowserContext::GetShellUserIdFor(
150 new_contents->GetBrowserContext()); 151 new_contents->GetBrowserContext());
151 ViewImpl* impl = new ViewImpl(connector_, new_user_id, std::move(client), 152 ViewImpl* impl = new ViewImpl(
152 std::move(view_request), ref_->Clone()); 153 connector_->Clone(), new_user_id, std::move(client),
154 std::move(view_request), ref_->Clone());
153 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl 155 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl
154 // with |new_contents| instead. 156 // with |new_contents| instead.
155 impl->web_view_->SetWebContents(new_contents); 157 impl->web_view_->SetWebContents(new_contents);
156 impl->web_view_->GetWebContents()->SetDelegate(impl); 158 impl->web_view_->GetWebContents()->SetDelegate(impl);
157 159
158 // TODO(beng): this reply is currently synchronous, figure out a fix. 160 // TODO(beng): this reply is currently synchronous, figure out a fix.
159 if (was_blocked) 161 if (was_blocked)
160 *was_blocked = false; 162 *was_blocked = false;
161 } 163 }
162 164
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 267 }
266 268
267 void ViewImpl::OnEmbed(ui::Window* root) { 269 void ViewImpl::OnEmbed(ui::Window* root) {
268 DCHECK(!widget_.get()); 270 DCHECK(!widget_.get());
269 widget_.reset(new views::Widget); 271 widget_.reset(new views::Widget);
270 views::Widget::InitParams params( 272 views::Widget::InitParams params(
271 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 273 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
272 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 274 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
273 params.delegate = this; 275 params.delegate = this;
274 params.native_widget = new views::NativeWidgetMus( 276 params.native_widget = new views::NativeWidgetMus(
275 widget_.get(), connector_, root, ui::mojom::SurfaceType::DEFAULT); 277 widget_.get(), connector_.get(), root, ui::mojom::SurfaceType::DEFAULT);
276 widget_->Init(params); 278 widget_->Init(params);
277 widget_->Show(); 279 widget_->Show();
278 } 280 }
279 281
280 void ViewImpl::OnDidDestroyClient(ui::WindowTreeClient* client) {} 282 void ViewImpl::OnDidDestroyClient(ui::WindowTreeClient* client) {}
281 void ViewImpl::OnEventObserved(const ui::Event& event, ui::Window* target) {} 283 void ViewImpl::OnEventObserved(const ui::Event& event, ui::Window* target) {}
282 284
283 views::View* ViewImpl::GetContentsView() { 285 views::View* ViewImpl::GetContentsView() {
284 return web_view_; 286 return web_view_;
285 } 287 }
286 288
287 views::Widget* ViewImpl::GetWidget() { 289 views::Widget* ViewImpl::GetWidget() {
288 return web_view_->GetWidget(); 290 return web_view_->GetWidget();
289 } 291 }
290 292
291 const views::Widget* ViewImpl::GetWidget() const { 293 const views::Widget* ViewImpl::GetWidget() const {
292 return web_view_->GetWidget(); 294 return web_view_->GetWidget();
293 } 295 }
294 296
295 } // navigation 297 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/view_impl.h ('k') | services/shell/public/cpp/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698