| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 //////////////////////////////////////////////////////////////////////////////// | 164 //////////////////////////////////////////////////////////////////////////////// |
| 165 // BrowserWindow, mus::ViewTreeDelegate implementation: | 165 // BrowserWindow, mus::ViewTreeDelegate implementation: |
| 166 | 166 |
| 167 void BrowserWindow::OnEmbed(mus::Window* root) { | 167 void BrowserWindow::OnEmbed(mus::Window* root) { |
| 168 TRACE_EVENT0("desktop_ui", "BrowserWindow::OnEmbed"); | 168 TRACE_EVENT0("desktop_ui", "BrowserWindow::OnEmbed"); |
| 169 // BrowserWindow does not support being embedded more than once. | 169 // BrowserWindow does not support being embedded more than once. |
| 170 CHECK(!root_); | 170 CHECK(!root_); |
| 171 | 171 |
| 172 // Record when the browser window was displayed, used for performance testing. | 172 // Record when the browser window was displayed, used for performance testing. |
| 173 const base::Time display_time = base::Time::Now(); | 173 const base::TimeTicks display_ticks = base::TimeTicks::Now(); |
| 174 | 174 |
| 175 root_ = root; | 175 root_ = root; |
| 176 | 176 |
| 177 host_->SetTitle("Mandoline"); | 177 host_->SetTitle("Mandoline"); |
| 178 | 178 |
| 179 content_ = root_->connection()->NewWindow(); | 179 content_ = root_->connection()->NewWindow(); |
| 180 Init(root_); | 180 Init(root_); |
| 181 | 181 |
| 182 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); | 182 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); |
| 183 | 183 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 207 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_LEFT, | 207 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_LEFT, |
| 208 mus::mojom::EVENT_FLAGS_ALT_DOWN)); | 208 mus::mojom::EVENT_FLAGS_ALT_DOWN)); |
| 209 host_->AddAccelerator( | 209 host_->AddAccelerator( |
| 210 static_cast<uint32_t>(BrowserCommand::GO_FORWARD), | 210 static_cast<uint32_t>(BrowserCommand::GO_FORWARD), |
| 211 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_RIGHT, | 211 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_RIGHT, |
| 212 mus::mojom::EVENT_FLAGS_ALT_DOWN)); | 212 mus::mojom::EVENT_FLAGS_ALT_DOWN)); |
| 213 // Now that we're ready, load the default url. | 213 // Now that we're ready, load the default url. |
| 214 LoadURL(default_url_); | 214 LoadURL(default_url_); |
| 215 | 215 |
| 216 // Record the time spent opening initial tabs, used for performance testing. | 216 // Record the time spent opening initial tabs, used for performance testing. |
| 217 const base::TimeDelta open_tabs_delta = base::Time::Now() - display_time; | 217 const base::TimeDelta open_tabs_delta = |
| 218 base::TimeTicks::Now() - display_ticks; |
| 218 | 219 |
| 219 // Record the browser startup time metrics, used for performance testing. | 220 // Record the browser startup time metrics, used for performance testing. |
| 220 static bool recorded_browser_startup_metrics = false; | 221 static bool recorded_browser_startup_metrics = false; |
| 221 if (!recorded_browser_startup_metrics && | 222 if (!recorded_browser_startup_metrics && |
| 222 base::CommandLine::ForCurrentProcess()->HasSwitch( | 223 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 223 tracing::kEnableStatsCollectionBindings)) { | 224 tracing::kEnableStatsCollectionBindings)) { |
| 224 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 225 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 225 request->url = mojo::String::From("mojo:tracing"); | 226 request->url = mojo::String::From("mojo:tracing"); |
| 226 tracing::StartupPerformanceDataCollectorPtr collector; | 227 tracing::StartupPerformanceDataCollectorPtr collector; |
| 227 app_->ConnectToService(request.Pass(), &collector); | 228 app_->ConnectToService(request.Pass(), &collector); |
| 228 collector->SetBrowserWindowDisplayTime(display_time.ToInternalValue()); | 229 collector->SetBrowserWindowDisplayTicks(display_ticks.ToInternalValue()); |
| 229 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue()); | 230 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue()); |
| 230 collector->SetBrowserMessageLoopStartTime( | 231 collector->SetBrowserMessageLoopStartTicks( |
| 231 manager_->startup_time().ToInternalValue()); | 232 manager_->startup_ticks().ToInternalValue()); |
| 232 recorded_browser_startup_metrics = true; | 233 recorded_browser_startup_metrics = true; |
| 233 } | 234 } |
| 234 } | 235 } |
| 235 | 236 |
| 236 void BrowserWindow::OnConnectionLost(mus::WindowTreeConnection* connection) { | 237 void BrowserWindow::OnConnectionLost(mus::WindowTreeConnection* connection) { |
| 237 root_ = nullptr; | 238 root_ = nullptr; |
| 238 delete this; | 239 delete this; |
| 239 } | 240 } |
| 240 | 241 |
| 241 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 omnibox_view_->Embed(view_tree_client.Pass()); | 431 omnibox_view_->Embed(view_tree_client.Pass()); |
| 431 | 432 |
| 432 // TODO(beng): This should be handled sufficiently by | 433 // TODO(beng): This should be handled sufficiently by |
| 433 // OmniboxImpl::ShowWindow() but unfortunately view manager policy | 434 // OmniboxImpl::ShowWindow() but unfortunately view manager policy |
| 434 // currently prevents the embedded app from changing window z for | 435 // currently prevents the embedded app from changing window z for |
| 435 // its own window. | 436 // its own window. |
| 436 omnibox_view_->MoveToFront(); | 437 omnibox_view_->MoveToFront(); |
| 437 } | 438 } |
| 438 | 439 |
| 439 } // namespace mandoline | 440 } // namespace mandoline |
| OLD | NEW |