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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // A ClientView that overrides NonClientHitTest() so that the whole window area | 42 // A ClientView that overrides NonClientHitTest() so that the whole window area |
43 // acts as a window caption, except a rect specified using set_client_rect(). | 43 // acts as a window caption, except a rect specified using set_client_rect(). |
44 // ScreenCaptureNotificationUIViews uses this class to make the notification bar | 44 // ScreenCaptureNotificationUIViews uses this class to make the notification bar |
45 // draggable. | 45 // draggable. |
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 ~NotificationBarClientView() override {} |
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 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 ~ScreenCaptureNotificationUIViews() override; |
83 | 83 |
84 // ScreenCaptureNotificationUI interface. | 84 // ScreenCaptureNotificationUI interface. |
85 virtual gfx::NativeViewId OnStarted(const base::Closure& stop_callback) | 85 gfx::NativeViewId OnStarted(const base::Closure& stop_callback) override; |
86 override; | |
87 | 86 |
88 // views::View overrides. | 87 // views::View overrides. |
89 virtual gfx::Size GetPreferredSize() const override; | 88 gfx::Size GetPreferredSize() const override; |
90 virtual void Layout() override; | 89 void Layout() override; |
91 | 90 |
92 // views::WidgetDelegateView overrides. | 91 // views::WidgetDelegateView overrides. |
93 virtual void DeleteDelegate() override; | 92 void DeleteDelegate() override; |
94 virtual views::View* GetContentsView() override; | 93 views::View* GetContentsView() override; |
95 virtual views::ClientView* CreateClientView(views::Widget* widget) override; | 94 views::ClientView* CreateClientView(views::Widget* widget) override; |
96 virtual views::NonClientFrameView* CreateNonClientFrameView( | 95 views::NonClientFrameView* CreateNonClientFrameView( |
97 views::Widget* widget) override; | 96 views::Widget* widget) override; |
98 virtual base::string16 GetWindowTitle() const override; | 97 base::string16 GetWindowTitle() const override; |
99 virtual bool ShouldShowWindowTitle() const override; | 98 bool ShouldShowWindowTitle() const override; |
100 virtual bool ShouldShowCloseButton() const override; | 99 bool ShouldShowCloseButton() const override; |
101 virtual bool CanActivate() const override; | 100 bool CanActivate() const override; |
102 | 101 |
103 // views::ButtonListener interface. | 102 // views::ButtonListener interface. |
104 virtual void ButtonPressed(views::Button* sender, | 103 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
105 const ui::Event& event) override; | |
106 | 104 |
107 // views::LinkListener interface. | 105 // views::LinkListener interface. |
108 virtual void LinkClicked(views::Link* source, int event_flags) override; | 106 void LinkClicked(views::Link* source, int event_flags) override; |
109 | 107 |
110 private: | 108 private: |
111 // Helper to call |stop_callback_|. | 109 // Helper to call |stop_callback_|. |
112 void NotifyStopped(); | 110 void NotifyStopped(); |
113 | 111 |
114 const base::string16 text_; | 112 const base::string16 text_; |
115 base::Closure stop_callback_; | 113 base::Closure stop_callback_; |
116 NotificationBarClientView* client_view_; | 114 NotificationBarClientView* client_view_; |
117 views::ImageView* gripper_; | 115 views::ImageView* gripper_; |
118 views::Label* label_; | 116 views::Label* label_; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 323 } |
326 } | 324 } |
327 | 325 |
328 } // namespace | 326 } // namespace |
329 | 327 |
330 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( | 328 scoped_ptr<ScreenCaptureNotificationUI> ScreenCaptureNotificationUI::Create( |
331 const base::string16& text) { | 329 const base::string16& text) { |
332 return scoped_ptr<ScreenCaptureNotificationUI>( | 330 return scoped_ptr<ScreenCaptureNotificationUI>( |
333 new ScreenCaptureNotificationUIViews(text)); | 331 new ScreenCaptureNotificationUIViews(text)); |
334 } | 332 } |
OLD | NEW |