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

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

Issue 1786933002: Revert of [Extension UI Views] Add tests for clicking the different message bubble buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 "chrome/browser/ui/views/extensions/extension_message_bubble_view.h" 5 #include "chrome/browser/ui/views/extensions/extension_message_bubble_view.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 22 matching lines...) Expand all
33 const int kHeadlineRowPadding = 10; 33 const int kHeadlineRowPadding = 10;
34 const int kMessageBubblePadding = 11; 34 const int kMessageBubblePadding = 11;
35 35
36 // How long to wait until showing the bubble (in seconds). 36 // How long to wait until showing the bubble (in seconds).
37 int g_bubble_appearance_wait_time = 5; 37 int g_bubble_appearance_wait_time = 5;
38 38
39 } // namespace 39 } // namespace
40 40
41 namespace extensions { 41 namespace extensions {
42 42
43 ExtensionMessageBubbleView*
44 ExtensionMessageBubbleView::active_bubble_for_testing_ = nullptr;
45
46 ExtensionMessageBubbleView::ExtensionMessageBubbleView( 43 ExtensionMessageBubbleView::ExtensionMessageBubbleView(
47 views::View* anchor_view, 44 views::View* anchor_view,
48 views::BubbleBorder::Arrow arrow_location, 45 views::BubbleBorder::Arrow arrow_location,
49 scoped_ptr<extensions::ExtensionMessageBubbleController> controller) 46 scoped_ptr<extensions::ExtensionMessageBubbleController> controller)
50 : BubbleDelegateView(anchor_view, arrow_location), 47 : BubbleDelegateView(anchor_view, arrow_location),
51 controller_(std::move(controller)), 48 controller_(std::move(controller)),
52 anchor_view_(anchor_view), 49 anchor_view_(anchor_view),
53 headline_(NULL), 50 headline_(NULL),
54 learn_more_(NULL), 51 learn_more_(NULL),
55 dismiss_button_(NULL), 52 dismiss_button_(NULL),
(...skipping 17 matching lines...) Expand all
73 // bubbles into the focus cycle). Another benefit of delaying the show is 70 // bubbles into the focus cycle). Another benefit of delaying the show is
74 // that fade-in works (the fade-in isn't apparent if the the bubble appears at 71 // that fade-in works (the fade-in isn't apparent if the the bubble appears at
75 // startup). 72 // startup).
76 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 73 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
77 FROM_HERE, base::Bind(&ExtensionMessageBubbleView::ShowBubble, 74 FROM_HERE, base::Bind(&ExtensionMessageBubbleView::ShowBubble,
78 weak_factory_.GetWeakPtr()), 75 weak_factory_.GetWeakPtr()),
79 base::TimeDelta::FromSeconds(g_bubble_appearance_wait_time)); 76 base::TimeDelta::FromSeconds(g_bubble_appearance_wait_time));
80 } 77 }
81 78
82 void ExtensionMessageBubbleView::OnWidgetDestroying(views::Widget* widget) { 79 void ExtensionMessageBubbleView::OnWidgetDestroying(views::Widget* widget) {
83 if (active_bubble_for_testing_ == this)
84 active_bubble_for_testing_ = nullptr;
85 // To catch Esc, we monitor destroy message. Unless the link has been clicked, 80 // To catch Esc, we monitor destroy message. Unless the link has been clicked,
86 // we assume Dismiss was the action taken. 81 // we assume Dismiss was the action taken.
87 if (!link_clicked_ && !action_taken_) { 82 if (!link_clicked_ && !action_taken_) {
88 bool closed_on_deactivation = close_reason() == CloseReason::DEACTIVATION; 83 bool closed_on_deactivation = close_reason() == CloseReason::DEACTIVATION;
89 controller_->OnBubbleDismiss(closed_on_deactivation); 84 controller_->OnBubbleDismiss(closed_on_deactivation);
90 } 85 }
91 } 86 }
92 87
93 void ExtensionMessageBubbleView::set_bubble_appearance_wait_time_for_testing( 88 void ExtensionMessageBubbleView::set_bubble_appearance_wait_time_for_testing(
94 int time_in_seconds) { 89 int time_in_seconds) {
95 g_bubble_appearance_wait_time = time_in_seconds; 90 g_bubble_appearance_wait_time = time_in_seconds;
96 } 91 }
97 92
98 //////////////////////////////////////////////////////////////////////////////// 93 ////////////////////////////////////////////////////////////////////////////////
99 // ExtensionMessageBubbleView - private. 94 // ExtensionMessageBubbleView - private.
100 95
101 ExtensionMessageBubbleView::~ExtensionMessageBubbleView() {} 96 ExtensionMessageBubbleView::~ExtensionMessageBubbleView() {}
102 97
103 void ExtensionMessageBubbleView::ShowBubble() { 98 void ExtensionMessageBubbleView::ShowBubble() {
104 active_bubble_for_testing_ = this;
105 // Since we delay in showing the bubble, the applicable extension(s) may 99 // Since we delay in showing the bubble, the applicable extension(s) may
106 // have been removed. 100 // have been removed.
107 if (controller_->ShouldShow()) { 101 if (controller_->ShouldShow()) {
108 controller_->OnShown(); 102 controller_->OnShown();
109 GetWidget()->Show(); 103 GetWidget()->Show();
110 } else { 104 } else {
111 GetWidget()->Close(); 105 GetWidget()->Close();
112 } 106 }
113 } 107 }
114 108
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 state->role = ui::AX_ROLE_ALERT; 226 state->role = ui::AX_ROLE_ALERT;
233 } 227 }
234 228
235 void ExtensionMessageBubbleView::ViewHierarchyChanged( 229 void ExtensionMessageBubbleView::ViewHierarchyChanged(
236 const ViewHierarchyChangedDetails& details) { 230 const ViewHierarchyChangedDetails& details) {
237 if (details.is_add && details.child == this) 231 if (details.is_add && details.child == this)
238 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 232 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
239 } 233 }
240 234
241 } // namespace extensions 235 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698