Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / view_manager / view_tree_host_connection.cc
blob1c9f1b5a1d6373eb5b18316c24cf207565af6552
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
3 // found in the LICENSE file.
5 #include "components/view_manager/view_tree_host_connection.h"
7 #include "components/view_manager/connection_manager.h"
8 #include "components/view_manager/view_tree_host_impl.h"
10 namespace view_manager {
12 ViewTreeHostConnection::ViewTreeHostConnection(
13 scoped_ptr<ViewTreeHostImpl> host_impl,
14 ConnectionManager* manager)
15 : host_(host_impl.Pass()),
16 tree_(nullptr),
17 connection_manager_(manager),
18 connection_closed_(false) {
21 ViewTreeHostConnection::~ViewTreeHostConnection() {
22 // If this DCHECK fails then something has tried to delete this object without
23 // calling CloseConnection.
24 DCHECK(connection_closed_);
28 void ViewTreeHostConnection::CloseConnection() {
29 // A connection error will trigger the display to close and so we want to make
30 // sure we signal the ConnectionManager only once.
31 if (connection_closed_)
32 return;
33 connection_manager()->OnHostConnectionClosed(this);
34 connection_closed_ = true;
35 delete this;
38 ViewTreeImpl* ViewTreeHostConnection::GetViewTree() {
39 return tree_;
42 void ViewTreeHostConnection::OnDisplayInitialized() {
45 void ViewTreeHostConnection::OnDisplayClosed() {
46 CloseConnection();
49 ViewTreeHostConnectionImpl::ViewTreeHostConnectionImpl(
50 mojo::InterfaceRequest<mojo::ViewTreeHost> request,
51 scoped_ptr<ViewTreeHostImpl> host_impl,
52 mojo::ViewTreeClientPtr client,
53 ConnectionManager* manager)
54 : ViewTreeHostConnection(host_impl.Pass(), manager),
55 binding_(view_tree_host(), request.Pass()),
56 client_(client.Pass()) {
59 ViewTreeHostConnectionImpl::~ViewTreeHostConnectionImpl() {
62 void ViewTreeHostConnectionImpl::OnDisplayInitialized() {
63 connection_manager()->AddHost(this);
64 set_view_tree(connection_manager()->EmbedAtView(
65 kInvalidConnectionId, view_tree_host()->root_view()->id(),
66 client_.Pass()));
69 } // namespace view_manager