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

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

Issue 1986003002: Revert of Add a basic browser to mash that uses the navigation service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/navigation.h ('k') | services/navigation/navigation_unittest.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/navigation.h" 5 #include "services/navigation/navigation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "services/navigation/view_impl.h" 9 #include "services/navigation/view_impl.h"
10 10
11 namespace navigation { 11 namespace navigation {
12 12
13 Navigation::Navigation() 13 Navigation::Navigation()
14 : ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) { 14 : ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) {
15 bindings_.set_connection_error_handler( 15 bindings_.set_connection_error_handler(
16 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this))); 16 base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this)));
17 } 17 }
18 Navigation::~Navigation() {} 18 Navigation::~Navigation() {}
19 19
20 void Navigation::Init(shell::Connector* connector, 20 void Navigation::SetBrowserContext(content::BrowserContext* browser_context) {
21 content::BrowserContext* browser_context) {
22 connector_ = connector;
23 browser_context_ = browser_context; 21 browser_context_ = browser_context;
24 for (auto& pending : pending_creates_) 22 for (auto& pending : pending_creates_)
25 CreateView(std::move(pending.first), std::move(pending.second)); 23 CreateView(std::move(pending.first), std::move(pending.second));
26 } 24 }
27 25
28 bool Navigation::AcceptConnection(shell::Connection* connection) { 26 bool Navigation::AcceptConnection(shell::Connection* connection) {
29 connection->AddInterface<mojom::ViewFactory>(this); 27 connection->AddInterface<mojom::ViewFactory>(this);
30 return true; 28 return true;
31 } 29 }
32 30
33 void Navigation::Create(shell::Connection* connection, 31 void Navigation::Create(shell::Connection* connection,
34 mojom::ViewFactoryRequest request) { 32 mojom::ViewFactoryRequest request) {
35 bindings_.AddBinding(this, std::move(request)); 33 bindings_.AddBinding(this, std::move(request));
36 refs_.insert(ref_factory_.CreateRef()); 34 refs_.insert(ref_factory_.CreateRef());
37 } 35 }
38 36
39 void Navigation::CreateView(mojom::ViewClientPtr client, 37 void Navigation::CreateView(mojom::ViewClientPtr client,
40 mojom::ViewRequest request) { 38 mojom::ViewRequest request) {
41 if (!browser_context_) { 39 if (!browser_context_) {
42 pending_creates_.push_back( 40 pending_creates_.push_back(
43 std::make_pair(std::move(client), std::move(request))); 41 std::make_pair(std::move(client), std::move(request)));
44 return; 42 return;
45 } 43 }
46 new ViewImpl(connector_, browser_context_, std::move(client), 44 new ViewImpl(browser_context_, std::move(client), std::move(request),
47 std::move(request), ref_factory_.CreateRef()); 45 ref_factory_.CreateRef());
48 } 46 }
49 47
50 void Navigation::ViewFactoryLost() { 48 void Navigation::ViewFactoryLost() {
51 refs_.erase(refs_.begin()); 49 refs_.erase(refs_.begin());
52 } 50 }
53 51
54 } // navigation 52 } // navigation
OLDNEW
« no previous file with comments | « services/navigation/navigation.h ('k') | services/navigation/navigation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698