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/views/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 void BrowserActionsContainer::OnDragEntered( | 627 void BrowserActionsContainer::OnDragEntered( |
628 const views::DropTargetEvent& event) { | 628 const views::DropTargetEvent& event) { |
629 } | 629 } |
630 | 630 |
631 int BrowserActionsContainer::OnDragUpdated( | 631 int BrowserActionsContainer::OnDragUpdated( |
632 const views::DropTargetEvent& event) { | 632 const views::DropTargetEvent& event) { |
633 // First check if we are above the chevron (overflow) menu. | 633 // First check if we are above the chevron (overflow) menu. |
634 if (GetViewForPoint(event.location()) == chevron_) { | 634 if (GetViewForPoint(event.location()) == chevron_) { |
635 if (show_menu_task_factory_.empty() && !overflow_menu_) | 635 if (show_menu_task_factory_.empty() && !overflow_menu_) |
636 StartShowFolderDropMenuTimer(); | 636 StartShowFolderDropMenuTimer(); |
637 return DragDropTypes::DRAG_MOVE; | 637 return ui::DragDropTypes::DRAG_MOVE; |
638 } | 638 } |
639 StopShowFolderDropMenuTimer(); | 639 StopShowFolderDropMenuTimer(); |
640 | 640 |
641 // Figure out where to display the indicator. This is a complex calculation: | 641 // Figure out where to display the indicator. This is a complex calculation: |
642 | 642 |
643 // First, we figure out how much space is to the left of the icon area, so we | 643 // First, we figure out how much space is to the left of the icon area, so we |
644 // can calculate the true offset into the icon area. | 644 // can calculate the true offset into the icon area. |
645 int width_before_icons = ToolbarView::kStandardSpacing + | 645 int width_before_icons = ToolbarView::kStandardSpacing + |
646 (base::i18n::IsRTL() ? | 646 (base::i18n::IsRTL() ? |
647 (chevron_->GetPreferredSize().width() + kChevronSpacing) : 0); | 647 (chevron_->GetPreferredSize().width() + kChevronSpacing) : 0); |
(...skipping 29 matching lines...) Expand all Loading... |
677 // icon as being "before the (last + 1) icon". | 677 // icon as being "before the (last + 1) icon". |
678 int before_icon = std::min(std::max(before_icon_unclamped, 0), | 678 int before_icon = std::min(std::max(before_icon_unclamped, 0), |
679 static_cast<int>(VisibleBrowserActions())); | 679 static_cast<int>(VisibleBrowserActions())); |
680 | 680 |
681 // Now we convert back to a pixel offset into the container. We want to place | 681 // Now we convert back to a pixel offset into the container. We want to place |
682 // the center of the drop indicator at the midpoint of the space before our | 682 // the center of the drop indicator at the midpoint of the space before our |
683 // chosen icon. | 683 // chosen icon. |
684 SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) - | 684 SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) - |
685 (kItemSpacing / 2)); | 685 (kItemSpacing / 2)); |
686 | 686 |
687 return DragDropTypes::DRAG_MOVE; | 687 return ui::DragDropTypes::DRAG_MOVE; |
688 } | 688 } |
689 | 689 |
690 void BrowserActionsContainer::OnDragExited() { | 690 void BrowserActionsContainer::OnDragExited() { |
691 StopShowFolderDropMenuTimer(); | 691 StopShowFolderDropMenuTimer(); |
692 drop_indicator_position_ = -1; | 692 drop_indicator_position_ = -1; |
693 SchedulePaint(); | 693 SchedulePaint(); |
694 } | 694 } |
695 | 695 |
696 int BrowserActionsContainer::OnPerformDrop( | 696 int BrowserActionsContainer::OnPerformDrop( |
697 const views::DropTargetEvent& event) { | 697 const views::DropTargetEvent& event) { |
698 BrowserActionDragData data; | 698 BrowserActionDragData data; |
699 if (!data.Read(event.GetData())) | 699 if (!data.Read(event.GetData())) |
700 return DragDropTypes::DRAG_NONE; | 700 return ui::DragDropTypes::DRAG_NONE; |
701 | 701 |
702 // Make sure we have the same view as we started with. | 702 // Make sure we have the same view as we started with. |
703 DCHECK_EQ(browser_action_views_[data.index()]->button()->extension()->id(), | 703 DCHECK_EQ(browser_action_views_[data.index()]->button()->extension()->id(), |
704 data.id()); | 704 data.id()); |
705 DCHECK(model_); | 705 DCHECK(model_); |
706 | 706 |
707 size_t i = 0; | 707 size_t i = 0; |
708 for (; i < browser_action_views_.size(); ++i) { | 708 for (; i < browser_action_views_.size(); ++i) { |
709 int view_x = | 709 int view_x = |
710 browser_action_views_[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).x(); | 710 browser_action_views_[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).x(); |
(...skipping 14 matching lines...) Expand all Loading... |
725 if (i > data.index()) | 725 if (i > data.index()) |
726 --i; | 726 --i; |
727 | 727 |
728 if (profile_->IsOffTheRecord()) | 728 if (profile_->IsOffTheRecord()) |
729 i = model_->IncognitoIndexToOriginal(i); | 729 i = model_->IncognitoIndexToOriginal(i); |
730 | 730 |
731 model_->MoveBrowserAction( | 731 model_->MoveBrowserAction( |
732 browser_action_views_[data.index()]->button()->extension(), i); | 732 browser_action_views_[data.index()]->button()->extension(), i); |
733 | 733 |
734 OnDragExited(); // Perform clean up after dragging. | 734 OnDragExited(); // Perform clean up after dragging. |
735 return DragDropTypes::DRAG_MOVE; | 735 return ui::DragDropTypes::DRAG_MOVE; |
736 } | 736 } |
737 | 737 |
738 void BrowserActionsContainer::OnThemeChanged() { | 738 void BrowserActionsContainer::OnThemeChanged() { |
739 LoadImages(); | 739 LoadImages(); |
740 } | 740 } |
741 | 741 |
742 AccessibilityTypes::Role BrowserActionsContainer::GetAccessibleRole() { | 742 AccessibilityTypes::Role BrowserActionsContainer::GetAccessibleRole() { |
743 return AccessibilityTypes::ROLE_GROUPING; | 743 return AccessibilityTypes::ROLE_GROUPING; |
744 } | 744 } |
745 | 745 |
(...skipping 24 matching lines...) Expand all Loading... |
770 BrowserActionDragData drag_data( | 770 BrowserActionDragData drag_data( |
771 browser_action_views_[i]->button()->extension()->id(), i); | 771 browser_action_views_[i]->button()->extension()->id(), i); |
772 drag_data.Write(profile_, data); | 772 drag_data.Write(profile_, data); |
773 break; | 773 break; |
774 } | 774 } |
775 } | 775 } |
776 } | 776 } |
777 | 777 |
778 int BrowserActionsContainer::GetDragOperations(View* sender, | 778 int BrowserActionsContainer::GetDragOperations(View* sender, |
779 const gfx::Point& p) { | 779 const gfx::Point& p) { |
780 return DragDropTypes::DRAG_MOVE; | 780 return ui::DragDropTypes::DRAG_MOVE; |
781 } | 781 } |
782 | 782 |
783 bool BrowserActionsContainer::CanStartDrag(View* sender, | 783 bool BrowserActionsContainer::CanStartDrag(View* sender, |
784 const gfx::Point& press_pt, | 784 const gfx::Point& press_pt, |
785 const gfx::Point& p) { | 785 const gfx::Point& p) { |
786 return true; | 786 return true; |
787 } | 787 } |
788 | 788 |
789 void BrowserActionsContainer::OnResize(int resize_amount, bool done_resizing) { | 789 void BrowserActionsContainer::OnResize(int resize_amount, bool done_resizing) { |
790 if (!done_resizing) { | 790 if (!done_resizing) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 AnimationEnded(resize_animation_.get()); | 1094 AnimationEnded(resize_animation_.get()); |
1095 } | 1095 } |
1096 } | 1096 } |
1097 | 1097 |
1098 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1098 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
1099 const Extension* extension) { | 1099 const Extension* extension) { |
1100 // Only display incognito-enabled extensions while in incognito mode. | 1100 // Only display incognito-enabled extensions while in incognito mode. |
1101 return (!profile_->IsOffTheRecord() || | 1101 return (!profile_->IsOffTheRecord() || |
1102 profile_->GetExtensionService()->IsIncognitoEnabled(extension)); | 1102 profile_->GetExtensionService()->IsIncognitoEnabled(extension)); |
1103 } | 1103 } |
OLD | NEW |