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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 gtk_util::BORDER_NONE); | 455 gtk_util::BORDER_NONE); |
455 } else { | 456 } else { |
456 gtk_util::StopActingAsRoundedWindow(alignment_); | 457 gtk_util::StopActingAsRoundedWindow(alignment_); |
457 } | 458 } |
458 | 459 |
459 return true; | 460 return true; |
460 } | 461 } |
461 | 462 |
462 gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, | 463 gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, |
463 GdkEventExpose* e) { | 464 GdkEventExpose* e) { |
| 465 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnAlignmentExpose"); |
| 466 |
464 // We may need to update the roundedness of the toolbar's top corners. In | 467 // We may need to update the roundedness of the toolbar's top corners. In |
465 // this case, don't draw; we'll be called again soon enough. | 468 // this case, don't draw; we'll be called again soon enough. |
466 if (UpdateRoundedness()) | 469 if (UpdateRoundedness()) |
467 return TRUE; | 470 return TRUE; |
468 | 471 |
469 // We don't need to render the toolbar image in GTK mode. | 472 // We don't need to render the toolbar image in GTK mode. |
470 if (theme_service_->UsingNativeTheme()) | 473 if (theme_service_->UsingNativeTheme()) |
471 return FALSE; | 474 return FALSE; |
472 | 475 |
473 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 476 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 cairo_surface_destroy(target); | 567 cairo_surface_destroy(target); |
565 } | 568 } |
566 | 569 |
567 cairo_destroy(cr); | 570 cairo_destroy(cr); |
568 | 571 |
569 return FALSE; // Allow subwidgets to paint. | 572 return FALSE; // Allow subwidgets to paint. |
570 } | 573 } |
571 | 574 |
572 gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, | 575 gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, |
573 GdkEventExpose* e) { | 576 GdkEventExpose* e) { |
| 577 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnLocationHboxExpose"); |
574 if (theme_service_->UsingNativeTheme()) { | 578 if (theme_service_->UsingNativeTheme()) { |
575 GtkAllocation allocation; | 579 GtkAllocation allocation; |
576 gtk_widget_get_allocation(location_hbox, &allocation); | 580 gtk_widget_get_allocation(location_hbox, &allocation); |
577 gtk_util::DrawTextEntryBackground(offscreen_entry_.get(), | 581 gtk_util::DrawTextEntryBackground(offscreen_entry_.get(), |
578 location_hbox, &e->area, | 582 location_hbox, &e->area, |
579 &allocation); | 583 &allocation); |
580 } | 584 } |
581 | 585 |
582 return FALSE; | 586 return FALSE; |
583 } | 587 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 650 } |
647 | 651 |
648 void BrowserToolbarGtk::RebuildWrenchMenu() { | 652 void BrowserToolbarGtk::RebuildWrenchMenu() { |
649 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); | 653 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); |
650 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); | 654 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.get())); |
651 is_wrench_menu_model_valid_ = true; | 655 is_wrench_menu_model_valid_ = true; |
652 } | 656 } |
653 | 657 |
654 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, | 658 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, |
655 GdkEventExpose* expose) { | 659 GdkEventExpose* expose) { |
| 660 TRACE_EVENT0("ui::gtk", "BrowserToolbarGtk::OnWrenchMenuButtonExpose"); |
656 int resource_id = 0; | 661 int resource_id = 0; |
657 if (UpgradeDetector::GetInstance()->notify_upgrade()) { | 662 if (UpgradeDetector::GetInstance()->notify_upgrade()) { |
658 resource_id = UpgradeDetector::GetInstance()->GetIconResourceID( | 663 resource_id = UpgradeDetector::GetInstance()->GetIconResourceID( |
659 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE); | 664 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE); |
660 } else { | 665 } else { |
661 resource_id = GlobalErrorServiceFactory::GetForProfile( | 666 resource_id = GlobalErrorServiceFactory::GetForProfile( |
662 browser_->profile())->GetFirstBadgeResourceID(); | 667 browser_->profile())->GetFirstBadgeResourceID(); |
663 } | 668 } |
664 | 669 |
665 if (!resource_id) | 670 if (!resource_id) |
666 return FALSE; | 671 return FALSE; |
667 | 672 |
668 GtkAllocation allocation; | 673 GtkAllocation allocation; |
669 gtk_widget_get_allocation(sender, &allocation); | 674 gtk_widget_get_allocation(sender, &allocation); |
670 | 675 |
671 // Draw the chrome app menu icon onto the canvas. | 676 // Draw the chrome app menu icon onto the canvas. |
672 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); | 677 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); |
673 gfx::CanvasSkiaPaint canvas(expose, false); | 678 gfx::CanvasSkiaPaint canvas(expose, false); |
674 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); | 679 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); |
675 int y_offset = 0; | 680 int y_offset = 0; |
676 canvas.DrawBitmapInt(*badge, | 681 canvas.DrawBitmapInt(*badge, |
677 allocation.x + x_offset, | 682 allocation.x + x_offset, |
678 allocation.y + y_offset); | 683 allocation.y + y_offset); |
679 | 684 |
680 return FALSE; | 685 return FALSE; |
681 } | 686 } |
OLD | NEW |