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/frame/browser_root_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_root_view.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | |
8 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
11 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/omnibox/location_bar.h" | 13 #include "chrome/browser/ui/omnibox/location_bar.h" |
15 #include "chrome/browser/ui/views/frame/browser_frame.h" | 14 #include "chrome/browser/ui/views/frame/browser_frame.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 16 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
18 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 18 #include "ui/base/dragdrop/drag_drop_types.h" |
19 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
20 | 20 |
21 BrowserRootView::BrowserRootView(BrowserView* browser_view, | 21 BrowserRootView::BrowserRootView(BrowserView* browser_view, |
22 views::Widget* widget) | 22 views::Widget* widget) |
23 : views::RootView(widget), | 23 : views::RootView(widget), |
24 browser_view_(browser_view), | 24 browser_view_(browser_view), |
25 forwarding_to_tab_strip_(false) { | 25 forwarding_to_tab_strip_(false) { |
26 SetAccessibleName(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 26 SetAccessibleName(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
27 } | 27 } |
28 | 28 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 MapEventToTabStrip(event, event.GetData())); | 67 MapEventToTabStrip(event, event.GetData())); |
68 if (!forwarding_to_tab_strip_) { | 68 if (!forwarding_to_tab_strip_) { |
69 tabstrip()->OnDragEntered(*mapped_event.get()); | 69 tabstrip()->OnDragEntered(*mapped_event.get()); |
70 forwarding_to_tab_strip_ = true; | 70 forwarding_to_tab_strip_ = true; |
71 } | 71 } |
72 return tabstrip()->OnDragUpdated(*mapped_event.get()); | 72 return tabstrip()->OnDragUpdated(*mapped_event.get()); |
73 } else if (forwarding_to_tab_strip_) { | 73 } else if (forwarding_to_tab_strip_) { |
74 forwarding_to_tab_strip_ = false; | 74 forwarding_to_tab_strip_ = false; |
75 tabstrip()->OnDragExited(); | 75 tabstrip()->OnDragExited(); |
76 } | 76 } |
77 return DragDropTypes::DRAG_NONE; | 77 return ui::DragDropTypes::DRAG_NONE; |
78 } | 78 } |
79 | 79 |
80 void BrowserRootView::OnDragExited() { | 80 void BrowserRootView::OnDragExited() { |
81 if (forwarding_to_tab_strip_) { | 81 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 } |
85 } | 85 } |
86 | 86 |
87 int BrowserRootView::OnPerformDrop(const views::DropTargetEvent& event) { | 87 int BrowserRootView::OnPerformDrop(const views::DropTargetEvent& event) { |
88 if (!forwarding_to_tab_strip_) | 88 if (!forwarding_to_tab_strip_) |
89 return DragDropTypes::DRAG_NONE; | 89 return ui::DragDropTypes::DRAG_NONE; |
90 | 90 |
91 // Extract the URL and create a new ui::OSExchangeData containing the URL. We | 91 // Extract the URL and create a new ui::OSExchangeData containing the URL. We |
92 // do this as the TabStrip doesn't know about the autocomplete edit and needs | 92 // do this as the TabStrip doesn't know about the autocomplete edit and needs |
93 // to know about it to handle 'paste and go'. | 93 // to know about it to handle 'paste and go'. |
94 GURL url; | 94 GURL url; |
95 std::wstring title; | 95 std::wstring title; |
96 ui::OSExchangeData mapped_data; | 96 ui::OSExchangeData mapped_data; |
97 if (!event.GetData().GetURLAndTitle(&url, &title) || !url.is_valid()) { | 97 if (!event.GetData().GetURLAndTitle(&url, &title) || !url.is_valid()) { |
98 // The url isn't valid. Use the paste and go url. | 98 // The url isn't valid. Use the paste and go url. |
99 if (GetPasteAndGoURL(event.GetData(), &url)) | 99 if (GetPasteAndGoURL(event.GetData(), &url)) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 AutocompleteMatch match; | 148 AutocompleteMatch match; |
149 browser_view_->browser()->profile()->GetAutocompleteClassifier()->Classify( | 149 browser_view_->browser()->profile()->GetAutocompleteClassifier()->Classify( |
150 text, std::wstring(), false, &match, NULL); | 150 text, std::wstring(), false, &match, NULL); |
151 if (!match.destination_url.is_valid()) | 151 if (!match.destination_url.is_valid()) |
152 return false; | 152 return false; |
153 | 153 |
154 if (url) | 154 if (url) |
155 *url = match.destination_url; | 155 *url = match.destination_url; |
156 return true; | 156 return true; |
157 } | 157 } |
OLD | NEW |