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

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

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash in surfaces if surfaceimpl outlives the app, and a double delete in browser Created 5 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
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 "mandoline/ui/browser/browser_ui.h" 9 #include "mandoline/ui/browser/browser_ui.h"
10 #include "mandoline/ui/browser/merged_service_provider.h" 10 #include "mandoline/ui/browser/merged_service_provider.h"
11 #include "mojo/application/application_runner_chromium.h" 11 #include "mojo/application/application_runner_chromium.h"
12 #include "mojo/common/common_type_converters.h" 12 #include "mojo/common/common_type_converters.h"
13 #include "third_party/mojo/src/mojo/public/c/system/main.h" 13 #include "third_party/mojo/src/mojo/public/c/system/main.h"
14 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
15 15
16 namespace mandoline { 16 namespace mandoline {
17 17
18 Browser::Browser() 18 Browser::Browser()
19 : window_manager_app_(new window_manager::WindowManagerApp(this, this)), 19 : window_manager_app_(new window_manager::WindowManagerApp(this, this)),
20 root_(nullptr), 20 root_(nullptr),
21 content_(nullptr), 21 content_(nullptr),
22 omnibox_(nullptr), 22 omnibox_(nullptr),
23 navigator_host_(this), 23 navigator_host_(this),
24 ui_(nullptr) { 24 ui_(nullptr) {
25 exposed_services_impl_.AddService(this); 25 exposed_services_impl_.AddService(this);
26 } 26 }
27 27
28 Browser::~Browser() { 28 Browser::~Browser() {
29 // Destruct ui_ manually while |this| is alive and reset the pointer first.
30 // This is to avoid a double delete when OnViewManagerDisconnected gets
31 // called.
32 delete ui_.release();
29 } 33 }
30 34
31 void Browser::ReplaceContentWithURL(const mojo::String& url) { 35 void Browser::ReplaceContentWithURL(const mojo::String& url) {
32 Embed(url, nullptr, nullptr); 36 Embed(url, nullptr, nullptr);
33 } 37 }
34 38
35 void Browser::Initialize(mojo::ApplicationImpl* app) { 39 void Browser::Initialize(mojo::ApplicationImpl* app) {
36 window_manager_app_->Initialize(app); 40 window_manager_app_->Initialize(app);
37 ui_.reset(BrowserUI::Create(this, app)); 41 ui_.reset(BrowserUI::Create(this, app));
38 42
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (!omnibox_) { 159 if (!omnibox_) {
156 omnibox_ = root_->view_manager()->CreateView(); 160 omnibox_ = root_->view_manager()->CreateView();
157 root_->AddChild(omnibox_); 161 root_->AddChild(omnibox_);
158 omnibox_->SetVisible(true); 162 omnibox_->SetVisible(true);
159 omnibox_->SetBounds(root_->bounds()); 163 omnibox_->SetBounds(root_->bounds());
160 } 164 }
161 omnibox_->Embed(url, services.Pass(), exposed_services.Pass()); 165 omnibox_->Embed(url, services.Pass(), exposed_services.Pass());
162 } 166 }
163 167
164 } // namespace mandoline 168 } // namespace mandoline
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698