OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <X11/XF86keysym.h> | 7 #include <X11/XF86keysym.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/trace_event.h" |
13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
18 #include "chrome/browser/net/url_fixer_upper.h" | 19 #include "chrome/browser/net/url_fixer_upper.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/themes/theme_service.h" | 22 #include "chrome/browser/themes/theme_service.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 gtk_util::BORDER_NONE); | 454 gtk_util::BORDER_NONE); |
454 } else { | 455 } else { |
455 gtk_util::StopActingAsRoundedWindow(alignment_); | 456 gtk_util::StopActingAsRoundedWindow(alignment_); |
456 } | 457 } |
457 | 458 |
458 return true; | 459 return true; |
459 } | 460 } |
460 | 461 |
461 gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, | 462 gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, |
462 GdkEventExpose* e) { | 463 GdkEventExpose* e) { |
| 464 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnAlignmentExpose"); |
| 465 |
463 // We may need to update the roundedness of the toolbar's top corners. In | 466 // We may need to update the roundedness of the toolbar's top corners. In |
464 // this case, don't draw; we'll be called again soon enough. | 467 // this case, don't draw; we'll be called again soon enough. |
465 if (UpdateRoundedness()) | 468 if (UpdateRoundedness()) |
466 return TRUE; | 469 return TRUE; |
467 | 470 |
468 // We don't need to render the toolbar image in GTK mode. | 471 // We don't need to render the toolbar image in GTK mode. |
469 if (theme_service_->UsingNativeTheme()) | 472 if (theme_service_->UsingNativeTheme()) |
470 return FALSE; | 473 return FALSE; |
471 | 474 |
472 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 475 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 cairo_surface_destroy(target); | 565 cairo_surface_destroy(target); |
563 } | 566 } |
564 | 567 |
565 cairo_destroy(cr); | 568 cairo_destroy(cr); |
566 | 569 |
567 return FALSE; // Allow subwidgets to paint. | 570 return FALSE; // Allow subwidgets to paint. |
568 } | 571 } |
569 | 572 |
570 gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, | 573 gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, |
571 GdkEventExpose* e) { | 574 GdkEventExpose* e) { |
| 575 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnLocationHboxExpose"); |
572 if (theme_service_->UsingNativeTheme()) { | 576 if (theme_service_->UsingNativeTheme()) { |
573 GtkAllocation allocation; | 577 GtkAllocation allocation; |
574 gtk_widget_get_allocation(location_hbox, &allocation); | 578 gtk_widget_get_allocation(location_hbox, &allocation); |
575 gtk_util::DrawTextEntryBackground(offscreen_entry_.get(), | 579 gtk_util::DrawTextEntryBackground(offscreen_entry_.get(), |
576 location_hbox, &e->area, | 580 location_hbox, &e->area, |
577 &allocation); | 581 &allocation); |
578 } | 582 } |
579 | 583 |
580 return FALSE; | 584 return FALSE; |
581 } | 585 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 648 } |
645 | 649 |
646 void BrowserToolbarGtk::RebuildWrenchMenu() { | 650 void BrowserToolbarGtk::RebuildWrenchMenu() { |
647 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); | 651 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); |
648 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); | 652 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); |
649 is_wrench_menu_model_valid_ = true; | 653 is_wrench_menu_model_valid_ = true; |
650 } | 654 } |
651 | 655 |
652 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, | 656 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, |
653 GdkEventExpose* expose) { | 657 GdkEventExpose* expose) { |
| 658 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnWrenchMenuButtonExpose"); |
654 int resource_id = 0; | 659 int resource_id = 0; |
655 if (UpgradeDetector::GetInstance()->notify_upgrade()) { | 660 if (UpgradeDetector::GetInstance()->notify_upgrade()) { |
656 resource_id = UpgradeDetector::GetInstance()->GetIconResourceID( | 661 resource_id = UpgradeDetector::GetInstance()->GetIconResourceID( |
657 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE); | 662 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE); |
658 } else { | 663 } else { |
659 resource_id = GlobalErrorServiceFactory::GetForProfile( | 664 resource_id = GlobalErrorServiceFactory::GetForProfile( |
660 browser_->profile())->GetFirstBadgeResourceID(); | 665 browser_->profile())->GetFirstBadgeResourceID(); |
661 } | 666 } |
662 | 667 |
663 if (!resource_id) | 668 if (!resource_id) |
664 return FALSE; | 669 return FALSE; |
665 | 670 |
666 GtkAllocation allocation; | 671 GtkAllocation allocation; |
667 gtk_widget_get_allocation(sender, &allocation); | 672 gtk_widget_get_allocation(sender, &allocation); |
668 | 673 |
669 // Draw the chrome app menu icon onto the canvas. | 674 // Draw the chrome app menu icon onto the canvas. |
670 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); | 675 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); |
671 gfx::CanvasSkiaPaint canvas(expose, false); | 676 gfx::CanvasSkiaPaint canvas(expose, false); |
672 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); | 677 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); |
673 int y_offset = 0; | 678 int y_offset = 0; |
674 canvas.DrawBitmapInt(*badge, | 679 canvas.DrawBitmapInt(*badge, |
675 allocation.x + x_offset, | 680 allocation.x + x_offset, |
676 allocation.y + y_offset); | 681 allocation.y + y_offset); |
677 | 682 |
678 return FALSE; | 683 return FALSE; |
679 } | 684 } |
OLD | NEW |