| 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/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/net/url_fixer_upper.h" | 18 #include "chrome/browser/net/url_fixer_upper.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/themes/theme_service.h" | 21 #include "chrome/browser/themes/theme_service.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/global_error_delegate.h" |
| 24 #include "chrome/browser/ui/global_error_service.h" |
| 25 #include "chrome/browser/ui/global_error_service_factory.h" |
| 23 #include "chrome/browser/ui/gtk/accelerators_gtk.h" | 26 #include "chrome/browser/ui/gtk/accelerators_gtk.h" |
| 24 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" | 27 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" |
| 25 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" | 28 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
| 26 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 29 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 27 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" | 30 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" |
| 28 #include "chrome/browser/ui/gtk/custom_button.h" | 31 #include "chrome/browser/ui/gtk/custom_button.h" |
| 29 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 32 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 30 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 33 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 31 #include "chrome/browser/ui/gtk/gtk_util.h" | 34 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 32 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 35 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 !home_page_is_new_tab_page_.IsManaged()); | 615 !home_page_is_new_tab_page_.IsManaged()); |
| 613 } | 616 } |
| 614 | 617 |
| 615 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { | 618 bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { |
| 616 // If we're a popup window, only show the location bar (omnibox). | 619 // If we're a popup window, only show the location bar (omnibox). |
| 617 return !browser_->is_type_tabbed(); | 620 return !browser_->is_type_tabbed(); |
| 618 } | 621 } |
| 619 | 622 |
| 620 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, | 623 gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, |
| 621 GdkEventExpose* expose) { | 624 GdkEventExpose* expose) { |
| 622 const SkBitmap* badge = NULL; | 625 int resource_id = 0; |
| 623 if (UpgradeDetector::GetInstance()->notify_upgrade()) { | 626 if (UpgradeDetector::GetInstance()->notify_upgrade()) { |
| 624 badge = theme_service_->GetBitmapNamed( | 627 resource_id = UpgradeDetector::GetInstance()->GetIconResourceID( |
| 625 UpgradeDetector::GetInstance()->GetIconResourceID( | 628 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE); |
| 626 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE)); | |
| 627 } else { | 629 } else { |
| 628 return FALSE; | 630 const std::vector<GlobalErrorDelegate*>& errors = |
| 631 GlobalErrorServiceFactory::GetForProfile( |
| 632 browser_->profile())->GetErrorDelegates(); |
| 633 for (std::vector<GlobalErrorDelegate*>::const_iterator |
| 634 it = errors.begin(); it != errors.end(); ++it) { |
| 635 GlobalErrorDelegate* error = *it; |
| 636 if (error->HasBadge()) { |
| 637 resource_id = error->GetBadgeResourceID(); |
| 638 break; |
| 639 } |
| 640 } |
| 629 } | 641 } |
| 630 | 642 |
| 643 if (!resource_id) |
| 644 return FALSE; |
| 645 |
| 631 // Draw the chrome app menu icon onto the canvas. | 646 // Draw the chrome app menu icon onto the canvas. |
| 647 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); |
| 632 gfx::CanvasSkiaPaint canvas(expose, false); | 648 gfx::CanvasSkiaPaint canvas(expose, false); |
| 633 int x_offset = base::i18n::IsRTL() ? 0 : | 649 int x_offset = base::i18n::IsRTL() ? 0 : |
| 634 sender->allocation.width - badge->width(); | 650 sender->allocation.width - badge->width(); |
| 635 int y_offset = 0; | 651 int y_offset = 0; |
| 636 canvas.DrawBitmapInt( | 652 canvas.DrawBitmapInt( |
| 637 *badge, | 653 *badge, |
| 638 sender->allocation.x + x_offset, | 654 sender->allocation.x + x_offset, |
| 639 sender->allocation.y + y_offset); | 655 sender->allocation.y + y_offset); |
| 640 | 656 |
| 641 return FALSE; | 657 return FALSE; |
| 642 } | 658 } |
| OLD | NEW |