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

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

Issue 10825249: ash: Export some constants for some code cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self-nit Created 8 years, 4 months 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
« no previous file with comments | « ash/wm/frame_painter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/extensions/draggable_region.h" 9 #include "chrome/common/extensions/draggable_region.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
29 #include "ui/views/window/non_client_view.h" 29 #include "ui/views/window/non_client_view.h"
30 30
31 #if defined(OS_WIN) && !defined(USE_AURA) 31 #if defined(OS_WIN) && !defined(USE_AURA)
32 #include "chrome/browser/shell_integration.h" 32 #include "chrome/browser/shell_integration.h"
33 #include "chrome/browser/web_applications/web_app.h" 33 #include "chrome/browser/web_applications/web_app.h"
34 #include "ui/base/win/shell.h" 34 #include "ui/base/win/shell.h"
35 #endif 35 #endif
36 36
37 #if defined(USE_ASH) 37 #if defined(USE_ASH)
38 #include "ash/ash_constants.h"
38 #include "ash/wm/custom_frame_view_ash.h" 39 #include "ash/wm/custom_frame_view_ash.h"
39 #include "ui/aura/window.h" 40 #include "ui/aura/window.h"
40 #endif 41 #endif
41 42
42 namespace { 43 namespace {
43 // TODO(jeremya): these are copy/pasted from ash/wm/frame_painter.cc, and I'd 44 #if !defined(USE_ASH)
44 // like to find a way to avoid duplicating the constants.
45 #if defined(USE_ASH)
46 const int kResizeOutsideBoundsSizeTouch = 30;
47 const int kResizeOutsideBoundsSize = 6;
48 const int kResizeInsideBoundsSize = 1;
49 const int kResizeAreaCornerSize = 16;
50 #else
51 const int kResizeOutsideBoundsSizeTouch = 0;
52 const int kResizeOutsideBoundsSize = 0;
53 const int kResizeInsideBoundsSize = 5; 45 const int kResizeInsideBoundsSize = 5;
54 const int kResizeAreaCornerSize = 16; 46 const int kResizeAreaCornerSize = 16;
55 #endif 47 #endif
56 48
57 // Height of the chrome-style caption, in pixels. 49 // Height of the chrome-style caption, in pixels.
58 const int kCaptionHeight = 25; 50 const int kCaptionHeight = 25;
59 } // namespace 51 } // namespace
60 52
61 class ShellWindowFrameView : public views::NonClientFrameView, 53 class ShellWindowFrameView : public views::NonClientFrameView,
62 public views::ButtonListener { 54 public views::ButtonListener {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 rb.GetNativeImageNamed(IDR_CLOSE_BAR_P).ToImageSkia()); 115 rb.GetNativeImageNamed(IDR_CLOSE_BAR_P).ToImageSkia());
124 close_button_->SetAccessibleName( 116 close_button_->SetAccessibleName(
125 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); 117 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
126 AddChildView(close_button_); 118 AddChildView(close_button_);
127 } 119 }
128 120
129 #if defined(USE_ASH) 121 #if defined(USE_ASH)
130 aura::Window* window = frame->GetNativeWindow(); 122 aura::Window* window = frame->GetNativeWindow();
131 // Ensure we get resize cursors for a few pixels outside our bounds. 123 // Ensure we get resize cursors for a few pixels outside our bounds.
132 int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? 124 int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
133 kResizeOutsideBoundsSizeTouch : 125 ash::kResizeOutsideBoundsSizeTouch :
134 kResizeOutsideBoundsSize; 126 ash::kResizeOutsideBoundsSize;
135 window->set_hit_test_bounds_override_outer( 127 window->set_hit_test_bounds_override_outer(
136 gfx::Insets(-outside_bounds, -outside_bounds, 128 gfx::Insets(-outside_bounds, -outside_bounds,
137 -outside_bounds, -outside_bounds)); 129 -outside_bounds, -outside_bounds));
138 // Ensure we get resize cursors just inside our bounds as well. 130 // Ensure we get resize cursors just inside our bounds as well.
139 // TODO(jeremya): do we need to update these when in fullscreen/maximized? 131 // TODO(jeremya): do we need to update these when in fullscreen/maximized?
140 window->set_hit_test_bounds_override_inner( 132 window->set_hit_test_bounds_override_inner(
141 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 133 gfx::Insets(ash::kResizeInsideBoundsSize, ash::kResizeInsideBoundsSize,
142 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); 134 ash::kResizeInsideBoundsSize, ash::kResizeInsideBoundsSize));
143 #endif 135 #endif
144 } 136 }
145 137
146 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const { 138 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const {
147 if (window_->frameless() || frame_->IsFullscreen()) 139 if (window_->frameless() || frame_->IsFullscreen())
148 return bounds(); 140 return bounds();
149 return gfx::Rect(0, kCaptionHeight, width(), 141 return gfx::Rect(0, kCaptionHeight, width(),
150 std::max(0, height() - kCaptionHeight)); 142 std::max(0, height() - kCaptionHeight));
151 } 143 }
152 144
(...skipping 11 matching lines...) Expand all
164 client_bounds.height() + kCaptionHeight); 156 client_bounds.height() + kCaptionHeight);
165 } 157 }
166 158
167 int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) { 159 int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) {
168 if (frame_->IsFullscreen()) 160 if (frame_->IsFullscreen())
169 return HTCLIENT; 161 return HTCLIENT;
170 162
171 #if defined(USE_ASH) 163 #if defined(USE_ASH)
172 gfx::Rect expanded_bounds = bounds(); 164 gfx::Rect expanded_bounds = bounds();
173 int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? 165 int outside_bounds = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
174 kResizeOutsideBoundsSizeTouch : 166 ash::kResizeOutsideBoundsSizeTouch :
175 kResizeOutsideBoundsSize; 167 ash::kResizeOutsideBoundsSize;
176 expanded_bounds.Inset(-outside_bounds, -outside_bounds); 168 expanded_bounds.Inset(-outside_bounds, -outside_bounds);
177 if (!expanded_bounds.Contains(point)) 169 if (!expanded_bounds.Contains(point))
178 return HTNOWHERE; 170 return HTNOWHERE;
171
172 int kResizeInsideBoundsSize = ash::kResizeInsideBoundsSize;
173 int kResizeAreaCornerSize = ash::kResizeAreaCornerSize;
179 #endif 174 #endif
180 175
181 // Check the frame first, as we allow a small area overlapping the contents 176 // Check the frame first, as we allow a small area overlapping the contents
182 // to be used for resize handles. 177 // to be used for resize handles.
183 bool can_ever_resize = frame_->widget_delegate() ? 178 bool can_ever_resize = frame_->widget_delegate() ?
184 frame_->widget_delegate()->CanResize() : 179 frame_->widget_delegate()->CanResize() :
185 false; 180 false;
186 // Don't allow overlapping resize handles when the window is maximized or 181 // Don't allow overlapping resize handles when the window is maximized or
187 // fullscreen, as it can't be resized in those states. 182 // fullscreen, as it can't be resized in those states.
188 int resize_border = 183 int resize_border =
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 OnViewWasResized(); 576 OnViewWasResized();
582 } 577 }
583 578
584 // static 579 // static
585 ShellWindow* ShellWindow::CreateImpl(Profile* profile, 580 ShellWindow* ShellWindow::CreateImpl(Profile* profile,
586 const extensions::Extension* extension, 581 const extensions::Extension* extension,
587 const GURL& url, 582 const GURL& url,
588 const ShellWindow::CreateParams& params) { 583 const ShellWindow::CreateParams& params) {
589 return new ShellWindowViews(profile, extension, url, params); 584 return new ShellWindowViews(profile, extension, url, params);
590 } 585 }
OLDNEW
« no previous file with comments | « ash/wm/frame_painter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698