OLD | NEW |
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 "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/thread_task_runner_handle.h" |
8 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 11 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
9 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
10 #include "chrome/grit/locale_settings.h" | 13 #include "chrome/grit/locale_settings.h" |
11 #include "ui/accessibility/ax_view_state.h" | 14 #include "ui/accessibility/ax_view_state.h" |
12 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/views/controls/button/label_button.h" | 16 #include "ui/views/controls/button/label_button.h" |
14 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
15 #include "ui/views/controls/link.h" | 18 #include "ui/views/controls/link.h" |
16 #include "ui/views/layout/grid_layout.h" | 19 #include "ui/views/layout/grid_layout.h" |
17 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 61 |
59 void ExtensionMessageBubbleView::Show() { | 62 void ExtensionMessageBubbleView::Show() { |
60 // Not showing the bubble right away (during startup) has a few benefits: | 63 // Not showing the bubble right away (during startup) has a few benefits: |
61 // We don't have to worry about focus being lost due to the Omnibox (or to | 64 // We don't have to worry about focus being lost due to the Omnibox (or to |
62 // other things that want focus at startup). This allows Esc to work to close | 65 // other things that want focus at startup). This allows Esc to work to close |
63 // the bubble and also solves the keyboard accessibility problem that comes | 66 // the bubble and also solves the keyboard accessibility problem that comes |
64 // with focus being lost (we don't have a good generic mechanism of injecting | 67 // with focus being lost (we don't have a good generic mechanism of injecting |
65 // bubbles into the focus cycle). Another benefit of delaying the show is | 68 // bubbles into the focus cycle). Another benefit of delaying the show is |
66 // that fade-in works (the fade-in isn't apparent if the the bubble appears at | 69 // that fade-in works (the fade-in isn't apparent if the the bubble appears at |
67 // startup). | 70 // startup). |
68 base::MessageLoop::current()->PostDelayedTask( | 71 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
69 FROM_HERE, | 72 FROM_HERE, base::Bind(&ExtensionMessageBubbleView::ShowBubble, |
70 base::Bind(&ExtensionMessageBubbleView::ShowBubble, | 73 weak_factory_.GetWeakPtr()), |
71 weak_factory_.GetWeakPtr()), | |
72 base::TimeDelta::FromSeconds(kBubbleAppearanceWaitTime)); | 74 base::TimeDelta::FromSeconds(kBubbleAppearanceWaitTime)); |
73 } | 75 } |
74 | 76 |
75 void ExtensionMessageBubbleView::OnWidgetDestroying(views::Widget* widget) { | 77 void ExtensionMessageBubbleView::OnWidgetDestroying(views::Widget* widget) { |
76 // To catch Esc, we monitor destroy message. Unless the link has been clicked, | 78 // To catch Esc, we monitor destroy message. Unless the link has been clicked, |
77 // we assume Dismiss was the action taken. | 79 // we assume Dismiss was the action taken. |
78 if (!link_clicked_ && !action_taken_) | 80 if (!link_clicked_ && !action_taken_) |
79 controller_->OnBubbleDismiss(); | 81 controller_->OnBubbleDismiss(); |
80 } | 82 } |
81 | 83 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 state->role = ui::AX_ROLE_ALERT; | 209 state->role = ui::AX_ROLE_ALERT; |
208 } | 210 } |
209 | 211 |
210 void ExtensionMessageBubbleView::ViewHierarchyChanged( | 212 void ExtensionMessageBubbleView::ViewHierarchyChanged( |
211 const ViewHierarchyChangedDetails& details) { | 213 const ViewHierarchyChangedDetails& details) { |
212 if (details.is_add && details.child == this) | 214 if (details.is_add && details.child == this) |
213 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 215 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
214 } | 216 } |
215 | 217 |
216 } // namespace extensions | 218 } // namespace extensions |
OLD | NEW |