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

Unified Diff: chrome/browser/ui/views/first_run_bubble.cc

Issue 1411423014: Ensure that the first run bubble displays as an inactive bubble window which ensures that it does n… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cache the anchor widget instead of the anchor view in the bubble closer class Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble.h ('k') | chrome/browser/ui/views/first_run_bubble_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/first_run_bubble.cc
diff --git a/chrome/browser/ui/views/first_run_bubble.cc b/chrome/browser/ui/views/first_run_bubble.cc
index c086fdeae46636e7fd654c95f7e2bb8681768079..9801719aee4412b50a5340952cedcc74cdfa3f38 100644
--- a/chrome/browser/ui/views/first_run_bubble.cc
+++ b/chrome/browser/ui/views/first_run_bubble.cc
@@ -32,7 +32,7 @@ FirstRunBubble* FirstRunBubble::ShowBubble(Browser* browser,
first_run::LogFirstRunMetric(first_run::FIRST_RUN_BUBBLE_SHOWN);
FirstRunBubble* delegate = new FirstRunBubble(browser, anchor_view);
- views::BubbleDelegateView::CreateBubble(delegate)->Show();
+ views::BubbleDelegateView::CreateBubble(delegate)->ShowInactive();
return delegate;
}
@@ -80,7 +80,8 @@ void FirstRunBubble::Init() {
FirstRunBubble::FirstRunBubble(Browser* browser, views::View* anchor_view)
: views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
- browser_(browser) {
+ browser_(browser),
+ bubble_closer_(this, anchor_view) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_view_insets(
gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0));
@@ -96,3 +97,36 @@ void FirstRunBubble::LinkClicked(views::Link* source, int event_flags) {
if (browser_)
chrome::ShowSearchEngineSettings(browser_);
}
+
+FirstRunBubble::FirstRunBubbleCloser::FirstRunBubbleCloser(
+ FirstRunBubble* bubble,
+ views::View* anchor_view)
+ : bubble_(bubble),
+ anchor_widget_(anchor_view->GetWidget()) {
+ AddKeyboardEventObserver();
+}
+
+FirstRunBubble::FirstRunBubbleCloser::~FirstRunBubbleCloser() {
+ if (anchor_widget_)
+ RemoveKeyboardEventObserver();
+}
+
+void FirstRunBubble::FirstRunBubbleCloser::OnKeyEvent(ui::KeyEvent* event) {
+ if (!anchor_widget_)
+ return;
+
+ RemoveKeyboardEventObserver();
+ DCHECK(bubble_);
+ bubble_->GetWidget()->Close();
+ bubble_ = nullptr;
+}
+
+void FirstRunBubble::FirstRunBubbleCloser::AddKeyboardEventObserver() {
+ anchor_widget_->GetRootView()->AddPreTargetHandler(this);
+}
+
+void FirstRunBubble::FirstRunBubbleCloser::RemoveKeyboardEventObserver() {
+ DCHECK(anchor_widget_);
+ anchor_widget_->GetRootView()->RemovePreTargetHandler(this);
+ anchor_widget_ = nullptr;
+}
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble.h ('k') | chrome/browser/ui/views/first_run_bubble_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698