| 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 "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class NotificationBarClientView : public views::ClientView { | 46 class NotificationBarClientView : public views::ClientView { |
| 47 public: | 47 public: |
| 48 NotificationBarClientView(views::Widget* widget, views::View* view) | 48 NotificationBarClientView(views::Widget* widget, views::View* view) |
| 49 : views::ClientView(widget, view) { | 49 : views::ClientView(widget, view) { |
| 50 } | 50 } |
| 51 virtual ~NotificationBarClientView() {} | 51 virtual ~NotificationBarClientView() {} |
| 52 | 52 |
| 53 void set_client_rect(const gfx::Rect& rect) { rect_ = rect; } | 53 void set_client_rect(const gfx::Rect& rect) { rect_ = rect; } |
| 54 | 54 |
| 55 // views::ClientView overrides. | 55 // views::ClientView overrides. |
| 56 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE { | 56 virtual int NonClientHitTest(const gfx::Point& point) override { |
| 57 if (!bounds().Contains(point)) | 57 if (!bounds().Contains(point)) |
| 58 return HTNOWHERE; | 58 return HTNOWHERE; |
| 59 // The whole window is HTCAPTION, except the |rect_|. | 59 // The whole window is HTCAPTION, except the |rect_|. |
| 60 if (rect_.Contains(gfx::PointAtOffsetFromOrigin(point - bounds().origin()))) | 60 if (rect_.Contains(gfx::PointAtOffsetFromOrigin(point - bounds().origin()))) |
| 61 return HTCLIENT; | 61 return HTCLIENT; |
| 62 | 62 |
| 63 return HTCAPTION; | 63 return HTCAPTION; |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 gfx::Rect rect_; | 67 gfx::Rect rect_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(NotificationBarClientView); | 69 DISALLOW_COPY_AND_ASSIGN(NotificationBarClientView); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 // ScreenCaptureNotificationUI implementation using Views. | 74 // ScreenCaptureNotificationUI implementation using Views. |
| 75 class ScreenCaptureNotificationUIViews | 75 class ScreenCaptureNotificationUIViews |
| 76 : public ScreenCaptureNotificationUI, | 76 : public ScreenCaptureNotificationUI, |
| 77 public views::WidgetDelegateView, | 77 public views::WidgetDelegateView, |
| 78 public views::ButtonListener, | 78 public views::ButtonListener, |
| 79 public views::LinkListener { | 79 public views::LinkListener { |
| 80 public: | 80 public: |
| 81 explicit ScreenCaptureNotificationUIViews(const base::string16& text); | 81 explicit ScreenCaptureNotificationUIViews(const base::string16& text); |
| 82 virtual ~ScreenCaptureNotificationUIViews(); | 82 virtual ~ScreenCaptureNotificationUIViews(); |
| 83 | 83 |
| 84 // ScreenCaptureNotificationUI interface. | 84 // ScreenCaptureNotificationUI interface. |
| 85 virtual gfx::NativeViewId OnStarted(const base::Closure& stop_callback) | 85 virtual gfx::NativeViewId OnStarted(const base::Closure& stop_callback) |
| 86 OVERRIDE; | 86 override; |
| 87 | 87 |
| 88 // views::View overrides. | 88 // views::View overrides. |
| 89 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 89 virtual gfx::Size GetPreferredSize() const override; |
| 90 virtual void Layout() OVERRIDE; | 90 virtual void Layout() override; |
| 91 | 91 |
| 92 // views::WidgetDelegateView overrides. | 92 // views::WidgetDelegateView overrides. |
| 93 virtual void DeleteDelegate() OVERRIDE; | 93 virtual void DeleteDelegate() override; |
| 94 virtual views::View* GetContentsView() OVERRIDE; | 94 virtual views::View* GetContentsView() override; |
| 95 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; | 95 virtual views::ClientView* CreateClientView(views::Widget* widget) override; |
| 96 virtual views::NonClientFrameView* CreateNonClientFrameView( | 96 virtual views::NonClientFrameView* CreateNonClientFrameView( |
| 97 views::Widget* widget) OVERRIDE; | 97 views::Widget* widget) override; |
| 98 virtual base::string16 GetWindowTitle() const OVERRIDE; | 98 virtual base::string16 GetWindowTitle() const override; |
| 99 virtual bool ShouldShowWindowTitle() const OVERRIDE; | 99 virtual bool ShouldShowWindowTitle() const override; |
| 100 virtual bool ShouldShowCloseButton() const OVERRIDE; | 100 virtual bool ShouldShowCloseButton() const override; |
| 101 virtual bool CanActivate() const OVERRIDE; | 101 virtual bool CanActivate() const override; |
| 102 | 102 |
| 103 // views::ButtonListener interface. | 103 // views::ButtonListener interface. |
| 104 virtual void ButtonPressed(views::Button* sender, | 104 virtual void ButtonPressed(views::Button* sender, |
| 105 const ui::Event& event) OVERRIDE; | 105 const ui::Event& event) override; |
| 106 | 106 |
| 107 // views::LinkListener interface. | 107 // views::LinkListener interface. |
| 108 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 108 virtual void LinkClicked(views::Link* source, int event_flags) override; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 // Helper to call |stop_callback_|. | 111 // Helper to call |stop_callback_|. |
| 112 void NotifyStopped(); | 112 void NotifyStopped(); |
| 113 | 113 |
| 114 const base::string16 text_; | 114 const base::string16 text_; |
| 115 base::Closure stop_callback_; | 115 base::Closure stop_callback_; |
| 116 NotificationBarClientView* client_view_; | 116 NotificationBarClientView* client_view_; |
| 117 views::ImageView* gripper_; | 117 views::ImageView* gripper_; |
| 118 views::Label* label_; | 118 views::Label* label_; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace | 328 } // namespace |
| 329 | 329 |
| 330 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( | 330 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( |
| 331 const base::string16& text) { | 331 const base::string16& text) { |
| 332 return scoped_ptr<ScreenCaptureNotificationUI>( | 332 return scoped_ptr<ScreenCaptureNotificationUI>( |
| 333 new ScreenCaptureNotificationUIViews(text)); | 333 new ScreenCaptureNotificationUIViews(text)); |
| 334 } | 334 } |
| OLD | NEW |