| 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 for (ScopedVector<ContentSettingImageViewGtk>::iterator i( | 628 for (ScopedVector<ContentSettingImageViewGtk>::iterator i( |
| 629 content_setting_views_.begin()); | 629 content_setting_views_.begin()); |
| 630 i != content_setting_views_.end(); ++i) { | 630 i != content_setting_views_.end(); ++i) { |
| 631 (*i)->UpdateFromTabContents( | 631 (*i)->UpdateFromTabContents( |
| 632 toolbar_model_->input_in_progress() ? NULL : tab_contents); | 632 toolbar_model_->input_in_progress() ? NULL : tab_contents); |
| 633 any_visible = (*i)->IsVisible() || any_visible; | 633 any_visible = (*i)->IsVisible() || any_visible; |
| 634 } | 634 } |
| 635 | 635 |
| 636 // If there are no visible content things, hide the top level box so it | 636 // If there are no visible content things, hide the top level box so it |
| 637 // doesn't mess with padding. | 637 // doesn't mess with padding. |
| 638 if (any_visible) | 638 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
| 639 gtk_widget_show(content_setting_hbox_.get()); | |
| 640 else | |
| 641 gtk_widget_hide(content_setting_hbox_.get()); | |
| 642 } | 639 } |
| 643 | 640 |
| 644 void LocationBarViewGtk::UpdatePageActions() { | 641 void LocationBarViewGtk::UpdatePageActions() { |
| 645 std::vector<ExtensionAction*> page_actions; | 642 std::vector<ExtensionAction*> page_actions; |
| 646 ExtensionService* service = profile_->GetExtensionService(); | 643 ExtensionService* service = profile_->GetExtensionService(); |
| 647 if (!service) | 644 if (!service) |
| 648 return; | 645 return; |
| 649 | 646 |
| 650 // Find all the page actions. | 647 // Find all the page actions. |
| 651 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 648 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 675 GURL url = GURL(WideToUTF8(toolbar_model_->GetText())); | 672 GURL url = GURL(WideToUTF8(toolbar_model_->GetText())); |
| 676 | 673 |
| 677 for (size_t i = 0; i < page_action_views_.size(); i++) { | 674 for (size_t i = 0; i < page_action_views_.size(); i++) { |
| 678 page_action_views_[i]->UpdateVisibility( | 675 page_action_views_[i]->UpdateVisibility( |
| 679 toolbar_model_->input_in_progress() ? NULL : contents, url); | 676 toolbar_model_->input_in_progress() ? NULL : contents, url); |
| 680 } | 677 } |
| 681 } | 678 } |
| 682 | 679 |
| 683 // If there are no visible page actions, hide the hbox too, so that it does | 680 // If there are no visible page actions, hide the hbox too, so that it does |
| 684 // not affect the padding in the location bar. | 681 // not affect the padding in the location bar. |
| 685 if (PageActionVisibleCount() && !ShouldOnlyShowLocation()) | 682 gtk_widget_set_visible(page_action_hbox_.get(), |
| 686 gtk_widget_show(page_action_hbox_.get()); | 683 PageActionVisibleCount() && !ShouldOnlyShowLocation()); |
| 687 else | |
| 688 gtk_widget_hide(page_action_hbox_.get()); | |
| 689 } | 684 } |
| 690 | 685 |
| 691 void LocationBarViewGtk::InvalidatePageActions() { | 686 void LocationBarViewGtk::InvalidatePageActions() { |
| 692 size_t count_before = page_action_views_.size(); | 687 size_t count_before = page_action_views_.size(); |
| 693 page_action_views_.reset(); | 688 page_action_views_.reset(); |
| 694 if (page_action_views_.size() != count_before) { | 689 if (page_action_views_.size() != count_before) { |
| 695 NotificationService::current()->Notify( | 690 NotificationService::current()->Notify( |
| 696 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 691 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 697 Source<LocationBar>(this), | 692 Source<LocationBar>(this), |
| 698 NotificationService::NoDetails()); | 693 NotificationService::NoDetails()); |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 | 1620 |
| 1626 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1621 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1627 if (badge_text.empty()) | 1622 if (badge_text.empty()) |
| 1628 return FALSE; | 1623 return FALSE; |
| 1629 | 1624 |
| 1630 gfx::CanvasSkiaPaint canvas(event, false); | 1625 gfx::CanvasSkiaPaint canvas(event, false); |
| 1631 gfx::Rect bounding_rect(widget->allocation); | 1626 gfx::Rect bounding_rect(widget->allocation); |
| 1632 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1627 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1633 return FALSE; | 1628 return FALSE; |
| 1634 } | 1629 } |
| OLD | NEW |