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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/extensions/native_app_window_views.cc
diff --git a/chrome/browser/ui/views/extensions/native_app_window_views.cc b/chrome/browser/ui/views/extensions/native_app_window_views.cc
index 1f7f7c406b2a30108557c356f6a15d3b45c3385f..e84b7ac0321ffe19ba6e04e0eb563507d3576d9b 100644
--- a/chrome/browser/ui/views/extensions/native_app_window_views.cc
+++ b/chrome/browser/ui/views/extensions/native_app_window_views.cc
@@ -78,9 +78,8 @@ void NativeAppWindowViews::InitializeDefaultWindow(
init_params.remove_standard_frame = true;
init_params.use_system_default_icon = true;
window_->Init(init_params);
- gfx::Rect window_bounds =
- window_->non_client_view()->GetWindowBoundsForClientBounds(
- create_params.bounds);
+ gfx::Rect window_bounds = create_params.bounds;
+ window_bounds.Inset(-GetFrameInsets());
// Center window if no position was specified.
if (create_params.bounds.x() == INT_MIN ||
create_params.bounds.y() == INT_MIN) {
@@ -210,6 +209,22 @@ bool NativeAppWindowViews::IsAlwaysOnTop() const {
return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL;
}
+gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
+ if (frameless())
+ return gfx::Insets();
+
+ // The pretend client_bounds passed in need to be large enough to ensure that
+ // GetWindowBoundsForClientBounds() doesn't decide that it needs more than
+ // the specified amount of space to fit the window controls in, and return a
+ // number larger than the real frame insets. Most window controls are smaller
+ // than 1000x1000px, so this should be big enough.
+ gfx::Rect client_bounds = gfx::Rect(1000, 1000);
+ gfx::Rect window_bounds =
+ window_->non_client_view()->GetWindowBoundsForClientBounds(
+ client_bounds);
+ return window_bounds.InsetsFrom(client_bounds);
+}
+
// Private method. TODO(stevenjb): Move this below InitializePanelWindow()
// to match declaration order.
void NativeAppWindowViews::OnViewWasResized() {
« 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