Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
| 10 | 10 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 UpdateRoundedness(); | 405 UpdateRoundedness(); |
| 406 } else if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { | 406 } else if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { |
| 407 // Redraw the wrench menu to update the badge. | 407 // Redraw the wrench menu to update the badge. |
| 408 gtk_widget_queue_draw(wrench_menu_button_->widget()); | 408 gtk_widget_queue_draw(wrench_menu_button_->widget()); |
| 409 } else if (type == chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED) { | 409 } else if (type == chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED) { |
| 410 is_wrench_menu_model_valid_ = false; | 410 is_wrench_menu_model_valid_ = false; |
| 411 gtk_widget_queue_draw(wrench_menu_button_->widget()); | 411 gtk_widget_queue_draw(wrench_menu_button_->widget()); |
| 412 } else if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { | 412 } else if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { |
| 413 // If our zoom level changed, we need to tell the menu to update its state, | 413 // If our zoom level changed, we need to tell the menu to update its state, |
| 414 // since the menu could still be open. | 414 // since the menu could still be open. |
| 415 wrench_menu_->UpdateMenu(); | 415 wrench_menu_->UpdateMenu(); |
|
Lei Zhang
2012/08/28 20:57:22
The alternative to depending on the ordering is to
| |
| 416 } else { | 416 } else { |
| 417 NOTREACHED(); | 417 NOTREACHED(); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 // BrowserToolbarGtk, public --------------------------------------------------- | 421 // BrowserToolbarGtk, public --------------------------------------------------- |
| 422 | 422 |
| 423 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents, | 423 void BrowserToolbarGtk::UpdateWebContents(WebContents* contents, |
| 424 bool should_restore_state) { | 424 bool should_restore_state) { |
| 425 location_bar_->Update(should_restore_state ? contents : NULL); | 425 location_bar_->Update(should_restore_state ? contents : NULL); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 SetUpDragForHomeButton(!home_page_.IsManaged() && | 654 SetUpDragForHomeButton(!home_page_.IsManaged() && |
| 655 !home_page_is_new_tab_page_.IsManaged()); | 655 !home_page_is_new_tab_page_.IsManaged()); |
| 656 } | 656 } |
| 657 | 657 |
| 658 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { | 658 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { |
| 659 // If we're a popup window, only show the location bar (omnibox). | 659 // If we're a popup window, only show the location bar (omnibox). |
| 660 return !browser_->is_type_tabbed(); | 660 return !browser_->is_type_tabbed(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 void BrowserToolbarGtk::RebuildWrenchMenu() { | 663 void BrowserToolbarGtk::RebuildWrenchMenu() { |
| 664 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); | 664 wrench_menu_model_->Rebuild(); |
| 665 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); | 665 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); |
| 666 // The bookmark menu model needs to be able to force the wrench menu to close. | 666 // The bookmark menu model needs to be able to force the wrench menu to close. |
| 667 wrench_menu_model_->bookmark_sub_menu_model()->SetMenuGtk(wrench_menu_.get()); | 667 wrench_menu_model_->bookmark_sub_menu_model()->SetMenuGtk(wrench_menu_.get()); |
| 668 is_wrench_menu_model_valid_ = true; | 668 is_wrench_menu_model_valid_ = true; |
| 669 } | 669 } |
| 670 | 670 |
| 671 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, | 671 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, |
| 672 GdkEventExpose* expose) { | 672 GdkEventExpose* expose) { |
| 673 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnWrenchMenuButtonExpose"); | 673 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnWrenchMenuButtonExpose"); |
| 674 int resource_id = 0; | 674 int resource_id = 0; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 690 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); | 690 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); |
| 691 gfx::CanvasSkiaPaint canvas(expose, false); | 691 gfx::CanvasSkiaPaint canvas(expose, false); |
| 692 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); | 692 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); |
| 693 int y_offset = 0; | 693 int y_offset = 0; |
| 694 canvas.DrawImageInt(*badge, | 694 canvas.DrawImageInt(*badge, |
| 695 allocation.x + x_offset, | 695 allocation.x + x_offset, |
| 696 allocation.y + y_offset); | 696 allocation.y + y_offset); |
| 697 | 697 |
| 698 return FALSE; | 698 return FALSE; |
| 699 } | 699 } |
| OLD | NEW |