| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/screen_capture_notification_ui.h" | 5 #include "chrome/browser/ui/screen_capture_notification_ui.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/ui/views/chrome_views_export.h" | 9 #include "chrome/browser/ui/views/chrome_views_export.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/views/win/hwnd_util.h" | 28 #include "ui/views/win/hwnd_util.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const int kMinimumWidth = 460; | 33 const int kMinimumWidth = 460; |
| 34 const int kMaximumWidth = 1000; | 34 const int kMaximumWidth = 1000; |
| 35 const int kHorizontalMargin = 10; | 35 const int kHorizontalMargin = 10; |
| 36 const int kPadding = 5; | 36 const int kPadding = 5; |
| 37 const int kPaddingLeft = 10; | 37 const int kPaddingLeft = 10; |
| 38 const float kWindowAlphaValue = 0.85f; |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 // A ClientView that overrides NonClientHitTest() so that the whole window area | 42 // A ClientView that overrides NonClientHitTest() so that the whole window area |
| 42 // acts as a window caption, except a rect specified using SetClientRect(). | 43 // acts as a window caption, except a rect specified using SetClientRect(). |
| 43 // ScreenCaptureNotificationUIViews uses this class to make the notification bar | 44 // ScreenCaptureNotificationUIViews uses this class to make the notification bar |
| 44 // draggable. | 45 // draggable. |
| 45 class NotificationBarClientView : public views::ClientView { | 46 class NotificationBarClientView : public views::ClientView { |
| 46 public: | 47 public: |
| 47 NotificationBarClientView(views::Widget* widget, views::View* view) | 48 NotificationBarClientView(views::Widget* widget, views::View* view) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // per-display screen capture is supported. | 201 // per-display screen capture is supported. |
| 201 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area(); | 202 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area(); |
| 202 | 203 |
| 203 // Place the bar in the center of the bottom of the display. | 204 // Place the bar in the center of the bottom of the display. |
| 204 gfx::Size size = widget->non_client_view()->GetPreferredSize(); | 205 gfx::Size size = widget->non_client_view()->GetPreferredSize(); |
| 205 gfx::Rect bounds( | 206 gfx::Rect bounds( |
| 206 work_area.x() + work_area.width() / 2 - size.width() / 2, | 207 work_area.x() + work_area.width() / 2 - size.width() / 2, |
| 207 work_area.y() + work_area.height() - size.height(), | 208 work_area.y() + work_area.height() - size.height(), |
| 208 size.width(), size.height()); | 209 size.width(), size.height()); |
| 209 widget->SetBounds(bounds); | 210 widget->SetBounds(bounds); |
| 210 | 211 widget->SetOpacity(0xFF * kWindowAlphaValue); |
| 211 widget->Show(); | 212 widget->Show(); |
| 212 | 213 |
| 213 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
| 214 return gfx::NativeViewId(views::HWNDForWidget(widget)); | 215 return gfx::NativeViewId(views::HWNDForWidget(widget)); |
| 215 #else | 216 #else |
| 216 return 0; | 217 return 0; |
| 217 #endif | 218 #endif |
| 218 } | 219 } |
| 219 | 220 |
| 220 gfx::Size ScreenCaptureNotificationUIViews::GetPreferredSize() { | 221 gfx::Size ScreenCaptureNotificationUIViews::GetPreferredSize() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 327 } |
| 327 } | 328 } |
| 328 | 329 |
| 329 } // namespace | 330 } // namespace |
| 330 | 331 |
| 331 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( | 332 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( |
| 332 const base::string16& text) { | 333 const base::string16& text) { |
| 333 return scoped_ptr<ScreenCaptureNotificationUI>( | 334 return scoped_ptr<ScreenCaptureNotificationUI>( |
| 334 new ScreenCaptureNotificationUIViews(text)); | 335 new ScreenCaptureNotificationUIViews(text)); |
| 335 } | 336 } |
| OLD | NEW |