summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@google.com <msw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 22:53:13 +0000
committermsw@google.com <msw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 22:53:13 +0000
commit8bce7075c2ef7334f3e624b41570123c4f29e6a8 (patch)
treeacaf9d77e8a5bc52a9a59ad29b19aa3324a91fe4
parentd8647346d2bfc756ce49d199a7f7a73a667dc918 (diff)
downloadchromium_src-8bce7075c2ef7334f3e624b41570123c4f29e6a8.zip
chromium_src-8bce7075c2ef7334f3e624b41570123c4f29e6a8.tar.gz
chromium_src-8bce7075c2ef7334f3e624b41570123c4f29e6a8.tar.bz2
Rebase the MessageBubble on the new views bubble.
Views screen locker password errors and the 3G promo bubble looks good; except: I filed crosbug.com/23324 for ScreenLockerViews MouseEventRelay. BUG=98322 TEST=MessageBubbles work as before (screen locker password errors, 3G MobileDataPromo). Review URL: http://codereview.chromium.org/8557005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112321 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/message_bubble.cc175
-rw-r--r--chrome/browser/chromeos/login/message_bubble.h94
-rw-r--r--chrome/browser/chromeos/login/screen_lock_view.cc11
-rw-r--r--chrome/browser/chromeos/login/screen_lock_view.h5
-rw-r--r--chrome/browser/chromeos/login/screen_locker_views.cc48
-rw-r--r--chrome/browser/chromeos/login/screen_locker_views.h15
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.cc52
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.h11
-rw-r--r--ui/views/bubble/bubble_delegate.cc3
-rw-r--r--ui/views/bubble/bubble_delegate.h3
10 files changed, 139 insertions, 278 deletions
diff --git a/chrome/browser/chromeos/login/message_bubble.cc b/chrome/browser/chromeos/login/message_bubble.cc
index 2758166..183070c 100644
--- a/chrome/browser/chromeos/login/message_bubble.cc
+++ b/chrome/browser/chromeos/login/message_bubble.cc
@@ -7,7 +7,6 @@
#include <vector>
#include "base/logging.h"
-#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
@@ -19,22 +18,34 @@
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
-namespace chromeos {
+namespace {
+
+const int kBorderSize = 4;
+const int kMaxLabelWidth = 250;
-static const int kBorderSize = 4;
-static const int kMaxLabelWidth = 250;
+} // namespace
+
+namespace chromeos {
-MessageBubble::MessageBubble(views::Widget::InitParams::Type type,
- views::Widget* parent,
+MessageBubble::MessageBubble(views::View* anchor_view,
+ views::BubbleBorder::ArrowLocation arrow_location,
SkBitmap* image,
- const std::wstring& text,
- const std::vector<std::wstring>& links,
- bool grab_enabled,
- MessageBubbleDelegate* delegate)
- : Bubble(type, false), // don't show while screen is locked
- parent_(parent),
- message_delegate_(delegate),
- grab_enabled_(grab_enabled) {
+ const string16& text,
+ const std::vector<string16>& links)
+ : BubbleDelegateView(anchor_view, arrow_location, kBackgroundColor),
+ image_(image),
+ text_(text),
+ close_button_(NULL),
+ link_listener_(NULL) {
+ set_use_focusless(true);
+ for (size_t i = 0; i < links.size(); ++i)
+ help_links_.push_back(new views::Link(links[i]));
+}
+
+MessageBubble::~MessageBubble() {
+}
+
+void MessageBubble::Init() {
using views::GridLayout;
views::View* control_view = new views::View();
@@ -49,9 +60,9 @@ MessageBubble::MessageBubble(views::Widget::InitParams::Type type,
column_set->AddPaddingColumn(0, kBorderSize);
column_set->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
GridLayout::USE_PREF, 0, 0);
- if (!links.empty()) {
+ if (!help_links_.empty()) {
column_set = layout->AddColumnSet(1);
- column_set->AddPaddingColumn(0, kBorderSize + image->width());
+ column_set->AddPaddingColumn(0, kBorderSize + image_->width());
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 1,
GridLayout::USE_PREF, 0, 0);
}
@@ -59,16 +70,15 @@ MessageBubble::MessageBubble(views::Widget::InitParams::Type type,
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
layout->StartRow(0, 0);
- icon_ = new views::ImageView();
- icon_->SetImage(*image);
- layout->AddView(icon_);
+ views::ImageView* icon = new views::ImageView();
+ icon->SetImage(*image_);
+ layout->AddView(icon);
- text_ = new views::Label(WideToUTF16Hack(text));
- text_->SetMultiLine(true);
- text_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- text_->SetBackgroundColor(Bubble::kBackgroundColor);
- text_->SizeToFit(kMaxLabelWidth);
- layout->AddView(text_);
+ views::Label* label = new views::Label(text_);
+ label->SetMultiLine(true);
+ label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ label->SizeToFit(kMaxLabelWidth);
+ layout->AddView(label);
close_button_ = new views::ImageButton(this);
close_button_->SetImage(views::CustomButton::BS_NORMAL,
@@ -79,132 +89,35 @@ MessageBubble::MessageBubble(views::Widget::InitParams::Type type,
rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
layout->AddView(close_button_);
- for (size_t i = 0; i < links.size(); ++i) {
+ for (size_t i = 0; i < help_links_.size(); ++i) {
layout->StartRowWithPadding(0, 1, 0, kBorderSize);
- views::Link* help_link_ = new views::Link(WideToUTF16Hack(links[i]));
- help_links_.push_back(help_link_);
- help_link_->set_listener(this);
- help_link_->SetBackgroundColor(Bubble::kBackgroundColor);
- help_link_->SetEnabledColor(login::kLinkColor);
- help_link_->SetPressedColor(login::kLinkColor);
- layout->AddView(help_link_);
+ views::Link* help_link = help_links_[i];
+ help_link->set_listener(this);
+ help_link->SetEnabledColor(login::kLinkColor);
+ help_link->SetPressedColor(login::kLinkColor);
+ layout->AddView(help_link);
}
}
-MessageBubble::~MessageBubble() {
-}
-
void MessageBubble::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_) {
- Close();
+ GetWidget()->Close();
} else {
NOTREACHED() << "Unknown view";
}
}
void MessageBubble::LinkClicked(views::Link* source, int event_flags) {
- if (!message_delegate_)
+ if (!link_listener_)
return;
for (size_t i = 0; i < help_links_.size(); ++i) {
if (source == help_links_[i]) {
- message_delegate_->OnLinkActivated(i);
+ link_listener_->OnLinkActivated(i);
return;
}
}
NOTREACHED() << "Unknown view";
}
-// static
-MessageBubble* MessageBubble::Show(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate) {
- std::vector<std::wstring> links;
- if (!help.empty())
- links.push_back(help);
- return MessageBubble::ShowWithLinks(parent,
- position_relative_to,
- arrow_location,
- image,
- text,
- links,
- delegate);
-}
-
-// static
-MessageBubble* MessageBubble::ShowWithLinks(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::vector<std::wstring>& links,
- MessageBubbleDelegate* delegate) {
- // The bubble will be destroyed when it is closed.
- MessageBubble* bubble = new MessageBubble(
- views::Widget::InitParams::TYPE_POPUP, parent, image, text, links,
- true, delegate);
- bubble->InitBubble(parent, position_relative_to, arrow_location,
- views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
- bubble->text_->parent(), delegate);
- return bubble;
-}
-
-// static
-MessageBubble* MessageBubble::ShowNoGrab(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate) {
- std::vector<std::wstring> links;
- if (!help.empty())
- links.push_back(help);
- // The bubble will be destroyed when it is closed.
- MessageBubble* bubble = new MessageBubble(
- views::Widget::InitParams::TYPE_CONTROL, parent, image, text, links,
- false, delegate);
- bubble->InitBubble(parent, position_relative_to, arrow_location,
- views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
- bubble->text_->parent(), delegate);
- return bubble;
-}
-
-#if defined(TOOLKIT_USES_GTK)
-// TODO(saintlou): Unclear if we need this for the !gtk case.
-void MessageBubble::OnActiveChanged() {
- if (parent_ && IsActive()) {
- // Show the parent.
- gtk_window_present_with_time(parent_->GetNativeWindow(),
- gtk_get_current_event_time());
- }
-}
-
-void MessageBubble::SetMouseCapture() {
- if (grab_enabled_)
- NativeWidgetGtk::SetMouseCapture();
-}
-#endif
-
-void MessageBubble::Close() {
- parent_ = NULL;
- Bubble::Close();
-}
-
-#if defined(TOOLKIT_USES_GTK)
-gboolean MessageBubble::OnButtonPress(GtkWidget* widget,
- GdkEventButton* event) {
- NativeWidgetGtk::OnButtonPress(widget, event);
- // Never propagate event to parent.
- return true;
-}
-#endif
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/message_bubble.h b/chrome/browser/chromeos/login/message_bubble.h
index 7d57251..2b28ac6 100644
--- a/chrome/browser/chromeos/login/message_bubble.h
+++ b/chrome/browser/chromeos/login/message_bubble.h
@@ -10,81 +10,47 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "chrome/browser/ui/views/bubble/bubble.h"
+#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/link_listener.h"
-#include "views/view.h"
-
-#if defined(TOOLKIT_USES_GTK)
-#include "ui/views/widget/native_widget_gtk.h"
-#endif
class SkBitmap;
namespace views {
class ImageButton;
-class ImageView;
-class Label;
}
namespace chromeos {
-class MessageBubbleDelegate : public BubbleDelegate {
+class MessageBubbleLinkListener {
public:
- // Called when the user clicked on help link.
- // |index| identifies which link was clicked if there's more than one.
+ // Called when the user clicks on help link.
+ // |index| identifies which link was clicked in case there's more than one.
virtual void OnLinkActivated(size_t index) = 0;
};
// MessageBubble is used to show error and info messages on OOBE screens.
-class MessageBubble : public Bubble,
+class MessageBubble : public views::BubbleDelegateView,
public views::ButtonListener,
public views::LinkListener {
public:
- // Create and show bubble. position_relative_to must be in screen coordinates.
- // |links| is an optional vector of links texts.
- static MessageBubble* Show(views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate);
-
- // Create and show bubble. position_relative_to must be in screen coordinates.
- // |links| is an optional vector of links texts.
- static MessageBubble* ShowWithLinks(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::vector<std::wstring>& links,
- MessageBubbleDelegate* delegate);
-
- // Create and show bubble which does not grab pointer. This creates
- // a TYPE_CHILD NativeWidgetGtk and |position_relative_to| must be in parent's
- // coordinates.
- static MessageBubble* ShowNoGrab(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate);
-
- // Overridden from NativeWidgetGtk/NativeWidgetViews.
- virtual void Close() OVERRIDE;
-
-#if defined(TOOLKIT_USES_GTK)
- virtual gboolean OnButtonPress(GtkWidget* widget,
- GdkEventButton* event) OVERRIDE;
-#endif
+ MessageBubble(views::View* anchor_view,
+ views::BubbleBorder::ArrowLocation arrow_location,
+ SkBitmap* image,
+ const string16& text,
+ const std::vector<string16>& links);
- protected:
virtual ~MessageBubble();
+ void set_link_listener(MessageBubbleLinkListener* link_listener) {
+ link_listener_ = link_listener;
+ }
+
+ protected:
+
+ // Overridden from views::BubbleDelegateView:
+ virtual void Init() OVERRIDE;
+
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE;
@@ -92,28 +58,12 @@ class MessageBubble : public Bubble,
// Overridden from views::LinkListener:
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
-#if defined(TOOLKIT_USES_GTK)
- // Overridden from NativeWidgetGtk.
- virtual void OnActiveChanged() OVERRIDE;
- virtual void SetMouseCapture() OVERRIDE;
-#endif
-
private:
- MessageBubble(views::Widget::InitParams::Type type,
- views::Widget* parent,
- SkBitmap* image,
- const std::wstring& text,
- const std::vector<std::wstring>& links,
- bool grab_enabled,
- MessageBubbleDelegate* delegate);
-
- views::Widget* parent_;
- views::ImageView* icon_;
- views::Label* text_;
+ SkBitmap* image_;
+ string16 text_;
views::ImageButton* close_button_;
std::vector<views::Link*> help_links_;
- MessageBubbleDelegate* message_delegate_;
- bool grab_enabled_;
+ MessageBubbleLinkListener* link_listener_;
DISALLOW_COPY_AND_ASSIGN(MessageBubble);
};
diff --git a/chrome/browser/chromeos/login/screen_lock_view.cc b/chrome/browser/chromeos/login/screen_lock_view.cc
index f8708c1..9eafac4 100644
--- a/chrome/browser/chromeos/login/screen_lock_view.cc
+++ b/chrome/browser/chromeos/login/screen_lock_view.cc
@@ -24,10 +24,13 @@
#include "ui/views/controls/textfield/native_textfield_wrapper.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
-#include "ui/views/widget/native_widget_gtk.h"
#include "views/background.h"
#include "views/border.h"
+#if defined(TOOLKIT_USES_GTK)
+#include "ui/views/widget/native_widget_gtk.h"
+#endif
+
namespace chromeos {
namespace {
@@ -200,12 +203,6 @@ void ScreenLockView::SetSignoutEnabled(bool enabled) {
user_view_->SetSignoutEnabled(enabled);
}
-gfx::Rect ScreenLockView::GetPasswordBoundsRelativeTo(const views::View* view) {
- gfx::Point p;
- views::View::ConvertPointToView(password_field_, view, &p);
- return gfx::Rect(p, size());
-}
-
void ScreenLockView::SetEnabled(bool enabled) {
views::View::SetEnabled(enabled);
diff --git a/chrome/browser/chromeos/login/screen_lock_view.h b/chrome/browser/chromeos/login/screen_lock_view.h
index 3c49547..5f8aaf1 100644
--- a/chrome/browser/chromeos/login/screen_lock_view.h
+++ b/chrome/browser/chromeos/login/screen_lock_view.h
@@ -41,9 +41,6 @@ class ScreenLockView : public ThrobberHostView,
// Enable/Disable signout button.
void SetSignoutEnabled(bool enabled);
- // Returns the bounds of the password field in ScreenLocker's coordinate.
- gfx::Rect GetPasswordBoundsRelativeTo(const views::View* view);
-
// views::View:
virtual void SetEnabled(bool enabled);
virtual void Layout() OVERRIDE;
@@ -64,6 +61,8 @@ class ScreenLockView : public ThrobberHostView,
virtual void OnSignout() OVERRIDE;
virtual bool IsUserSelected() const OVERRIDE;
+ views::Textfield* password_field() { return password_field_; }
+
private:
friend class test::ScreenLockerTester;
diff --git a/chrome/browser/chromeos/login/screen_locker_views.cc b/chrome/browser/chromeos/login/screen_locker_views.cc
index 6740bcf..7a82e25 100644
--- a/chrome/browser/chromeos/login/screen_locker_views.cc
+++ b/chrome/browser/chromeos/login/screen_locker_views.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/chromeos/view_ids.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/ui/views/window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "content/browser/user_metrics.h"
@@ -31,9 +32,11 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/screen.h"
+#include "ui/views/controls/textfield/textfield.h"
#if defined(TOOLKIT_USES_GTK)
#include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h"
+#include "ui/views/widget/native_widget_gtk.h"
#endif
namespace {
@@ -793,12 +796,15 @@ void ScreenLockerViews::ShowCaptchaAndErrorMessage(const GURL& captcha_url,
void ScreenLockerViews::ClearErrors() {
if (error_info_) {
- error_info_->Close();
+ error_info_->GetWidget()->Close();
error_info_ = NULL;
}
}
-void ScreenLockerViews::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
+void ScreenLockerViews::OnWidgetClosing(views::Widget* widget) {
+ if (!error_info_ || error_info_->GetWidget() != widget)
+ return;
+
error_info_ = NULL;
SetSignoutEnabled(true);
if (mouse_event_relay_.get()) {
@@ -807,17 +813,6 @@ void ScreenLockerViews::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
}
}
-bool ScreenLockerViews::CloseOnEscape() {
- return true;
-}
-
-bool ScreenLockerViews::FadeInOnShow() {
- return false;
-}
-
-void ScreenLockerViews::OnLinkActivated(size_t index) {
-}
-
void ScreenLockerViews::OnCaptchaEntered(const std::string& captcha) {
// Captcha dialog is only shown when LoginPerformer instance exists,
// i.e. blocking UI after password change is in place.
@@ -870,27 +865,26 @@ void ScreenLockerViews::OnWindowManagerReady() {
void ScreenLockerViews::ShowErrorBubble(
const string16& message,
views::BubbleBorder::ArrowLocation arrow_location) {
- if (error_info_)
- error_info_->Close();
-
- gfx::Rect rect = screen_lock_view_->GetPasswordBoundsRelativeTo(
- lock_widget_->GetRootView());
- gfx::Rect lock_widget_bounds = lock_widget_->GetClientAreaScreenBounds();
- rect.Offset(lock_widget_bounds.x(), lock_widget_bounds.y());
- error_info_ = MessageBubble::ShowNoGrab(
- lock_window_,
- rect,
+ ClearErrors();
+
+ // TODO(nkostylev): Add help link.
+ std::vector<string16> help_links;
+ error_info_ = new MessageBubble(
+ screen_lock_view_->password_field(),
arrow_location,
ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING),
- UTF16ToWide(message),
- UTF16ToWide(string16()), // TODO(nkostylev): Add help link.
- this);
+ message,
+ help_links);
+ browser::CreateViewsBubbleAboveLockScreen(error_info_);
+ error_info_->Show();
+ error_info_->GetWidget()->AddObserver(this);
if (mouse_event_relay_.get())
MessageLoopForUI::current()->RemoveObserver(mouse_event_relay_.get());
+ // TODO(oshima|msw): Investigate MouseEventRelay problems: crosbug.com/23324.
mouse_event_relay_.reset(
new MouseEventRelay(lock_widget_->GetNativeView()->window,
- error_info_->GetNativeView()->window));
+ error_info_->GetWidget()->GetNativeView()->window));
MessageLoopForUI::current()->AddObserver(mouse_event_relay_.get());
}
diff --git a/chrome/browser/chromeos/login/screen_locker_views.h b/chrome/browser/chromeos/login/screen_locker_views.h
index aa6eef8..f2b3f99 100644
--- a/chrome/browser/chromeos/login/screen_locker_views.h
+++ b/chrome/browser/chromeos/login/screen_locker_views.h
@@ -10,6 +10,10 @@
#include "chrome/browser/chromeos/login/message_bubble.h"
#include "chrome/browser/chromeos/login/screen_locker_delegate.h"
+#if defined(TOOLKIT_USES_GTK)
+#include "ui/base/gtk/gtk_signal.h"
+#endif
+
namespace chromeos {
class BackgroundView;
@@ -28,9 +32,9 @@ class ScreenLockerTester;
// shows a BackgroundView and a Signout button as well as creating a
// ScreenLockView to allow the user to log in.
class ScreenLockerViews : public ScreenLockerDelegate,
- public MessageBubbleDelegate,
public CaptchaView::Delegate,
- public ui::AcceleratorTarget {
+ public ui::AcceleratorTarget,
+ public views::Widget::Observer {
public:
// Interface that helps switching from ScreenLockView to CaptchaView.
class ScreenLockViewContainer {
@@ -67,11 +71,8 @@ class ScreenLockerViews : public ScreenLockerDelegate,
const string16& message) OVERRIDE;
virtual void ClearErrors() OVERRIDE;
- // Overridden from views::BubbleDelegate.
- virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
- virtual bool CloseOnEscape() OVERRIDE;
- virtual bool FadeInOnShow() OVERRIDE;
- virtual void OnLinkActivated(size_t index) OVERRIDE;
+ // views::Widget::Observer implementation:
+ virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
// CaptchaView::Delegate implementation:
virtual void OnCaptchaEntered(const std::string& captcha) OVERRIDE;
diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc
index f58461d..def7c92 100644
--- a/chrome/browser/chromeos/status/network_menu_button.cc
+++ b/chrome/browser/chromeos/status/network_menu_button.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/views/window.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -129,7 +130,7 @@ NetworkMenuButton::~NetworkMenuButton() {
if (!cellular_device_path_.empty())
netlib->RemoveNetworkDeviceObserver(cellular_device_path_, this);
if (mobile_data_bubble_)
- mobile_data_bubble_->Close();
+ mobile_data_bubble_->GetWidget()->Close();
}
// static
@@ -238,21 +239,19 @@ void NetworkMenuButton::NetworkMenuIconChanged() {
}
////////////////////////////////////////////////////////////////////////////////
-// MessageBubbleDelegate implementation:
+// views::Widget::Observer implementation:
+
+void NetworkMenuButton::OnWidgetClosing(views::Widget* widget) {
+ if (!mobile_data_bubble_ || mobile_data_bubble_->GetWidget() != widget)
+ return;
-void NetworkMenuButton::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
mobile_data_bubble_ = NULL;
deal_info_url_.clear();
deal_topup_url_.clear();
}
-bool NetworkMenuButton::CloseOnEscape() {
- return true;
-}
-
-bool NetworkMenuButton::FadeInOnShow() {
- return false;
-}
+////////////////////////////////////////////////////////////////////////////////
+// MessageBubbleLinkListener implementation:
void NetworkMenuButton::OnLinkActivated(size_t index) {
// If we have deal info URL defined that means that there're
@@ -260,7 +259,7 @@ void NetworkMenuButton::OnLinkActivated(size_t index) {
// to navigate to second link.
// mobile_data_bubble_ will be set to NULL in BubbleClosing callback.
if (deal_info_url_.empty() && mobile_data_bubble_)
- mobile_data_bubble_->Close();
+ mobile_data_bubble_->GetWidget()->Close();
std::string deal_url_to_open;
if (index == 0) {
@@ -410,13 +409,12 @@ void NetworkMenuButton::ShowOptionalMobileDataPromoNotification(
}
// Add deal text if it's defined.
- std::wstring notification_text;
- std::wstring default_text =
- UTF16ToWide(l10n_util::GetStringUTF16(IDS_3G_NOTIFICATION_MESSAGE));
+ string16 notification_text;
+ string16 default_text =
+ l10n_util::GetStringUTF16(IDS_3G_NOTIFICATION_MESSAGE);
if (!deal_text.empty()) {
- notification_text = StringPrintf(L"%ls\n\n%ls",
- UTF8ToWide(deal_text).c_str(),
- default_text.c_str());
+ notification_text =
+ UTF8ToUTF16(deal_text) + UTF8ToUTF16("\n\n") + default_text;
} else {
notification_text = default_text;
}
@@ -428,18 +426,20 @@ void NetworkMenuButton::ShowOptionalMobileDataPromoNotification(
else
link_message_id = IDS_STATUSBAR_NETWORK_VIEW_ACCOUNT;
- std::vector<std::wstring> links;
- links.push_back(UTF16ToWide(l10n_util::GetStringUTF16(link_message_id)));
+ std::vector<string16> links;
+ links.push_back(l10n_util::GetStringUTF16(link_message_id));
if (!deal_info_url_.empty())
- links.push_back(UTF16ToWide(l10n_util::GetStringUTF16(IDS_LEARN_MORE)));
- mobile_data_bubble_ = MessageBubble::ShowWithLinks(
- GetWidget(),
- button_bounds,
- views::BubbleBorder::TOP_RIGHT ,
+ links.push_back(l10n_util::GetStringUTF16(IDS_LEARN_MORE));
+ mobile_data_bubble_ = new MessageBubble(
+ this,
+ views::BubbleBorder::TOP_RIGHT,
ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_NOTIFICATION_3G),
notification_text,
- links,
- this);
+ links);
+ mobile_data_bubble_->set_link_listener(this);
+ browser::CreateViewsBubbleAboveLockScreen(mobile_data_bubble_);
+ mobile_data_bubble_->Show();
+ mobile_data_bubble_->GetWidget()->AddObserver(this);
check_for_promo_ = false;
SetShow3gPromoNotification(false);
diff --git a/chrome/browser/chromeos/status/network_menu_button.h b/chrome/browser/chromeos/status/network_menu_button.h
index 1bb51db..eaaab09 100644
--- a/chrome/browser/chromeos/status/network_menu_button.h
+++ b/chrome/browser/chromeos/status/network_menu_button.h
@@ -53,7 +53,8 @@ class NetworkMenuButton : public StatusAreaButton,
public NetworkLibrary::NetworkManagerObserver,
public NetworkLibrary::NetworkObserver,
public NetworkLibrary::CellularDataPlanObserver,
- public MessageBubbleDelegate {
+ public views::Widget::Observer,
+ public MessageBubbleLinkListener {
public:
explicit NetworkMenuButton(StatusAreaButton::Delegate* delegate);
virtual ~NetworkMenuButton();
@@ -89,10 +90,10 @@ class NetworkMenuButton : public StatusAreaButton,
// views::ViewMenuDelegate implementation.
virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE;
- // MessageBubbleDelegate implementation:
- virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
- virtual bool CloseOnEscape() OVERRIDE;
- virtual bool FadeInOnShow() OVERRIDE;
+ // views::Widget::Observer implementation:
+ virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
+
+ // MessageBubbleLinkListener implementation:
virtual void OnLinkActivated(size_t index) OVERRIDE;
private:
diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index dc459d3..f262a33 100644
--- a/ui/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
@@ -71,6 +71,9 @@ Widget* CreateBorderWidget(BubbleDelegateView* bubble, Widget* parent) {
} // namespace
+// TODO(msw): Use NativeTheme/color_helper (crbug.com/105023).
+const SkColor BubbleDelegateView::kBackgroundColor = SK_ColorWHITE;
+
BubbleDelegateView::BubbleDelegateView()
: close_on_esc_(true),
close_on_deactivate_(true),
diff --git a/ui/views/bubble/bubble_delegate.h b/ui/views/bubble/bubble_delegate.h
index ddf9785..0e7da9b 100644
--- a/ui/views/bubble/bubble_delegate.h
+++ b/ui/views/bubble/bubble_delegate.h
@@ -87,6 +87,9 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// bubble to the setting before StartFade() was called.
void ResetFade();
+ // The default bubble background color.
+ static const SkColor kBackgroundColor;
+
protected:
// View overrides:
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;