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

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

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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/standalone/context.cc » ('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/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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 entry_ptr->title = base::UTF16ToUTF8(entry.GetTitle()); 54 entry_ptr->title = base::UTF16ToUTF8(entry.GetTitle());
55 entry_ptr->redirect_chain = entry.GetRedirectChain(); 55 entry_ptr->redirect_chain = entry.GetRedirectChain();
56 return entry_ptr; 56 return entry_ptr;
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 ViewImpl::ViewImpl(std::unique_ptr<shell::Connector> connector, 61 ViewImpl::ViewImpl(std::unique_ptr<shell::Connector> connector,
62 const std::string& client_user_id, 62 const std::string& client_user_id,
63 mojom::ViewClientPtr client, 63 mojom::ViewClientPtr client,
64 mojom::ViewRequest request,
65 std::unique_ptr<shell::ServiceContextRef> ref) 64 std::unique_ptr<shell::ServiceContextRef> ref)
66 : connector_(std::move(connector)), 65 : connector_(std::move(connector)),
67 binding_(this, std::move(request)),
68 client_(std::move(client)), 66 client_(std::move(client)),
69 ref_(std::move(ref)), 67 ref_(std::move(ref)),
70 web_view_(new views::WebView( 68 web_view_(new views::WebView(
71 content::BrowserContext::GetBrowserContextForShellUserId( 69 content::BrowserContext::GetBrowserContextForShellUserId(
72 client_user_id))) { 70 client_user_id))) {
73 web_view_->GetWebContents()->SetDelegate(this); 71 web_view_->GetWebContents()->SetDelegate(this);
74 const content::NavigationController* controller = 72 const content::NavigationController* controller =
75 &web_view_->GetWebContents()->GetController(); 73 &web_view_->GetWebContents()->GetController();
76 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
77 content::Source<content::NavigationController>(controller)); 75 content::Source<content::NavigationController>(controller));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 mojom::ViewClientPtr client; 143 mojom::ViewClientPtr client;
146 mojom::ViewPtr view; 144 mojom::ViewPtr view;
147 mojom::ViewRequest view_request = GetProxy(&view); 145 mojom::ViewRequest view_request = GetProxy(&view);
148 client_->ViewCreated(std::move(view), GetProxy(&client), 146 client_->ViewCreated(std::move(view), GetProxy(&client),
149 disposition == WindowOpenDisposition::NEW_POPUP, 147 disposition == WindowOpenDisposition::NEW_POPUP,
150 initial_rect, user_gesture); 148 initial_rect, user_gesture);
151 149
152 const std::string new_user_id = 150 const std::string new_user_id =
153 content::BrowserContext::GetShellUserIdFor( 151 content::BrowserContext::GetShellUserIdFor(
154 new_contents->GetBrowserContext()); 152 new_contents->GetBrowserContext());
155 ViewImpl* impl = new ViewImpl( 153 auto impl = base::MakeUnique<ViewImpl>(connector_->Clone(), new_user_id,
156 connector_->Clone(), new_user_id, std::move(client), 154 std::move(client), ref_->Clone());
157 std::move(view_request), ref_->Clone()); 155
158 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl 156 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl
159 // with |new_contents| instead. 157 // with |new_contents| instead.
160 impl->web_view_->SetWebContents(new_contents); 158 impl->web_view_->SetWebContents(new_contents);
161 impl->web_view_->GetWebContents()->SetDelegate(impl); 159 impl->web_view_->GetWebContents()->SetDelegate(impl.get());
162 160
163 // TODO(beng): this reply is currently synchronous, figure out a fix. 161 // TODO(beng): this reply is currently synchronous, figure out a fix.
164 if (was_blocked) 162 if (was_blocked)
165 *was_blocked = false; 163 *was_blocked = false;
164
165 mojo::MakeStrongBinding(std::move(impl), std::move(view_request));
166 } 166 }
167 167
168 void ViewImpl::CloseContents(content::WebContents* source) { 168 void ViewImpl::CloseContents(content::WebContents* source) {
169 client_->Close(); 169 client_->Close();
170 } 170 }
171 171
172 content::WebContents* ViewImpl::OpenURLFromTab( 172 content::WebContents* ViewImpl::OpenURLFromTab(
173 content::WebContents* source, 173 content::WebContents* source,
174 const content::OpenURLParams& params) { 174 const content::OpenURLParams& params) {
175 mojom::OpenURLParamsPtr params_ptr = mojom::OpenURLParams::New(); 175 mojom::OpenURLParamsPtr params_ptr = mojom::OpenURLParams::New();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 views::Widget* ViewImpl::GetWidget() { 300 views::Widget* ViewImpl::GetWidget() {
301 return web_view_->GetWidget(); 301 return web_view_->GetWidget();
302 } 302 }
303 303
304 const views::Widget* ViewImpl::GetWidget() const { 304 const views::Widget* ViewImpl::GetWidget() const {
305 return web_view_->GetWidget(); 305 return web_view_->GetWidget();
306 } 306 }
307 307
308 } // navigation 308 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/view_impl.h ('k') | services/shell/standalone/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698