| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/extensions/shell_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/shell_window_views.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 is_fullscreen_(false), | 402 is_fullscreen_(false), |
| 403 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { | 403 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { |
| 404 window_ = new views::Widget; | 404 window_ = new views::Widget; |
| 405 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 405 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 406 params.delegate = this; | 406 params.delegate = this; |
| 407 params.remove_standard_frame = true; | 407 params.remove_standard_frame = true; |
| 408 params.use_system_default_icon = true; | 408 params.use_system_default_icon = true; |
| 409 minimum_size_ = win_params.minimum_size; | 409 minimum_size_ = win_params.minimum_size; |
| 410 maximum_size_ = win_params.maximum_size; | 410 maximum_size_ = win_params.maximum_size; |
| 411 window_->Init(params); | 411 window_->Init(params); |
| 412 gfx::Rect window_bounds = | 412 gfx::Rect window_bounds = WindowBoundsForContentBounds(win_params.bounds); |
| 413 window_->non_client_view()->GetWindowBoundsForClientBounds( | |
| 414 win_params.bounds); | |
| 415 // Center window if no position was specified. | 413 // Center window if no position was specified. |
| 416 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) { | 414 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) { |
| 417 window_->CenterWindow(window_bounds.size()); | 415 window_->CenterWindow(window_bounds.size()); |
| 418 } else { | 416 } else { |
| 419 window_->SetBounds(window_bounds); | 417 window_->SetBounds(window_bounds); |
| 420 } | 418 } |
| 421 #if defined(OS_WIN) && !defined(USE_AURA) | 419 #if defined(OS_WIN) && !defined(USE_AURA) |
| 422 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( | 420 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
| 423 extension()->id()); | 421 extension()->id()); |
| 424 ui::win::SetAppIdForWindow( | 422 ui::win::SetAppIdForWindow( |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 565 } |
| 568 | 566 |
| 569 void ShellWindowViews::FlashFrame(bool flash) { | 567 void ShellWindowViews::FlashFrame(bool flash) { |
| 570 window_->FlashFrame(flash); | 568 window_->FlashFrame(flash); |
| 571 } | 569 } |
| 572 | 570 |
| 573 bool ShellWindowViews::IsAlwaysOnTop() const { | 571 bool ShellWindowViews::IsAlwaysOnTop() const { |
| 574 return false; | 572 return false; |
| 575 } | 573 } |
| 576 | 574 |
| 575 gfx::Rect ShellWindowViews::ContentBoundsForWindowBounds( |
| 576 const gfx::Rect& window_bounds) const { |
| 577 if (frameless()) { |
| 578 return window_bounds; |
| 579 } else { |
| 580 gfx::Rect bounds = window_bounds; |
| 581 bounds.set_height(std::max(0, bounds.height() - kCaptionHeight)); |
| 582 return bounds; |
| 583 } |
| 584 } |
| 585 |
| 586 gfx::Rect ShellWindowViews::WindowBoundsForContentBounds( |
| 587 const gfx::Rect& content_bounds) const { |
| 588 if (frameless()) { |
| 589 return content_bounds; |
| 590 } else { |
| 591 gfx::Rect bounds = content_bounds; |
| 592 bounds.set_height(bounds.height() + kCaptionHeight); |
| 593 return bounds; |
| 594 } |
| 595 } |
| 596 |
| 577 void ShellWindowViews::DeleteDelegate() { | 597 void ShellWindowViews::DeleteDelegate() { |
| 578 shell_window_->OnNativeClose(); | 598 shell_window_->OnNativeClose(); |
| 579 } | 599 } |
| 580 | 600 |
| 581 bool ShellWindowViews::CanResize() const { | 601 bool ShellWindowViews::CanResize() const { |
| 582 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_; | 602 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_; |
| 583 } | 603 } |
| 584 | 604 |
| 585 bool ShellWindowViews::CanMaximize() const { | 605 bool ShellWindowViews::CanMaximize() const { |
| 586 return CanResize(); | 606 return CanResize(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 ui::WindowShowState show_state) { | 754 ui::WindowShowState show_state) { |
| 735 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 755 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
| 736 shell_window_->SaveWindowPosition(); | 756 shell_window_->SaveWindowPosition(); |
| 737 } | 757 } |
| 738 | 758 |
| 739 // static | 759 // static |
| 740 NativeShellWindow* NativeShellWindow::Create( | 760 NativeShellWindow* NativeShellWindow::Create( |
| 741 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 761 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
| 742 return new ShellWindowViews(shell_window, params); | 762 return new ShellWindowViews(shell_window, params); |
| 743 } | 763 } |
| OLD | NEW |