Chromium Code Reviews| 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/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 36 #include "chrome/grit/theme_resources.h" | 36 #include "chrome/grit/theme_resources.h" |
| 37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
| 39 #include "third_party/skia/include/core/SkColorFilter.h" | 39 #include "third_party/skia/include/core/SkColorFilter.h" |
| 40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
| 41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" | 41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" |
| 42 #include "third_party/skia/include/pathops/SkPathOps.h" | 42 #include "third_party/skia/include/pathops/SkPathOps.h" |
| 43 #include "ui/accessibility/ax_view_state.h" | 43 #include "ui/accessibility/ax_view_state.h" |
| 44 #include "ui/base/default_theme_provider.h" | 44 #include "ui/base/default_theme_provider.h" |
| 45 #include "ui/base/dragdrop/drag_and_drop_url_utils.h" | |
| 45 #include "ui/base/dragdrop/drag_drop_types.h" | 46 #include "ui/base/dragdrop/drag_drop_types.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/material_design/material_design_controller.h" | 48 #include "ui/base/material_design/material_design_controller.h" |
| 48 #include "ui/base/models/list_selection_model.h" | 49 #include "ui/base/models/list_selection_model.h" |
| 49 #include "ui/base/resource/resource_bundle.h" | 50 #include "ui/base/resource/resource_bundle.h" |
| 50 #include "ui/compositor/compositing_recorder.h" | 51 #include "ui/compositor/compositing_recorder.h" |
| 51 #include "ui/compositor/paint_recorder.h" | 52 #include "ui/compositor/paint_recorder.h" |
| 52 #include "ui/display/display.h" | 53 #include "ui/display/display.h" |
| 53 #include "ui/display/screen.h" | 54 #include "ui/display/screen.h" |
| 54 #include "ui/gfx/animation/animation_container.h" | 55 #include "ui/gfx/animation/animation_container.h" |
| (...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1603 void TabStrip::OnDragEntered(const DropTargetEvent& event) { | 1604 void TabStrip::OnDragEntered(const DropTargetEvent& event) { |
| 1604 // Force animations to stop, otherwise it makes the index calculation tricky. | 1605 // Force animations to stop, otherwise it makes the index calculation tricky. |
| 1605 StopAnimating(true); | 1606 StopAnimating(true); |
| 1606 | 1607 |
| 1607 UpdateDropIndex(event); | 1608 UpdateDropIndex(event); |
| 1608 | 1609 |
| 1609 GURL url; | 1610 GURL url; |
| 1610 base::string16 title; | 1611 base::string16 title; |
| 1611 | 1612 |
| 1612 // Check whether the event data includes supported drop data. | 1613 // Check whether the event data includes supported drop data. |
| 1613 if (event.data().GetURLAndTitle( | 1614 if (auto url_and_title = ui::TryToInterpretAsURL( |
|
dyaroshev
2016/09/14 17:12:05
I'm still not so sure, how much of this code shoul
Peter Kasting
2016/09/15 21:26:52
Which logic are you referring to specifically?
Ma
| |
| 1614 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title) && | 1615 event.data(), ui::OSExchangeData::CONVERT_FILENAMES)) { |
| 1615 url.is_valid()) { | 1616 if (!url_and_title->first.is_valid()) |
| 1616 drop_info_->url = url; | 1617 return; |
| 1618 drop_info_->url = url_and_title->first; | |
| 1617 | 1619 |
| 1618 // For file:// URLs, kick off a MIME type request in case they're dropped. | 1620 // For file:// URLs, kick off a MIME type request in case they're dropped. |
| 1619 if (url.SchemeIsFile()) | 1621 if (url_and_title->first.SchemeIsFile()) |
| 1620 controller_->CheckFileSupported(url); | 1622 controller_->CheckFileSupported(url_and_title->first); |
| 1621 } | 1623 } |
| 1622 } | 1624 } |
| 1623 | 1625 |
| 1624 int TabStrip::OnDragUpdated(const DropTargetEvent& event) { | 1626 int TabStrip::OnDragUpdated(const DropTargetEvent& event) { |
| 1625 // Update the drop index even if the file is unsupported, to allow | 1627 // Update the drop index even if the file is unsupported, to allow |
| 1626 // dragging a file to the contents of another tab. | 1628 // dragging a file to the contents of another tab. |
| 1627 UpdateDropIndex(event); | 1629 UpdateDropIndex(event); |
| 1628 | 1630 |
| 1629 if (!drop_info_->file_supported) | 1631 if (!drop_info_->file_supported) |
| 1630 return ui::DragDropTypes::DRAG_NONE; | 1632 return ui::DragDropTypes::DRAG_NONE; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1642 | 1644 |
| 1643 const int drop_index = drop_info_->drop_index; | 1645 const int drop_index = drop_info_->drop_index; |
| 1644 const bool drop_before = drop_info_->drop_before; | 1646 const bool drop_before = drop_info_->drop_before; |
| 1645 const bool file_supported = drop_info_->file_supported; | 1647 const bool file_supported = drop_info_->file_supported; |
| 1646 | 1648 |
| 1647 // Hide the drop indicator. | 1649 // Hide the drop indicator. |
| 1648 SetDropIndex(-1, false); | 1650 SetDropIndex(-1, false); |
| 1649 | 1651 |
| 1650 // Do nothing if the file was unsupported or the URL is invalid. The URL may | 1652 // Do nothing if the file was unsupported or the URL is invalid. The URL may |
| 1651 // have been changed after |drop_info_| was created. | 1653 // have been changed after |drop_info_| was created. |
| 1652 GURL url; | 1654 if (!file_supported) |
| 1653 base::string16 title; | |
| 1654 if (!file_supported || | |
| 1655 !event.data().GetURLAndTitle( | |
| 1656 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title) || | |
| 1657 !url.is_valid()) | |
| 1658 return ui::DragDropTypes::DRAG_NONE; | 1655 return ui::DragDropTypes::DRAG_NONE; |
| 1659 | 1656 |
| 1660 controller_->PerformDrop(drop_before, drop_index, url); | 1657 auto url_and_title = ui::TryToInterpretAsURL( |
| 1658 event.data(), ui::OSExchangeData::CONVERT_FILENAMES); | |
| 1659 if (!url_and_title || !url_and_title->first.is_valid()) | |
| 1660 return ui::DragDropTypes::DRAG_NONE; | |
| 1661 | |
| 1662 controller_->PerformDrop(drop_before, drop_index, url_and_title->first); | |
| 1661 | 1663 |
| 1662 return GetDropEffect(event); | 1664 return GetDropEffect(event); |
| 1663 } | 1665 } |
| 1664 | 1666 |
| 1665 void TabStrip::GetAccessibleState(ui::AXViewState* state) { | 1667 void TabStrip::GetAccessibleState(ui::AXViewState* state) { |
| 1666 state->role = ui::AX_ROLE_TAB_LIST; | 1668 state->role = ui::AX_ROLE_TAB_LIST; |
| 1667 } | 1669 } |
| 1668 | 1670 |
| 1669 views::View* TabStrip::GetTooltipHandlerForPoint(const gfx::Point& point) { | 1671 views::View* TabStrip::GetTooltipHandlerForPoint(const gfx::Point& point) { |
| 1670 if (!HitTestPoint(point)) | 1672 if (!HitTestPoint(point)) |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2886 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2888 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| 2887 if (view) | 2889 if (view) |
| 2888 return view; | 2890 return view; |
| 2889 } | 2891 } |
| 2890 Tab* tab = FindTabForEvent(point); | 2892 Tab* tab = FindTabForEvent(point); |
| 2891 if (tab) | 2893 if (tab) |
| 2892 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2894 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
| 2893 } | 2895 } |
| 2894 return this; | 2896 return this; |
| 2895 } | 2897 } |
| OLD | NEW |