| 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/frame/browser_root_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_root_view.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 bool BrowserRootView::AreDropTypesRequired() { | 47 bool BrowserRootView::AreDropTypesRequired() { |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool BrowserRootView::CanDrop(const ui::OSExchangeData& data) { | 51 bool BrowserRootView::CanDrop(const ui::OSExchangeData& data) { |
| 52 if (!tabstrip() || !tabstrip()->visible()) | 52 if (!tabstrip() || !tabstrip()->visible()) |
| 53 return false; | 53 return false; |
| 54 | 54 |
| 55 // If there is a URL, we'll allow the drop. | 55 // If there is a URL, we'll allow the drop. |
| 56 if (data.HasURL(ui::OSExchangeData::CONVERT_FILENAMES)) | 56 if (data.HasURL(ui::OSExchangeData::CONVERT_FILENAMES, |
| 57 ui::OSExchangeData::DO_NOT_PARSE_TEXT_AS_URL)) |
| 57 return true; | 58 return true; |
| 58 | 59 |
| 59 // If there isn't a URL, see if we can 'paste and go'. | 60 // If there isn't a URL, see if we can 'paste and go'. |
| 60 return GetPasteAndGoURL(data, nullptr); | 61 return GetPasteAndGoURL(data, nullptr); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void BrowserRootView::OnDragEntered(const ui::DropTargetEvent& event) { | 64 void BrowserRootView::OnDragEntered(const ui::DropTargetEvent& event) { |
| 64 if (ShouldForwardToTabStrip(event)) { | 65 if (ShouldForwardToTabStrip(event)) { |
| 65 forwarding_to_tab_strip_ = true; | 66 forwarding_to_tab_strip_ = true; |
| 66 std::unique_ptr<ui::DropTargetEvent> mapped_event( | 67 std::unique_ptr<ui::DropTargetEvent> mapped_event( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 95 int BrowserRootView::OnPerformDrop(const ui::DropTargetEvent& event) { | 96 int BrowserRootView::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 96 if (!forwarding_to_tab_strip_) | 97 if (!forwarding_to_tab_strip_) |
| 97 return ui::DragDropTypes::DRAG_NONE; | 98 return ui::DragDropTypes::DRAG_NONE; |
| 98 | 99 |
| 99 // Extract the URL and create a new ui::OSExchangeData containing the URL. We | 100 // Extract the URL and create a new ui::OSExchangeData containing the URL. We |
| 100 // do this as the TabStrip doesn't know about the autocomplete edit and needs | 101 // do this as the TabStrip doesn't know about the autocomplete edit and needs |
| 101 // to know about it to handle 'paste and go'. | 102 // to know about it to handle 'paste and go'. |
| 102 GURL url; | 103 GURL url; |
| 103 base::string16 title; | 104 base::string16 title; |
| 104 ui::OSExchangeData mapped_data; | 105 ui::OSExchangeData mapped_data; |
| 105 if (!event.data().GetURLAndTitle( | 106 if (!event.data().GetURLAndTitle(ui::OSExchangeData::CONVERT_FILENAMES, |
| 106 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title) || | 107 ui::OSExchangeData::DO_NOT_PARSE_TEXT_AS_URL, |
| 108 &url, &title) || |
| 107 !url.is_valid()) { | 109 !url.is_valid()) { |
| 108 // The url isn't valid. Use the paste and go url. | 110 // The url isn't valid. Use the paste and go url. |
| 109 if (GetPasteAndGoURL(event.data(), &url)) | 111 if (GetPasteAndGoURL(event.data(), &url)) |
| 110 mapped_data.SetURL(url, base::string16()); | 112 mapped_data.SetURL(url, base::string16()); |
| 111 // else case: couldn't extract a url or 'paste and go' url. This ends up | 113 // else case: couldn't extract a url or 'paste and go' url. This ends up |
| 112 // passing through an ui::OSExchangeData with nothing in it. We need to do | 114 // passing through an ui::OSExchangeData with nothing in it. We need to do |
| 113 // this so that the tab strip cleans up properly. | 115 // this so that the tab strip cleans up properly. |
| 114 } else { | 116 } else { |
| 115 mapped_data.SetURL(url, base::string16()); | 117 mapped_data.SetURL(url, base::string16()); |
| 116 } | 118 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 browser_view_->browser()->profile())->Classify( | 237 browser_view_->browser()->profile())->Classify( |
| 236 text, false, false, metrics::OmniboxEventProto::INVALID_SPEC, &match, | 238 text, false, false, metrics::OmniboxEventProto::INVALID_SPEC, &match, |
| 237 nullptr); | 239 nullptr); |
| 238 if (!match.destination_url.is_valid()) | 240 if (!match.destination_url.is_valid()) |
| 239 return false; | 241 return false; |
| 240 | 242 |
| 241 if (url) | 243 if (url) |
| 242 *url = match.destination_url; | 244 *url = match.destination_url; |
| 243 return true; | 245 return true; |
| 244 } | 246 } |
| OLD | NEW |