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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 10 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 width() - kPopupBackgroundEdge->width(), top_spacing); | 605 width() - kPopupBackgroundEdge->width(), top_spacing); |
606 } | 606 } |
607 | 607 |
608 // For glass, we need to draw a black line below the location bar to separate | 608 // For glass, we need to draw a black line below the location bar to separate |
609 // it from the content area. For non-glass, the NonClientView draws the | 609 // it from the content area. For non-glass, the NonClientView draws the |
610 // toolbar background below the location bar for us. | 610 // toolbar background below the location bar for us. |
611 if (GetWindow()->GetNonClientView()->UseNativeFrame()) | 611 if (GetWindow()->GetNonClientView()->UseNativeFrame()) |
612 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 612 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
613 } | 613 } |
614 | 614 |
| 615 // Note this method is ignored on Windows, but needs to be implemented for |
| 616 // linux, where it is called before CanDrop(). |
| 617 bool ToolbarView::GetDropFormats( |
| 618 int* formats, |
| 619 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
| 620 *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; |
| 621 return true; |
| 622 } |
| 623 |
| 624 bool ToolbarView::CanDrop(const ui::OSExchangeData& data) { |
| 625 // To support loading URLs by dropping into the toolbar, we need to support |
| 626 // dropping URLs and/or text. |
| 627 return data.HasURL() || data.HasString(); |
| 628 } |
| 629 |
| 630 int ToolbarView::OnDragUpdated(const views::DropTargetEvent& event) { |
| 631 if (event.source_operations() & ui::DragDropTypes::DRAG_COPY) { |
| 632 return ui::DragDropTypes::DRAG_COPY; |
| 633 } else if (event.source_operations() & ui::DragDropTypes::DRAG_LINK) { |
| 634 return ui::DragDropTypes::DRAG_LINK; |
| 635 } |
| 636 return ui::DragDropTypes::DRAG_NONE; |
| 637 } |
| 638 |
| 639 int ToolbarView::OnPerformDrop(const views::DropTargetEvent& event) { |
| 640 return location_bar_->location_entry()->OnPerformDrop(event); |
| 641 } |
| 642 |
615 void ToolbarView::OnThemeChanged() { | 643 void ToolbarView::OnThemeChanged() { |
616 LoadImages(); | 644 LoadImages(); |
617 } | 645 } |
618 | 646 |
619 //////////////////////////////////////////////////////////////////////////////// | 647 //////////////////////////////////////////////////////////////////////////////// |
620 // ToolbarView, protected: | 648 // ToolbarView, protected: |
621 | 649 |
622 // Override this so that when the user presses F6 to rotate toolbar panes, | 650 // Override this so that when the user presses F6 to rotate toolbar panes, |
623 // the location bar gets focus, not the first control in the toolbar. | 651 // the location bar gets focus, not the first control in the toolbar. |
624 views::View* ToolbarView::GetDefaultFocusableChild() { | 652 views::View* ToolbarView::GetDefaultFocusableChild() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 NOTREACHED(); | 799 NOTREACHED(); |
772 #endif | 800 #endif |
773 } else { | 801 } else { |
774 NOTREACHED(); | 802 NOTREACHED(); |
775 } | 803 } |
776 | 804 |
777 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin); | 805 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin); |
778 | 806 |
779 return canvas->ExtractBitmap(); | 807 return canvas->ExtractBitmap(); |
780 } | 808 } |
OLD | NEW |