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

Side by Side Diff: ui/message_center/views/toast_contents_view.cc

Issue 2726773003: Reland: Make popup notification active on being clicked (Closed)
Patch Set: Relanded Patch Created 3 years, 9 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
« no previous file with comments | « ui/message_center/views/toast_contents_view.h ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/message_center/views/toast_contents_view.h" 5 #include "ui/message_center/views/toast_contents_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 26 matching lines...) Expand all
37 37
38 // The width of a toast before animated reveal and after closing. 38 // The width of a toast before animated reveal and after closing.
39 const int kClosedToastWidth = 5; 39 const int kClosedToastWidth = 5;
40 40
41 // FadeIn/Out look a bit better if they are slightly longer then default slide. 41 // FadeIn/Out look a bit better if they are slightly longer then default slide.
42 const int kFadeInOutDuration = 200; 42 const int kFadeInOutDuration = 200;
43 43
44 } // namespace. 44 } // namespace.
45 45
46 // static 46 // static
47 const char ToastContentsView::kViewClassName[] = "ToastContentsView";
48
49 // static
47 gfx::Size ToastContentsView::GetToastSizeForView(const views::View* view) { 50 gfx::Size ToastContentsView::GetToastSizeForView(const views::View* view) {
48 int width = kNotificationWidth + view->GetInsets().width(); 51 int width = kNotificationWidth + view->GetInsets().width();
49 return gfx::Size(width, view->GetHeightForWidth(width)); 52 return gfx::Size(width, view->GetHeightForWidth(width));
50 } 53 }
51 54
52 ToastContentsView::ToastContentsView( 55 ToastContentsView::ToastContentsView(
53 const std::string& notification_id, 56 const std::string& notification_id,
54 PopupAlignmentDelegate* alignment_delegate, 57 PopupAlignmentDelegate* alignment_delegate,
55 base::WeakPtr<MessagePopupCollection> collection) 58 base::WeakPtr<MessagePopupCollection> collection)
56 : collection_(collection), 59 : collection_(collection),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (collection_) 164 if (collection_)
162 collection_->IncrementDeferCounter(); 165 collection_->IncrementDeferCounter();
163 166
164 if (bounds_animation_.get()) 167 if (bounds_animation_.get())
165 bounds_animation_->Stop(); 168 bounds_animation_->Stop();
166 169
167 bounds_animation_.reset(new gfx::SlideAnimation(this)); 170 bounds_animation_.reset(new gfx::SlideAnimation(this));
168 bounds_animation_->Show(); 171 bounds_animation_->Show();
169 } 172 }
170 173
174 void ToastContentsView::ActivateToast() {
175 set_can_activate(true);
176 if (GetWidget())
177 GetWidget()->Activate();
178 }
179
171 void ToastContentsView::StartFadeIn() { 180 void ToastContentsView::StartFadeIn() {
172 // The decrement is done in OnBoundsAnimationEndedOrCancelled callback. 181 // The decrement is done in OnBoundsAnimationEndedOrCancelled callback.
173 if (collection_) 182 if (collection_)
174 collection_->IncrementDeferCounter(); 183 collection_->IncrementDeferCounter();
175 fade_animation_->Stop(); 184 fade_animation_->Stop();
176 185
177 GetWidget()->SetOpacity(0); 186 GetWidget()->SetOpacity(0);
178 GetWidget()->ShowInactive(); 187 GetWidget()->ShowInactive();
179 fade_animation_->Reset(0); 188 fade_animation_->Reset(0);
180 fade_animation_->Show(); 189 fade_animation_->Show();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 317 }
309 SetBoundsWithAnimation(bounds()); 318 SetBoundsWithAnimation(bounds());
310 } 319 }
311 320
312 void ToastContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 321 void ToastContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
313 if (child_count() > 0) 322 if (child_count() > 0)
314 child_at(0)->GetAccessibleNodeData(node_data); 323 child_at(0)->GetAccessibleNodeData(node_data);
315 node_data->role = ui::AX_ROLE_WINDOW; 324 node_data->role = ui::AX_ROLE_WINDOW;
316 } 325 }
317 326
327 const char* ToastContentsView::GetClassName() const {
328 return kViewClassName;
329 }
330
318 void ToastContentsView::ClickOnNotification( 331 void ToastContentsView::ClickOnNotification(
319 const std::string& notification_id) { 332 const std::string& notification_id) {
320 if (collection_) 333 if (collection_)
321 collection_->ClickOnNotification(notification_id); 334 collection_->ClickOnNotification(notification_id);
322 } 335 }
323 336
324 void ToastContentsView::ClickOnSettingsButton( 337 void ToastContentsView::ClickOnSettingsButton(
325 const std::string& notification_id) { 338 const std::string& notification_id) {
326 if (collection_) 339 if (collection_)
327 collection_->ClickOnSettingsButton(notification_id); 340 collection_->ClickOnSettingsButton(notification_id);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 402 }
390 403
391 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { 404 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) {
392 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, 405 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth,
393 bounds.y(), 406 bounds.y(),
394 kClosedToastWidth, 407 kClosedToastWidth,
395 bounds.height()); 408 bounds.height());
396 } 409 }
397 410
398 } // namespace message_center 411 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/toast_contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698