| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (data.HasURL(ui::OSExchangeData::CONVERT_FILENAMES)) | 56 if (data.HasURL(ui::OSExchangeData::CONVERT_FILENAMES)) |
| 57 return true; | 57 return true; |
| 58 | 58 |
| 59 // If there isn't a URL, see if we can 'paste and go'. | 59 // If there isn't a URL, see if we can 'paste and go'. |
| 60 return GetPasteAndGoURL(data, nullptr); | 60 return GetPasteAndGoURL(data, nullptr); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void BrowserRootView::OnDragEntered(const ui::DropTargetEvent& event) { | 63 void BrowserRootView::OnDragEntered(const ui::DropTargetEvent& event) { |
| 64 if (ShouldForwardToTabStrip(event)) { | 64 if (ShouldForwardToTabStrip(event)) { |
| 65 forwarding_to_tab_strip_ = true; | 65 forwarding_to_tab_strip_ = true; |
| 66 scoped_ptr<ui::DropTargetEvent> mapped_event( | 66 std::unique_ptr<ui::DropTargetEvent> mapped_event( |
| 67 MapEventToTabStrip(event, event.data())); | 67 MapEventToTabStrip(event, event.data())); |
| 68 tabstrip()->OnDragEntered(*mapped_event.get()); | 68 tabstrip()->OnDragEntered(*mapped_event.get()); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 int BrowserRootView::OnDragUpdated(const ui::DropTargetEvent& event) { | 72 int BrowserRootView::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 73 if (ShouldForwardToTabStrip(event)) { | 73 if (ShouldForwardToTabStrip(event)) { |
| 74 scoped_ptr<ui::DropTargetEvent> mapped_event( | 74 std::unique_ptr<ui::DropTargetEvent> mapped_event( |
| 75 MapEventToTabStrip(event, event.data())); | 75 MapEventToTabStrip(event, event.data())); |
| 76 if (!forwarding_to_tab_strip_) { | 76 if (!forwarding_to_tab_strip_) { |
| 77 tabstrip()->OnDragEntered(*mapped_event.get()); | 77 tabstrip()->OnDragEntered(*mapped_event.get()); |
| 78 forwarding_to_tab_strip_ = true; | 78 forwarding_to_tab_strip_ = true; |
| 79 } | 79 } |
| 80 return tabstrip()->OnDragUpdated(*mapped_event.get()); | 80 return tabstrip()->OnDragUpdated(*mapped_event.get()); |
| 81 } else if (forwarding_to_tab_strip_) { | 81 } else if (forwarding_to_tab_strip_) { |
| 82 forwarding_to_tab_strip_ = false; | 82 forwarding_to_tab_strip_ = false; |
| 83 tabstrip()->OnDragExited(); | 83 tabstrip()->OnDragExited(); |
| 84 } | 84 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 // The url isn't valid. Use the paste and go url. | 108 // The url isn't valid. Use the paste and go url. |
| 109 if (GetPasteAndGoURL(event.data(), &url)) | 109 if (GetPasteAndGoURL(event.data(), &url)) |
| 110 mapped_data.SetURL(url, base::string16()); | 110 mapped_data.SetURL(url, base::string16()); |
| 111 // else case: couldn't extract a url or 'paste and go' url. This ends up | 111 // 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 | 112 // passing through an ui::OSExchangeData with nothing in it. We need to do |
| 113 // this so that the tab strip cleans up properly. | 113 // this so that the tab strip cleans up properly. |
| 114 } else { | 114 } else { |
| 115 mapped_data.SetURL(url, base::string16()); | 115 mapped_data.SetURL(url, base::string16()); |
| 116 } | 116 } |
| 117 forwarding_to_tab_strip_ = false; | 117 forwarding_to_tab_strip_ = false; |
| 118 scoped_ptr<ui::DropTargetEvent> mapped_event( | 118 std::unique_ptr<ui::DropTargetEvent> mapped_event( |
| 119 MapEventToTabStrip(event, mapped_data)); | 119 MapEventToTabStrip(event, mapped_data)); |
| 120 return tabstrip()->OnPerformDrop(*mapped_event); | 120 return tabstrip()->OnPerformDrop(*mapped_event); |
| 121 } | 121 } |
| 122 | 122 |
| 123 const char* BrowserRootView::GetClassName() const { | 123 const char* BrowserRootView::GetClassName() const { |
| 124 return kViewClassName; | 124 return kViewClassName; |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 127 bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
| 128 if (browser_defaults::kScrollEventChangesTab) { | 128 if (browser_defaults::kScrollEventChangesTab) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 browser_view_->browser()->profile())->Classify( | 235 browser_view_->browser()->profile())->Classify( |
| 236 text, false, false, metrics::OmniboxEventProto::INVALID_SPEC, &match, | 236 text, false, false, metrics::OmniboxEventProto::INVALID_SPEC, &match, |
| 237 nullptr); | 237 nullptr); |
| 238 if (!match.destination_url.is_valid()) | 238 if (!match.destination_url.is_valid()) |
| 239 return false; | 239 return false; |
| 240 | 240 |
| 241 if (url) | 241 if (url) |
| 242 *url = match.destination_url; | 242 *url = match.destination_url; |
| 243 return true; | 243 return true; |
| 244 } | 244 } |
| OLD | NEW |