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

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

Issue 7294024: Sound volume and bightness bubbles doesn't grab focus anymore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge branch 'trunk' of http://git.chromium.org/git/chromium into 16867 Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bubble/bubble.cc
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index 477e96b6bd36cd0a44468f9654e0d5d13d49ba5f..6886d724d954cc373e8af8c65acfa24a154fd0b2 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -55,6 +55,10 @@ Bubble* Bubble::Show(views::Widget* parent,
Bubble* bubble = new Bubble;
bubble->InitBubble(parent, position_relative_to, arrow_location,
contents, delegate);
+
+ // Register the Escape accelerator for closing.
+ bubble->RegisterEscapeAccelerator();
+
return bubble;
}
@@ -139,7 +143,8 @@ Bubble::Bubble()
show_while_screen_is_locked_(false),
#endif
arrow_location_(BubbleBorder::NONE),
- contents_(NULL) {
+ contents_(NULL),
+ accelerator_registered_(false) {
}
#if defined(OS_CHROMEOS)
@@ -267,10 +272,6 @@ void Bubble::InitBubble(views::Widget* parent,
#endif
GetWidget()->SetBounds(window_bounds);
- // Register the Escape accelerator for closing.
- GetWidget()->GetFocusManager()->RegisterAccelerator(
- views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
-
// Done creating the bubble.
NotificationService::current()->Notify(NotificationType::INFO_BUBBLE_CREATED,
Source<Bubble>(this),
@@ -287,6 +288,19 @@ void Bubble::InitBubble(views::Widget* parent,
#endif
}
+void Bubble::RegisterEscapeAccelerator() {
+ GetWidget()->GetFocusManager()->RegisterAccelerator(
+ views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
+ accelerator_registered_ = true;
+}
+
+void Bubble::UnregisterEscapeAccelerator() {
+ DCHECK(accelerator_registered_);
+ GetWidget()->GetFocusManager()->UnregisterAccelerator(
+ views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
+ accelerator_registered_ = false;
+}
+
BorderContents* Bubble::CreateBorderContents() {
return new BorderContents();
}
@@ -334,8 +348,8 @@ void Bubble::DoClose(bool closed_by_escape) {
if (show_status_ == kClosed)
return;
- GetWidget()->GetFocusManager()->UnregisterAccelerator(
- views::Accelerator(ui::VKEY_ESCAPE, false, false, false), this);
+ if (accelerator_registered_)
+ UnregisterEscapeAccelerator();
if (delegate_)
delegate_->BubbleClosing(this, closed_by_escape);
show_status_ = kClosed;

Powered by Google App Engine
This is Rietveld 408576698