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

Unified Diff: chrome/browser/views/toolbar_view.cc

Issue 53096: Broadcast a state change notification from the toolbar to the RenderWidgetHos... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | chrome/common/notification_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/toolbar_view.cc
===================================================================
--- chrome/browser/views/toolbar_view.cc (revision 12533)
+++ chrome/browser/views/toolbar_view.cc (working copy)
@@ -66,6 +66,7 @@
model_(browser->toolbar_model()),
back_(NULL),
forward_(NULL),
+ threedee_(NULL),
reload_(NULL),
home_(NULL),
star_(NULL),
@@ -84,9 +85,18 @@
display_mode_ = DISPLAYMODE_NORMAL;
else
display_mode_ = DISPLAYMODE_LOCATION;
+
+ NotificationService::current()->AddObserver(
+ this,
+ NOTIFY_THREEDEE_TOGGLED,
+ NotificationService::AllSources());
}
BrowserToolbarView::~BrowserToolbarView() {
+ NotificationService::current()->RemoveObserver(
+ this,
+ NOTIFY_THREEDEE_TOGGLED,
+ NotificationService::AllSources());
}
void BrowserToolbarView::Init(Profile* profile) {
@@ -135,6 +145,19 @@
AddChildView(forward_);
controller_->AddManagedButton(forward_, IDC_FORWARD);
+ threedee_ = new views::ToggleButton();
+ threedee_->SetListener(this, IDC_THREEDEE);
+ threedee_->SetImage(views::BaseButton::BS_NORMAL,
+ rb.GetBitmapNamed(IDR_3D));
+ threedee_->SetImage(views::BaseButton::BS_HOT,
+ rb.GetBitmapNamed(IDR_3D_H));
+ threedee_->SetImage(views::BaseButton::BS_PUSHED,
+ rb.GetBitmapNamed(IDR_3D_P));
+ threedee_->SetToggledImage(views::BaseButton::BS_NORMAL,
+ rb.GetBitmapNamed(IDR_3D_C));
+ threedee_->SetID(VIEW_ID_3D_BUTTON);
+ AddChildView(threedee_);
+
reload_ = new views::Button();
reload_->SetImage(views::Button::BS_NORMAL, rb.GetBitmapNamed(IDR_RELOAD));
reload_->SetImage(views::Button::BS_HOT, rb.GetBitmapNamed(IDR_RELOAD_H));
@@ -264,11 +287,22 @@
forward_->SetBounds(back_->x() + back_->width(), kControlVertOffset,
sz.width(), sz.height());
- sz = reload_->GetPreferredSize();
- reload_->SetBounds(forward_->x() + forward_->width() +
- kControlHorizOffset,
- kControlVertOffset, sz.width(), sz.height());
+ if (threedee_) {
+ sz = threedee_->GetPreferredSize();
+ threedee_->SetBounds(forward_->x() + forward_->width() + kControlHorizOffset,
+ kControlVertOffset, reload_->GetPreferredSize().width(),
+ sz.height());
+ reload_->SetBounds(threedee_->x() + threedee_->width() + kControlHorizOffset,
+ kControlVertOffset, reload_->GetPreferredSize().width(),
+ sz.height());
+ } else {
+ sz = reload_->GetPreferredSize();
+ reload_->SetBounds(forward_->x() + forward_->width() +
+ kControlHorizOffset,
+ kControlVertOffset, sz.width(), sz.height());
+ }
+
int offset = 0;
if (show_home_button_.GetValue()) {
sz = home_->GetPreferredSize();
@@ -697,9 +731,27 @@
Layout();
SchedulePaint();
}
+ } else if (type == NOTIFY_THREEDEE_TOGGLED) {
+ // Redraw the window when the user changes this setting.
+ threedee_->SetToggled(g_threedee_enabled);
}
}
+void BrowserToolbarView::ButtonPressed(views::BaseButton* sender) {
+ if (sender->GetTag() == IDC_THREEDEE) {
+ g_threedee_enabled = !g_threedee_enabled;
+ // The toggle state of the button will get changed in our observer (to keep
+ // all toolbars in sync).
+
+ NotificationService::current()->Notify(
+ NOTIFY_THREEDEE_TOGGLED,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+
+ return;
+ }
+}
+
bool BrowserToolbarView::GetAcceleratorInfo(int id,
views::Accelerator* accel) {
// The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | chrome/common/notification_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698