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/desktop_ui/browser_window.h" | 5 #include "mandoline/ui/desktop_ui/browser_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void BrowserWindow::Close() { | 134 void BrowserWindow::Close() { |
135 if (root_) | 135 if (root_) |
136 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); | 136 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); |
137 else | 137 else |
138 delete this; | 138 delete this; |
139 } | 139 } |
140 | 140 |
141 void BrowserWindow::ShowOmnibox() { | 141 void BrowserWindow::ShowOmnibox() { |
142 TRACE_EVENT0("desktop_ui", "BrowserWindow::ShowOmnibox"); | 142 TRACE_EVENT0("desktop_ui", "BrowserWindow::ShowOmnibox"); |
143 if (!omnibox_.get()) { | 143 if (!omnibox_.get()) { |
144 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 144 omnibox_connection_ = app_->ConnectToApplication("mojo:omnibox"); |
145 request->url = mojo::String::From("mojo:omnibox"); | |
146 omnibox_connection_ = app_->ConnectToApplication(request.Pass()); | |
147 omnibox_connection_->AddService<ViewEmbedder>(this); | 145 omnibox_connection_->AddService<ViewEmbedder>(this); |
148 omnibox_connection_->ConnectToService(&omnibox_); | 146 omnibox_connection_->ConnectToService(&omnibox_); |
149 omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler( | 147 omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler( |
150 [this]() { | 148 [this]() { |
151 // This will cause the connection to be re-established the next time | 149 // This will cause the connection to be re-established the next time |
152 // we come through this codepath. | 150 // we come through this codepath. |
153 omnibox_.reset(); | 151 omnibox_.reset(); |
154 }); | 152 }); |
155 } | 153 } |
156 omnibox_->ShowForURL(mojo::String::From(current_url_.spec())); | 154 omnibox_->ShowForURL(mojo::String::From(current_url_.spec())); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 233 |
236 // Record the time spent opening initial tabs, used for performance testing. | 234 // Record the time spent opening initial tabs, used for performance testing. |
237 const base::TimeDelta open_tabs_delta = | 235 const base::TimeDelta open_tabs_delta = |
238 base::TimeTicks::Now() - display_ticks; | 236 base::TimeTicks::Now() - display_ticks; |
239 | 237 |
240 // Record the browser startup time metrics, used for performance testing. | 238 // Record the browser startup time metrics, used for performance testing. |
241 static bool recorded_browser_startup_metrics = false; | 239 static bool recorded_browser_startup_metrics = false; |
242 if (!recorded_browser_startup_metrics && | 240 if (!recorded_browser_startup_metrics && |
243 base::CommandLine::ForCurrentProcess()->HasSwitch( | 241 base::CommandLine::ForCurrentProcess()->HasSwitch( |
244 tracing::kEnableStatsCollectionBindings)) { | 242 tracing::kEnableStatsCollectionBindings)) { |
245 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
246 request->url = mojo::String::From("mojo:tracing"); | |
247 tracing::StartupPerformanceDataCollectorPtr collector; | 243 tracing::StartupPerformanceDataCollectorPtr collector; |
248 app_->ConnectToService(request.Pass(), &collector); | 244 app_->ConnectToService("mojo:tracing", &collector); |
249 collector->SetBrowserWindowDisplayTicks(display_ticks.ToInternalValue()); | 245 collector->SetBrowserWindowDisplayTicks(display_ticks.ToInternalValue()); |
250 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue()); | 246 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue()); |
251 collector->SetBrowserMessageLoopStartTicks( | 247 collector->SetBrowserMessageLoopStartTicks( |
252 manager_->startup_ticks().ToInternalValue()); | 248 manager_->startup_ticks().ToInternalValue()); |
253 recorded_browser_startup_metrics = true; | 249 recorded_browser_startup_metrics = true; |
254 } | 250 } |
255 } | 251 } |
256 | 252 |
257 void BrowserWindow::OnConnectionLost(mus::WindowTreeConnection* connection) { | 253 void BrowserWindow::OnConnectionLost(mus::WindowTreeConnection* connection) { |
258 root_ = nullptr; | 254 root_ = nullptr; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 content_bounds.set_width(DIPSToPixels(progress_bar_bounds.width())); | 441 content_bounds.set_width(DIPSToPixels(progress_bar_bounds.width())); |
446 content_bounds.set_height(host->bounds().height() - content_bounds.y() - | 442 content_bounds.set_height(host->bounds().height() - content_bounds.y() - |
447 DIPSToPixels(10)); | 443 DIPSToPixels(10)); |
448 content_->SetBounds(content_bounds); | 444 content_->SetBounds(content_bounds); |
449 | 445 |
450 // The omnibox view bounds are in physical pixels. | 446 // The omnibox view bounds are in physical pixels. |
451 omnibox_view_->SetBounds(bounds_in_physical_pixels); | 447 omnibox_view_->SetBounds(bounds_in_physical_pixels); |
452 } | 448 } |
453 | 449 |
454 } // namespace mandoline | 450 } // namespace mandoline |
OLD | NEW |