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/views/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 CreateBrowserActionViews(); | 551 CreateBrowserActionViews(); |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 // static | 555 // static |
556 int BrowserActionsContainer::IconWidth(bool include_padding) { | 556 int BrowserActionsContainer::IconWidth(bool include_padding) { |
557 static bool initialized = false; | 557 static bool initialized = false; |
558 static int icon_width = 0; | 558 static int icon_width = 0; |
559 if (!initialized) { | 559 if (!initialized) { |
560 initialized = true; | 560 initialized = true; |
561 icon_width = ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( | 561 icon_width = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
562 IDR_BROWSER_ACTION)->width(); | 562 IDR_BROWSER_ACTION)->width(); |
563 } | 563 } |
564 return icon_width + (include_padding ? kItemSpacing : 0); | 564 return icon_width + (include_padding ? kItemSpacing : 0); |
565 } | 565 } |
566 | 566 |
567 // static | 567 // static |
568 int BrowserActionsContainer::IconHeight() { | 568 int BrowserActionsContainer::IconHeight() { |
569 static bool initialized = false; | 569 static bool initialized = false; |
570 static int icon_height = 0; | 570 static int icon_height = 0; |
571 if (!initialized) { | 571 if (!initialized) { |
572 initialized = true; | 572 initialized = true; |
573 icon_height = ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( | 573 icon_height = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
574 IDR_BROWSER_ACTION)->height(); | 574 IDR_BROWSER_ACTION)->height(); |
575 } | 575 } |
576 return icon_height; | 576 return icon_height; |
577 } | 577 } |
578 | 578 |
579 void BrowserActionsContainer::BrowserActionAdded(const Extension* extension, | 579 void BrowserActionsContainer::BrowserActionAdded(const Extension* extension, |
580 int index) { | 580 int index) { |
581 #if defined(DEBUG) | 581 #if defined(DEBUG) |
582 for (size_t i = 0; i < browser_action_views_.size(); ++i) { | 582 for (size_t i = 0; i < browser_action_views_.size(); ++i) { |
583 DCHECK(browser_action_views_[i]->button()->extension() != extension) << | 583 DCHECK(browser_action_views_[i]->button()->extension() != extension) << |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 Layout(); | 666 Layout(); |
667 SchedulePaint(); | 667 SchedulePaint(); |
668 } | 668 } |
669 | 669 |
670 void BrowserActionsContainer::ModelLoaded() { | 670 void BrowserActionsContainer::ModelLoaded() { |
671 SetContainerWidth(); | 671 SetContainerWidth(); |
672 } | 672 } |
673 | 673 |
674 void BrowserActionsContainer::LoadImages() { | 674 void BrowserActionsContainer::LoadImages() { |
675 ui::ThemeProvider* tp = GetThemeProvider(); | 675 ui::ThemeProvider* tp = GetThemeProvider(); |
676 chevron_->SetIcon(*tp->GetBitmapNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); | 676 chevron_->SetIcon(*tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); |
677 chevron_->SetHoverIcon(*tp->GetBitmapNamed(IDR_BROWSER_ACTIONS_OVERFLOW_H)); | 677 chevron_->SetHoverIcon(*tp->GetImageSkiaNamed( |
678 chevron_->SetPushedIcon(*tp->GetBitmapNamed(IDR_BROWSER_ACTIONS_OVERFLOW_P)); | 678 IDR_BROWSER_ACTIONS_OVERFLOW_H)); |
| 679 chevron_->SetPushedIcon(*tp->GetImageSkiaNamed( |
| 680 IDR_BROWSER_ACTIONS_OVERFLOW_P)); |
679 } | 681 } |
680 | 682 |
681 void BrowserActionsContainer::SetContainerWidth() { | 683 void BrowserActionsContainer::SetContainerWidth() { |
682 int visible_actions = model_->GetVisibleIconCount(); | 684 int visible_actions = model_->GetVisibleIconCount(); |
683 if (visible_actions < 0) // All icons should be visible. | 685 if (visible_actions < 0) // All icons should be visible. |
684 visible_actions = model_->toolbar_items().size(); | 686 visible_actions = model_->toolbar_items().size(); |
685 chevron_->SetVisible( | 687 chevron_->SetVisible( |
686 static_cast<size_t>(visible_actions) < model_->toolbar_items().size()); | 688 static_cast<size_t>(visible_actions) < model_->toolbar_items().size()); |
687 container_width_ = IconCountToWidth(visible_actions, chevron_->visible()); | 689 container_width_ = IconCountToWidth(visible_actions, chevron_->visible()); |
688 } | 690 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? | 811 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? |
810 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 812 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; |
811 popup_ = ExtensionPopup::ShowPopup(popup_url, | 813 popup_ = ExtensionPopup::ShowPopup(popup_url, |
812 browser_, | 814 browser_, |
813 reference_view, | 815 reference_view, |
814 arrow_location); | 816 arrow_location); |
815 popup_->GetWidget()->AddObserver(this); | 817 popup_->GetWidget()->AddObserver(this); |
816 popup_button_ = button; | 818 popup_button_ = button; |
817 popup_button_->SetButtonPushed(); | 819 popup_button_->SetButtonPushed(); |
818 } | 820 } |
OLD | NEW |