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

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

Issue 1443253004: Fix a regression caused by my change to make the first run bubble window display as an inactive win… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 9801719aee4412b50a5340952cedcc74cdfa3f38..bdab66c9ffc13a90fb7b519149b93d075e728a6e 100644
--- a/chrome/browser/ui/views/first_run_bubble.cc
+++ b/chrome/browser/ui/views/first_run_bubble.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/grit/generated_resources.h"
#include "components/search_engines/util.h"
+#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/label.h"
@@ -103,30 +104,48 @@ FirstRunBubble::FirstRunBubbleCloser::FirstRunBubbleCloser(
views::View* anchor_view)
: bubble_(bubble),
anchor_widget_(anchor_view->GetWidget()) {
- AddKeyboardEventObserver();
+ AddEventObservers();
}
FirstRunBubble::FirstRunBubbleCloser::~FirstRunBubbleCloser() {
if (anchor_widget_)
- RemoveKeyboardEventObserver();
+ RemoveEventObservers();
}
void FirstRunBubble::FirstRunBubbleCloser::OnKeyEvent(ui::KeyEvent* event) {
- if (!anchor_widget_)
- return;
+ CloseBubble();
+}
- RemoveKeyboardEventObserver();
- DCHECK(bubble_);
- bubble_->GetWidget()->Close();
- bubble_ = nullptr;
+void FirstRunBubble::FirstRunBubbleCloser::OnMouseEvent(
+ ui::MouseEvent* event) {
+ if (event->type() == ui::ET_MOUSE_PRESSED)
+ CloseBubble();
+}
+
+void FirstRunBubble::FirstRunBubbleCloser::OnGestureEvent(
+ ui::GestureEvent* event) {
+ if (event->type() == ui::ET_GESTURE_TAP ||
+ event->type() == ui::ET_GESTURE_TAP_DOWN) {
+ CloseBubble();
+ }
}
-void FirstRunBubble::FirstRunBubbleCloser::AddKeyboardEventObserver() {
- anchor_widget_->GetRootView()->AddPreTargetHandler(this);
+void FirstRunBubble::FirstRunBubbleCloser::AddEventObservers() {
+ anchor_widget_->GetNativeView()->AddPreTargetHandler(this);
}
-void FirstRunBubble::FirstRunBubbleCloser::RemoveKeyboardEventObserver() {
+void FirstRunBubble::FirstRunBubbleCloser::RemoveEventObservers() {
DCHECK(anchor_widget_);
- anchor_widget_->GetRootView()->RemovePreTargetHandler(this);
+ anchor_widget_->GetNativeView()->RemovePreTargetHandler(this);
anchor_widget_ = nullptr;
}
+
+void FirstRunBubble::FirstRunBubbleCloser::CloseBubble() {
+ if (!anchor_widget_)
+ return;
+
+ RemoveEventObservers();
+ DCHECK(bubble_);
+ bubble_->GetWidget()->Close();
+ bubble_ = 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