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

Side by Side Diff: mandoline/ui/browser/browser.cc

Issue 1254383016: ApplicationConnection lifetime management changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 4 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/tab/frame_connection.h ('k') | mandoline/ui/browser/browser_apptest.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 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/browser/browser.h" 5 #include "mandoline/ui/browser/browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/view_manager/public/cpp/view.h" 9 #include "components/view_manager/public/cpp/view.h"
10 #include "components/view_manager/public/cpp/view_manager_init.h" 10 #include "components/view_manager/public/cpp/view_manager_init.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 void Browser::OnEmbedForDescendant(mojo::View* view, 112 void Browser::OnEmbedForDescendant(mojo::View* view,
113 mojo::URLRequestPtr request, 113 mojo::URLRequestPtr request,
114 mojo::ViewManagerClientPtr* client) { 114 mojo::ViewManagerClientPtr* client) {
115 // TODO(sky): move this to Frame/FrameTree. 115 // TODO(sky): move this to Frame/FrameTree.
116 Frame* frame = Frame::FindFirstFrameAncestor(view); 116 Frame* frame = Frame::FindFirstFrameAncestor(view);
117 if (!frame || !frame->HasAncestor(frame_tree_->root())) { 117 if (!frame || !frame->HasAncestor(frame_tree_->root())) {
118 // TODO(sky): add requestor url so that we can return false if it's not 118 // TODO(sky): add requestor url so that we can return false if it's not
119 // an app we expect. 119 // an app we expect.
120 mojo::ApplicationConnection* connection = 120 scoped_ptr<mojo::ApplicationConnection> connection =
121 app_->ConnectToApplication(request.Pass()); 121 app_->ConnectToApplication(request.Pass());
122 connection->ConnectToService(client); 122 connection->ConnectToService(client);
123 return; 123 return;
124 } 124 }
125 125
126 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); 126 scoped_ptr<FrameConnection> frame_connection(new FrameConnection);
127 frame_connection->Init(app_, request.Pass(), client); 127 frame_connection->Init(app_, request.Pass(), client);
128 FrameTreeClient* frame_tree_client = frame_connection->frame_tree_client(); 128 FrameTreeClient* frame_tree_client = frame_connection->frame_tree_client();
129 frame_tree_->CreateOrReplaceFrame(frame, view, frame_tree_client, 129 frame_tree_->CreateOrReplaceFrame(frame, view, frame_tree_client,
130 frame_connection.Pass()); 130 frame_connection.Pass());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 view_embedder_bindings_.AddBinding(this, request.Pass()); 208 view_embedder_bindings_.AddBinding(this, request.Pass());
209 } 209 }
210 210
211 void Browser::ShowOmnibox(mojo::URLRequestPtr request) { 211 void Browser::ShowOmnibox(mojo::URLRequestPtr request) {
212 if (!omnibox_) { 212 if (!omnibox_) {
213 omnibox_ = root_->view_manager()->CreateView(); 213 omnibox_ = root_->view_manager()->CreateView();
214 root_->AddChild(omnibox_); 214 root_->AddChild(omnibox_);
215 omnibox_->SetBounds(root_->bounds()); 215 omnibox_->SetBounds(root_->bounds());
216 } 216 }
217 mojo::ViewManagerClientPtr view_manager_client; 217 mojo::ViewManagerClientPtr view_manager_client;
218 mojo::ApplicationConnection* connection = 218 scoped_ptr<mojo::ApplicationConnection> connection =
219 app_->ConnectToApplication(request.Pass()); 219 app_->ConnectToApplication(request.Pass());
220 connection->AddService<ViewEmbedder>(this); 220 connection->AddService<ViewEmbedder>(this);
221 connection->ConnectToService(&view_manager_client); 221 connection->ConnectToService(&view_manager_client);
222 omnibox_->Embed(view_manager_client.Pass()); 222 omnibox_->Embed(view_manager_client.Pass());
223 omnibox_->SetVisible(true); 223 omnibox_->SetVisible(true);
224 } 224 }
225 225
226 void Browser::RequestNavigate(Frame* source, 226 void Browser::RequestNavigate(Frame* source,
227 NavigationTargetType target_type, 227 NavigationTargetType target_type,
228 Frame* target_frame, 228 Frame* target_frame,
229 mojo::URLRequestPtr request) { 229 mojo::URLRequestPtr request) {
230 // TODO: this needs security checks. 230 // TODO: this needs security checks.
231 if (target_type == NAVIGATION_TARGET_TYPE_EXISTING_FRAME) { 231 if (target_type == NAVIGATION_TARGET_TYPE_EXISTING_FRAME) {
232 if (target_frame && target_frame != frame_tree_->root() && 232 if (target_frame && target_frame != frame_tree_->root() &&
233 target_frame->view()) { 233 target_frame->view()) {
234 NavigateExistingFrame(target_frame, request.Pass()); 234 NavigateExistingFrame(target_frame, request.Pass());
235 return; 235 return;
236 } 236 }
237 DVLOG(1) << "RequestNavigate() targeted existing frame that doesn't exist."; 237 DVLOG(1) << "RequestNavigate() targeted existing frame that doesn't exist.";
238 return; 238 return;
239 } 239 }
240 ReplaceContentWithRequest(request.Pass()); 240 ReplaceContentWithRequest(request.Pass());
241 } 241 }
242 242
243 } // namespace mandoline 243 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/tab/frame_connection.h ('k') | mandoline/ui/browser/browser_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698