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/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 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 | 1549 |
1550 if (visible != old_visible) { | 1550 if (visible != old_visible) { |
1551 content::NotificationService::current()->Notify( | 1551 content::NotificationService::current()->Notify( |
1552 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 1552 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
1553 content::Source<ExtensionAction>(page_action_), | 1553 content::Source<ExtensionAction>(page_action_), |
1554 content::Details<WebContents>(contents)); | 1554 content::Details<WebContents>(contents)); |
1555 } | 1555 } |
1556 } | 1556 } |
1557 | 1557 |
1558 void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded( | 1558 void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded( |
1559 SkBitmap* image, const ExtensionResource& resource, int index) { | 1559 const gfx::Image& image, |
| 1560 const std::string& extension_id, |
| 1561 int index) { |
1560 // We loaded icons()->size() icons, plus one extra if the page action had | 1562 // We loaded icons()->size() icons, plus one extra if the page action had |
1561 // a default icon. | 1563 // a default icon. |
1562 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); | 1564 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); |
1563 if (!page_action_->default_icon_path().empty()) | 1565 if (!page_action_->default_icon_path().empty()) |
1564 total_icons++; | 1566 total_icons++; |
1565 DCHECK(index < total_icons); | 1567 DCHECK(index < total_icons); |
1566 | 1568 |
1567 // Map the index of the loaded image back to its name. If we ever get an | 1569 // Map the index of the loaded image back to its name. If we ever get an |
1568 // index greater than the number of icons, it must be the default icon. | 1570 // index greater than the number of icons, it must be the default icon. |
1569 if (image) { | 1571 if (!image.IsEmpty()) { |
1570 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(image); | 1572 GdkPixbuf* pixbuf = |
| 1573 static_cast<GdkPixbuf*>(g_object_ref(image.ToGdkPixbuf())); |
1571 if (index < static_cast<int>(page_action_->icon_paths()->size())) | 1574 if (index < static_cast<int>(page_action_->icon_paths()->size())) |
1572 pixbufs_[page_action_->icon_paths()->at(index)] = pixbuf; | 1575 pixbufs_[page_action_->icon_paths()->at(index)] = pixbuf; |
1573 else | 1576 else |
1574 pixbufs_[page_action_->default_icon_path()] = pixbuf; | 1577 pixbufs_[page_action_->default_icon_path()] = pixbuf; |
1575 } | 1578 } |
1576 | 1579 |
1577 // If we have no owner, that means this class is still being constructed and | 1580 // If we have no owner, that means this class is still being constructed and |
1578 // we should not UpdatePageActions, since it leads to the PageActions being | 1581 // we should not UpdatePageActions, since it leads to the PageActions being |
1579 // destroyed again and new ones recreated (causing an infinite loop). | 1582 // destroyed again and new ones recreated (causing an infinite loop). |
1580 if (owner_) | 1583 if (owner_) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1649 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1647 if (badge_text.empty()) | 1650 if (badge_text.empty()) |
1648 return FALSE; | 1651 return FALSE; |
1649 | 1652 |
1650 gfx::CanvasSkiaPaint canvas(event, false); | 1653 gfx::CanvasSkiaPaint canvas(event, false); |
1651 GtkAllocation allocation; | 1654 GtkAllocation allocation; |
1652 gtk_widget_get_allocation(widget, &allocation); | 1655 gtk_widget_get_allocation(widget, &allocation); |
1653 page_action_->PaintBadge(&canvas, gfx::Rect(allocation), tab_id); | 1656 page_action_->PaintBadge(&canvas, gfx::Rect(allocation), tab_id); |
1654 return FALSE; | 1657 return FALSE; |
1655 } | 1658 } |
OLD | NEW |