Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: chrome/browser/views/location_bar_view.cc

Issue 1075006: Eliminate all UI thread decoding of extension images.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/location_bar_view.h" 5 #include "chrome/browser/views/location_bar_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1420
1421 LocationBarView::PageActionImageView::PageActionImageView( 1421 LocationBarView::PageActionImageView::PageActionImageView(
1422 LocationBarView* owner, 1422 LocationBarView* owner,
1423 Profile* profile, 1423 Profile* profile,
1424 ExtensionAction* page_action, 1424 ExtensionAction* page_action,
1425 const BubblePositioner* bubble_positioner) 1425 const BubblePositioner* bubble_positioner)
1426 : LocationBarImageView(bubble_positioner), 1426 : LocationBarImageView(bubble_positioner),
1427 owner_(owner), 1427 owner_(owner),
1428 profile_(profile), 1428 profile_(profile),
1429 page_action_(page_action), 1429 page_action_(page_action),
1430 tracker_(NULL), 1430 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
1431 current_tab_id_(-1), 1431 current_tab_id_(-1),
1432 preview_enabled_(false), 1432 preview_enabled_(false),
1433 popup_(NULL) { 1433 popup_(NULL) {
1434 Extension* extension = profile->GetExtensionsService()->GetExtensionById( 1434 Extension* extension = profile->GetExtensionsService()->GetExtensionById(
1435 page_action->extension_id(), false); 1435 page_action->extension_id(), false);
1436 DCHECK(extension); 1436 DCHECK(extension);
1437 1437
1438 // Load all the icons declared in the manifest. This is the contents of the 1438 // Load all the icons declared in the manifest. This is the contents of the
1439 // icons array, plus the default_icon property, if any. 1439 // icons array, plus the default_icon property, if any.
1440 std::vector<std::string> icon_paths(*page_action->icon_paths()); 1440 std::vector<std::string> icon_paths(*page_action->icon_paths());
1441 if (!page_action_->default_icon_path().empty()) 1441 if (!page_action_->default_icon_path().empty())
1442 icon_paths.push_back(page_action_->default_icon_path()); 1442 icon_paths.push_back(page_action_->default_icon_path());
1443 1443
1444 tracker_ = new ImageLoadingTracker(this, icon_paths.size()); 1444 int i = 0;
1445 for (std::vector<std::string>::iterator iter = icon_paths.begin(); 1445 for (std::vector<std::string>::iterator iter = icon_paths.begin();
1446 iter != icon_paths.end(); ++iter) { 1446 iter != icon_paths.end(); ++iter) {
1447 tracker_->PostLoadImageTask( 1447 tracker_.PostLoadImageTask(
1448 extension->GetResource(*iter), 1448 extension->GetResource(*iter),
1449 gfx::Size(Extension::kPageActionIconMaxSize, 1449 gfx::Size(Extension::kPageActionIconMaxSize,
1450 Extension::kPageActionIconMaxSize)); 1450 Extension::kPageActionIconMaxSize), i++);
1451 } 1451 }
1452 } 1452 }
1453 1453
1454 LocationBarView::PageActionImageView::~PageActionImageView() { 1454 LocationBarView::PageActionImageView::~PageActionImageView() {
1455 if (tracker_)
1456 tracker_->StopTrackingImageLoad();
1457
1458 if (popup_) 1455 if (popup_)
1459 HidePopup(); 1456 HidePopup();
1460 } 1457 }
1461 1458
1462 void LocationBarView::PageActionImageView::ExecuteAction(int button, 1459 void LocationBarView::PageActionImageView::ExecuteAction(int button,
1463 bool inspect_with_devtools) { 1460 bool inspect_with_devtools) {
1464 if (current_tab_id_ < 0) { 1461 if (current_tab_id_ < 0) {
1465 NOTREACHED() << "No current tab."; 1462 NOTREACHED() << "No current tab.";
1466 return; 1463 return;
1467 } 1464 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 return; 1551 return;
1555 } 1552 }
1556 1553
1557 ExecuteAction(button, false); // inspect_with_devtools 1554 ExecuteAction(button, false); // inspect_with_devtools
1558 } 1555 }
1559 1556
1560 void LocationBarView::PageActionImageView::ShowInfoBubble() { 1557 void LocationBarView::PageActionImageView::ShowInfoBubble() {
1561 ShowInfoBubbleImpl(ASCIIToWide(tooltip_), GetColor(false, TEXT)); 1558 ShowInfoBubbleImpl(ASCIIToWide(tooltip_), GetColor(false, TEXT));
1562 } 1559 }
1563 1560
1564 void LocationBarView::PageActionImageView::OnImageLoaded(SkBitmap* image, 1561 void LocationBarView::PageActionImageView::OnImageLoaded(
1565 size_t index) { 1562 SkBitmap* image, int index) {
1566 // We loaded icons()->size() icons, plus one extra if the page action had 1563 // We loaded icons()->size() icons, plus one extra if the page action had
1567 // a default icon. 1564 // a default icon.
1568 size_t total_icons = page_action_->icon_paths()->size(); 1565 int total_icons = static_cast<int>(page_action_->icon_paths()->size());
1569 if (!page_action_->default_icon_path().empty()) 1566 if (!page_action_->default_icon_path().empty())
1570 total_icons++; 1567 total_icons++;
1571 DCHECK(index < total_icons); 1568 DCHECK(index < total_icons);
1572 1569
1573 // Map the index of the loaded image back to its name. If we ever get an 1570 // Map the index of the loaded image back to its name. If we ever get an
1574 // index greater than the number of icons, it must be the default icon. 1571 // index greater than the number of icons, it must be the default icon.
1575 if (image) { 1572 if (image) {
1576 if (index < page_action_->icon_paths()->size()) 1573 if (index < total_icons)
1577 page_action_icons_[page_action_->icon_paths()->at(index)] = *image; 1574 page_action_icons_[page_action_->icon_paths()->at(index)] = *image;
1578 else 1575 else
1579 page_action_icons_[page_action_->default_icon_path()] = *image; 1576 page_action_icons_[page_action_->default_icon_path()] = *image;
1580 } 1577 }
1581 1578
1582 // If we are done, release the tracker.
1583 if (index == total_icons - 1)
1584 tracker_ = NULL;
1585
1586 owner_->UpdatePageActions(); 1579 owner_->UpdatePageActions();
1587 } 1580 }
1588 1581
1589 void LocationBarView::PageActionImageView::UpdateVisibility( 1582 void LocationBarView::PageActionImageView::UpdateVisibility(
1590 TabContents* contents, const GURL& url) { 1583 TabContents* contents, const GURL& url) {
1591 // Save this off so we can pass it back to the extension when the action gets 1584 // Save this off so we can pass it back to the extension when the action gets
1592 // executed. See PageActionImageView::OnMousePressed. 1585 // executed. See PageActionImageView::OnMousePressed.
1593 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); 1586 current_tab_id_ = ExtensionTabUtil::GetTabId(contents);
1594 current_url_ = url; 1587 current_url_ = url;
1595 1588
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, 1732 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton,
1740 false); // inspect_with_devtools 1733 false); // inspect_with_devtools
1741 return; 1734 return;
1742 } 1735 }
1743 ++current; 1736 ++current;
1744 } 1737 }
1745 } 1738 }
1746 1739
1747 NOTREACHED(); 1740 NOTREACHED();
1748 } 1741 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698