summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/first_run_bubble.cc36
-rw-r--r--chrome/browser/views/first_run_bubble.h17
2 files changed, 43 insertions, 10 deletions
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index 043a972..4e4f111 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -17,6 +17,7 @@
#include "chrome/views/event.h"
#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/label.h"
+#include "chrome/views/focus/focus_manager.h"
#include "chrome/views/window/window.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -24,8 +25,8 @@
namespace {
-// How much extra padding to put around our content over what
-// infobubble provides.
+// How much extra padding to put around our content over what the InfoBubble
+// provides.
static const int kBubblePadding = 4;
std::wstring GetDefaultSearchEngineName(Profile* profile) {
@@ -49,7 +50,8 @@ std::wstring GetDefaultSearchEngineName(Profile* profile) {
// Implements the client view inside the first run bubble. It is kind of a
// dialog-ish view, but is not a true dialog.
class FirstRunBubbleView : public views::View,
- public views::NativeButton::Listener {
+ public views::NativeButton::Listener,
+ public views::FocusChangeListener {
public:
FirstRunBubbleView(FirstRunBubble* bubble_window, Profile* profile)
: bubble_window_(bubble_window),
@@ -164,6 +166,21 @@ class FirstRunBubbleView : public views::View,
IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES));
}
+ virtual void FocusWillChange(View* focused_before, View* focused_now) {
+ if (focused_before && focused_before->GetClassName() ==
+ views::NativeButton::kViewClassName) {
+ views::NativeButton* before =
+ static_cast<views::NativeButton*>(focused_before);
+ before->SetDefaultButton(false);
+ }
+ if (focused_now && focused_now->GetClassName() ==
+ views::NativeButton::kViewClassName) {
+ views::NativeButton* after =
+ static_cast<views::NativeButton*>(focused_now);
+ after->SetDefaultButton(true);
+ }
+ }
+
private:
FirstRunBubble* bubble_window_;
views::Label* label1_;
@@ -171,7 +188,8 @@ class FirstRunBubbleView : public views::View,
views::Label* label3_;
views::NativeButton* change_button_;
views::NativeButton* keep_button_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunBubbleView);
+
+ DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleView);
};
// Keep the bubble around for kLingerTime milliseconds, to prevent accidental
@@ -203,15 +221,23 @@ void FirstRunBubble::InfoBubbleClosing(InfoBubble* info_bubble,
if (!IsWindowEnabled(GetParent()))
::EnableWindow(GetParent(), true);
enable_window_method_factory_.RevokeAll();
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(GetNativeView());
+ focus_manager->RemoveFocusChangeListener(view_);
}
+// static
FirstRunBubble* FirstRunBubble::Show(Profile* profile, HWND parent_hwnd,
const gfx::Rect& position_relative_to) {
FirstRunBubble* window = new FirstRunBubble();
- views::View* view = new FirstRunBubbleView(window, profile);
+ FirstRunBubbleView* view = new FirstRunBubbleView(window, profile);
window->SetDelegate(window);
+ window->set_view(view);
window->Init(parent_hwnd, position_relative_to, view);
window->ShowWindow(SW_SHOW);
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(window->GetNativeView());
+ focus_manager->AddFocusChangeListener(view);
return window;
}
diff --git a/chrome/browser/views/first_run_bubble.h b/chrome/browser/views/first_run_bubble.h
index a358aa8..d921987 100644
--- a/chrome/browser/views/first_run_bubble.h
+++ b/chrome/browser/views/first_run_bubble.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H__
-#define CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H__
+#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H_
+#define CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H_
#include "base/task.h"
#include "chrome/browser/views/info_bubble.h"
+class FirstRunBubbleView;
class Profile;
class FirstRunBubble : public InfoBubble,
@@ -18,7 +19,8 @@ class FirstRunBubble : public InfoBubble,
FirstRunBubble()
: enable_window_method_factory_(this),
- has_been_activated_(false) {
+ has_been_activated_(false),
+ view_(NULL) {
}
virtual ~FirstRunBubble() {
@@ -27,6 +29,8 @@ class FirstRunBubble : public InfoBubble,
enable_window_method_factory_.RevokeAll();
}
+ void set_view(FirstRunBubbleView* view) { view_ = view; }
+
// Overridden from InfoBubble:
virtual void OnActivate(UINT action, BOOL minimized, HWND window);
@@ -44,7 +48,10 @@ class FirstRunBubble : public InfoBubble,
ScopedRunnableMethodFactory<FirstRunBubble> enable_window_method_factory_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunBubble);
+ // The view inside the FirstRunBubble.
+ FirstRunBubbleView* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(FirstRunBubble);
};
-#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H__
+#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H_