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

Side by Side Diff: chrome/browser/ui/views/extensions/shell_window_views.cc

Issue 11369237: Add a way to fetch window frame metrics from NativeShellWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change ShellWindowViews frame insets logic Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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
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 = win_params.bounds;
413 window_->non_client_view()->GetWindowBoundsForClientBounds( 413 window_bounds.Inset(-GetFrameInsets());
414 win_params.bounds);
415 // Center window if no position was specified. 414 // Center window if no position was specified.
416 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) { 415 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) {
417 window_->CenterWindow(window_bounds.size()); 416 window_->CenterWindow(window_bounds.size());
418 } else { 417 } else {
419 window_->SetBounds(window_bounds); 418 window_->SetBounds(window_bounds);
420 } 419 }
421 #if defined(OS_WIN) && !defined(USE_AURA) 420 #if defined(OS_WIN) && !defined(USE_AURA)
422 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( 421 std::string app_name = web_app::GenerateApplicationNameFromExtensionId(
423 extension()->id()); 422 extension()->id());
424 ui::win::SetAppIdForWindow( 423 ui::win::SetAppIdForWindow(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } 566 }
568 567
569 void ShellWindowViews::FlashFrame(bool flash) { 568 void ShellWindowViews::FlashFrame(bool flash) {
570 window_->FlashFrame(flash); 569 window_->FlashFrame(flash);
571 } 570 }
572 571
573 bool ShellWindowViews::IsAlwaysOnTop() const { 572 bool ShellWindowViews::IsAlwaysOnTop() const {
574 return false; 573 return false;
575 } 574 }
576 575
576 gfx::Insets ShellWindowViews::GetFrameInsets() const {
577 if (frameless())
578 return gfx::Insets();
579
580 gfx::Rect client_bounds = gfx::Rect(100, 100);
stevenjb 2012/11/27 01:12:47 I take it 100 x 100 is arbitrary? I assume it just
jeremya 2012/11/27 02:50:16 it just needs to be large enough that GetWindowBou
581 gfx::Rect window_bounds =
582 window_->non_client_view()->GetWindowBoundsForClientBounds(
583 client_bounds);
584 return window_bounds.InsetsFrom(client_bounds);
585 }
586
577 void ShellWindowViews::DeleteDelegate() { 587 void ShellWindowViews::DeleteDelegate() {
578 shell_window_->OnNativeClose(); 588 shell_window_->OnNativeClose();
579 } 589 }
580 590
581 bool ShellWindowViews::CanResize() const { 591 bool ShellWindowViews::CanResize() const {
582 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_; 592 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_;
583 } 593 }
584 594
585 bool ShellWindowViews::CanMaximize() const { 595 bool ShellWindowViews::CanMaximize() const {
586 return CanResize(); 596 return CanResize();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 ui::WindowShowState show_state) { 744 ui::WindowShowState show_state) {
735 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); 745 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
736 shell_window_->SaveWindowPosition(); 746 shell_window_->SaveWindowPosition();
737 } 747 }
738 748
739 // static 749 // static
740 NativeShellWindow* NativeShellWindow::Create( 750 NativeShellWindow* NativeShellWindow::Create(
741 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { 751 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
742 return new ShellWindowViews(shell_window, params); 752 return new ShellWindowViews(shell_window, params);
743 } 753 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/shell_window_views.h ('k') | chrome/browser/ui/views/select_file_dialog_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698