| OLD | NEW |
| 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 22 matching lines...) Expand all Loading... |
| 33 Browser::Browser() | 33 Browser::Browser() |
| 34 : root_(nullptr), | 34 : root_(nullptr), |
| 35 content_(nullptr), | 35 content_(nullptr), |
| 36 omnibox_(nullptr), | 36 omnibox_(nullptr), |
| 37 navigator_host_(this), | 37 navigator_host_(this), |
| 38 ui_(nullptr) { | 38 ui_(nullptr) { |
| 39 exposed_services_impl_.AddService<mojo::NavigatorHost>(this); | 39 exposed_services_impl_.AddService<mojo::NavigatorHost>(this); |
| 40 } | 40 } |
| 41 | 41 |
| 42 Browser::~Browser() { | 42 Browser::~Browser() { |
| 43 // Destruct ui_ manually while |this| is alive and reset the pointer first. |
| 44 // This is to avoid a double delete when OnViewManagerDisconnected gets |
| 45 // called. |
| 46 delete ui_.release(); |
| 43 } | 47 } |
| 44 | 48 |
| 45 void Browser::ReplaceContentWithURL(const mojo::String& url) { | 49 void Browser::ReplaceContentWithURL(const mojo::String& url) { |
| 46 Embed(url, nullptr, nullptr); | 50 Embed(url, nullptr, nullptr); |
| 47 } | 51 } |
| 48 | 52 |
| 49 void Browser::Initialize(mojo::ApplicationImpl* app) { | 53 void Browser::Initialize(mojo::ApplicationImpl* app) { |
| 50 view_manager_init_.reset(new mojo::ViewManagerInit(app, this, this)); | 54 view_manager_init_.reset(new mojo::ViewManagerInit(app, this, this)); |
| 51 | 55 |
| 52 ui_.reset(BrowserUI::Create(this, app)); | 56 ui_.reset(BrowserUI::Create(this, app)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (!omnibox_) { | 174 if (!omnibox_) { |
| 171 omnibox_ = root_->view_manager()->CreateView(); | 175 omnibox_ = root_->view_manager()->CreateView(); |
| 172 root_->AddChild(omnibox_); | 176 root_->AddChild(omnibox_); |
| 173 omnibox_->SetVisible(true); | 177 omnibox_->SetVisible(true); |
| 174 omnibox_->SetBounds(root_->bounds()); | 178 omnibox_->SetBounds(root_->bounds()); |
| 175 } | 179 } |
| 176 omnibox_->Embed(url, services.Pass(), exposed_services.Pass()); | 180 omnibox_->Embed(url, services.Pass(), exposed_services.Pass()); |
| 177 } | 181 } |
| 178 | 182 |
| 179 } // namespace mandoline | 183 } // namespace mandoline |
| OLD | NEW |