| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); | 205 host_->SetSize(mojo::Size::From(gfx::Size(1280, 800))); |
| 206 | 206 |
| 207 root_->AddChild(content_); | 207 root_->AddChild(content_); |
| 208 host_->AddActivationParent(root_->id()); | 208 host_->AddActivationParent(root_->id()); |
| 209 content_->SetVisible(true); | 209 content_->SetVisible(true); |
| 210 | 210 |
| 211 web_view_.Init(app_, content_); | 211 web_view_.Init(app_, content_); |
| 212 | 212 |
| 213 host_->AddAccelerator( | 213 host_->AddAccelerator( |
| 214 static_cast<uint32_t>(BrowserCommand::CLOSE), | 214 static_cast<uint32_t>(BrowserCommand::CLOSE), |
| 215 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_W, | 215 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::W, |
| 216 mus::mojom::EVENT_FLAGS_CONTROL_DOWN), | 216 mus::mojom::kEventFlagControlDown), |
| 217 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 217 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 218 host_->AddAccelerator( | 218 host_->AddAccelerator( |
| 219 static_cast<uint32_t>(BrowserCommand::FOCUS_OMNIBOX), | 219 static_cast<uint32_t>(BrowserCommand::FOCUS_OMNIBOX), |
| 220 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_L, | 220 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::L, |
| 221 mus::mojom::EVENT_FLAGS_CONTROL_DOWN), | 221 mus::mojom::kEventFlagControlDown), |
| 222 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 222 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 223 host_->AddAccelerator( | 223 host_->AddAccelerator( |
| 224 static_cast<uint32_t>(BrowserCommand::NEW_WINDOW), | 224 static_cast<uint32_t>(BrowserCommand::NEW_WINDOW), |
| 225 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, | 225 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 226 mus::mojom::EVENT_FLAGS_CONTROL_DOWN), | 226 mus::mojom::kEventFlagControlDown), |
| 227 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 227 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 228 host_->AddAccelerator( | 228 host_->AddAccelerator( |
| 229 static_cast<uint32_t>(BrowserCommand::SHOW_FIND), | 229 static_cast<uint32_t>(BrowserCommand::SHOW_FIND), |
| 230 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_F, | 230 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::F, |
| 231 mus::mojom::EVENT_FLAGS_CONTROL_DOWN), | 231 mus::mojom::kEventFlagControlDown), |
| 232 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 232 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 233 host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_BACK), | 233 host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_BACK), |
| 234 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_LEFT, | 234 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::LEFT, |
| 235 mus::mojom::EVENT_FLAGS_ALT_DOWN), | 235 mus::mojom::kEventFlagAltDown), |
| 236 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 236 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 237 host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_FORWARD), | 237 host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_FORWARD), |
| 238 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_RIGHT, | 238 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::RIGHT, |
| 239 mus::mojom::EVENT_FLAGS_ALT_DOWN), | 239 mus::mojom::kEventFlagAltDown), |
| 240 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); | 240 mus::mojom::WindowTreeHost::AddAcceleratorCallback()); |
| 241 // Now that we're ready, load the default url. | 241 // Now that we're ready, load the default url. |
| 242 LoadURL(default_url_); | 242 LoadURL(default_url_); |
| 243 | 243 |
| 244 // Record the time spent opening initial tabs, used for performance testing. | 244 // Record the time spent opening initial tabs, used for performance testing. |
| 245 const base::TimeDelta open_tabs_delta = | 245 const base::TimeDelta open_tabs_delta = |
| 246 base::TimeTicks::Now() - display_ticks; | 246 base::TimeTicks::Now() - display_ticks; |
| 247 | 247 |
| 248 // Record the browser startup time metrics, used for performance testing. | 248 // Record the browser startup time metrics, used for performance testing. |
| 249 static bool recorded_browser_startup_metrics = false; | 249 static bool recorded_browser_startup_metrics = false; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 void BrowserWindow::LoadingStateChanged(bool is_loading, double progress) { | 313 void BrowserWindow::LoadingStateChanged(bool is_loading, double progress) { |
| 314 progress_bar_->SetIsLoading(is_loading); | 314 progress_bar_->SetIsLoading(is_loading); |
| 315 progress_bar_->SetProgress(progress); | 315 progress_bar_->SetProgress(progress); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void BrowserWindow::BackForwardChanged( | 318 void BrowserWindow::BackForwardChanged( |
| 319 web_view::mojom::ButtonState back_button, | 319 web_view::mojom::ButtonState back_button, |
| 320 web_view::mojom::ButtonState forward_button) { | 320 web_view::mojom::ButtonState forward_button) { |
| 321 toolbar_view_->SetBackForwardEnabled( | 321 toolbar_view_->SetBackForwardEnabled( |
| 322 back_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED, | 322 back_button == web_view::mojom::ButtonState::ENABLED, |
| 323 forward_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED); | 323 forward_button == web_view::mojom::ButtonState::ENABLED); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void BrowserWindow::TitleChanged(const mojo::String& title) { | 326 void BrowserWindow::TitleChanged(const mojo::String& title) { |
| 327 base::string16 formatted = | 327 base::string16 formatted = |
| 328 title.is_null() ? base::ASCIIToUTF16("Untitled") | 328 title.is_null() ? base::ASCIIToUTF16("Untitled") |
| 329 : title.To<base::string16>() + | 329 : title.To<base::string16>() + |
| 330 base::ASCIIToUTF16(" - Mandoline"); | 330 base::ASCIIToUTF16(" - Mandoline"); |
| 331 host_->SetTitle(mojo::String::From(formatted)); | 331 host_->SetTitle(mojo::String::From(formatted)); |
| 332 } | 332 } |
| 333 | 333 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 widget_delegate->GetContentsView()->SetLayoutManager( | 401 widget_delegate->GetContentsView()->SetLayoutManager( |
| 402 new LayoutManagerImpl(this)); | 402 new LayoutManagerImpl(this)); |
| 403 | 403 |
| 404 find_bar_view_ = new FindBarView(this); | 404 find_bar_view_ = new FindBarView(this); |
| 405 widget_delegate->GetContentsView()->AddChildView(find_bar_view_); | 405 widget_delegate->GetContentsView()->AddChildView(find_bar_view_); |
| 406 | 406 |
| 407 views::Widget* widget = new views::Widget; | 407 views::Widget* widget = new views::Widget; |
| 408 views::Widget::InitParams params( | 408 views::Widget::InitParams params( |
| 409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 409 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 410 params.native_widget = new views::NativeWidgetMus( | 410 params.native_widget = new views::NativeWidgetMus( |
| 411 widget, app_->shell(), root, mus::mojom::SURFACE_TYPE_DEFAULT); | 411 widget, app_->shell(), root, mus::mojom::SurfaceType::DEFAULT); |
| 412 params.delegate = widget_delegate; | 412 params.delegate = widget_delegate; |
| 413 params.bounds = root_->bounds(); | 413 params.bounds = root_->bounds(); |
| 414 widget->Init(params); | 414 widget->Init(params); |
| 415 widget->Show(); | 415 widget->Show(); |
| 416 root_->SetFocus(); | 416 root_->SetFocus(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 void BrowserWindow::EmbedOmnibox() { | 419 void BrowserWindow::EmbedOmnibox() { |
| 420 mus::mojom::WindowTreeClientPtr view_tree_client; | 420 mus::mojom::WindowTreeClientPtr view_tree_client; |
| 421 omnibox_->GetWindowTreeClient(GetProxy(&view_tree_client)); | 421 omnibox_->GetWindowTreeClient(GetProxy(&view_tree_client)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 451 content_bounds.set_width(DIPSToPixels(progress_bar_bounds.width())); | 451 content_bounds.set_width(DIPSToPixels(progress_bar_bounds.width())); |
| 452 content_bounds.set_height(host->bounds().height() - content_bounds.y() - | 452 content_bounds.set_height(host->bounds().height() - content_bounds.y() - |
| 453 DIPSToPixels(10)); | 453 DIPSToPixels(10)); |
| 454 content_->SetBounds(content_bounds); | 454 content_->SetBounds(content_bounds); |
| 455 | 455 |
| 456 // The omnibox view bounds are in physical pixels. | 456 // The omnibox view bounds are in physical pixels. |
| 457 omnibox_view_->SetBounds(bounds_in_physical_pixels); | 457 omnibox_view_->SetBounds(bounds_in_physical_pixels); |
| 458 } | 458 } |
| 459 | 459 |
| 460 } // namespace mandoline | 460 } // namespace mandoline |
| OLD | NEW |