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

Side by Side Diff: chrome/browser/ui/views/extensions/native_app_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: rebase again Created 8 years 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/native_app_window_views.h" 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/favicon/favicon_tab_helper.h" 8 #include "chrome/browser/favicon/favicon_tab_helper.h"
9 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 9 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
10 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" 10 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 web_view_->SetWebContents(NULL); 71 web_view_->SetWebContents(NULL);
72 } 72 }
73 73
74 void NativeAppWindowViews::InitializeDefaultWindow( 74 void NativeAppWindowViews::InitializeDefaultWindow(
75 const ShellWindow::CreateParams& create_params) { 75 const ShellWindow::CreateParams& create_params) {
76 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); 76 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
77 init_params.delegate = this; 77 init_params.delegate = this;
78 init_params.remove_standard_frame = true; 78 init_params.remove_standard_frame = true;
79 init_params.use_system_default_icon = true; 79 init_params.use_system_default_icon = true;
80 window_->Init(init_params); 80 window_->Init(init_params);
81 gfx::Rect window_bounds = 81 gfx::Rect window_bounds = create_params.bounds;
82 window_->non_client_view()->GetWindowBoundsForClientBounds( 82 window_bounds.Inset(-GetFrameInsets());
83 create_params.bounds);
84 // Center window if no position was specified. 83 // Center window if no position was specified.
85 if (create_params.bounds.x() == INT_MIN || 84 if (create_params.bounds.x() == INT_MIN ||
86 create_params.bounds.y() == INT_MIN) { 85 create_params.bounds.y() == INT_MIN) {
87 window_->CenterWindow(window_bounds.size()); 86 window_->CenterWindow(window_bounds.size());
88 } else { 87 } else {
89 window_->SetBounds(window_bounds); 88 window_->SetBounds(window_bounds);
90 } 89 }
91 90
92 #if defined(OS_WIN) && !defined(USE_AURA) 91 #if defined(OS_WIN) && !defined(USE_AURA)
93 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( 92 std::string app_name = web_app::GenerateApplicationNameFromExtensionId(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 202 }
204 203
205 void NativeAppWindowViews::FlashFrame(bool flash) { 204 void NativeAppWindowViews::FlashFrame(bool flash) {
206 window_->FlashFrame(flash); 205 window_->FlashFrame(flash);
207 } 206 }
208 207
209 bool NativeAppWindowViews::IsAlwaysOnTop() const { 208 bool NativeAppWindowViews::IsAlwaysOnTop() const {
210 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL; 209 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL;
211 } 210 }
212 211
212 gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
213 if (frameless())
214 return gfx::Insets();
215
216 // The pretend client_bounds passed in need to be large enough to ensure that
217 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than
218 // the specified amount of space to fit the window controls in, and return a
219 // number larger than the real frame insets. Most window controls are smaller
220 // than 1000x1000px, so this should be big enough.
221 gfx::Rect client_bounds = gfx::Rect(1000, 1000);
222 gfx::Rect window_bounds =
223 window_->non_client_view()->GetWindowBoundsForClientBounds(
224 client_bounds);
225 return window_bounds.InsetsFrom(client_bounds);
226 }
227
213 // Private method. TODO(stevenjb): Move this below InitializePanelWindow() 228 // Private method. TODO(stevenjb): Move this below InitializePanelWindow()
214 // to match declaration order. 229 // to match declaration order.
215 void NativeAppWindowViews::OnViewWasResized() { 230 void NativeAppWindowViews::OnViewWasResized() {
216 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the 231 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the
217 // window shape in sync. 232 // window shape in sync.
218 #if defined(OS_WIN) && !defined(USE_AURA) 233 #if defined(OS_WIN) && !defined(USE_AURA)
219 // Set the window shape of the RWHV. 234 // Set the window shape of the RWHV.
220 DCHECK(window_); 235 DCHECK(window_);
221 DCHECK(web_view_); 236 DCHECK(web_view_);
222 gfx::Size sz = web_view_->size(); 237 gfx::Size sz = web_view_->size();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 476 }
462 477
463 //------------------------------------------------------------------------------ 478 //------------------------------------------------------------------------------
464 // NativeAppWindow::Create 479 // NativeAppWindow::Create
465 480
466 // static 481 // static
467 NativeAppWindow* NativeAppWindow::Create( 482 NativeAppWindow* NativeAppWindow::Create(
468 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { 483 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
469 return new NativeAppWindowViews(shell_window, params); 484 return new NativeAppWindowViews(shell_window, params);
470 } 485 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/native_app_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