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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
9 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 9 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 BrowserRootView::BrowserRootView(BrowserView* browser_view, | 22 BrowserRootView::BrowserRootView(BrowserView* browser_view, |
23 views::Widget* widget) | 23 views::Widget* widget) |
24 : views::internal::RootView(widget), | 24 : views::internal::RootView(widget), |
25 browser_view_(browser_view), | 25 browser_view_(browser_view), |
26 forwarding_to_tab_strip_(false) { } | 26 forwarding_to_tab_strip_(false) { } |
27 | 27 |
28 bool BrowserRootView::GetDropFormats( | 28 bool BrowserRootView::GetDropFormats( |
29 int* formats, | 29 int* formats, |
30 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) { | 30 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) { |
31 if (tabstrip() && tabstrip()->IsVisible()) { | 31 if (tabstrip() && tabstrip()->visible()) { |
32 *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; | 32 *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; |
33 return true; | 33 return true; |
34 } | 34 } |
35 return false; | 35 return false; |
36 } | 36 } |
37 | 37 |
38 bool BrowserRootView::AreDropTypesRequired() { | 38 bool BrowserRootView::AreDropTypesRequired() { |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 bool BrowserRootView::CanDrop(const ui::OSExchangeData& data) { | 42 bool BrowserRootView::CanDrop(const ui::OSExchangeData& data) { |
43 if (!tabstrip() || !tabstrip()->IsVisible()) | 43 if (!tabstrip() || !tabstrip()->visible()) |
44 return false; | 44 return false; |
45 | 45 |
46 // If there is a URL, we'll allow the drop. | 46 // If there is a URL, we'll allow the drop. |
47 if (data.HasURL()) | 47 if (data.HasURL()) |
48 return true; | 48 return true; |
49 | 49 |
50 // If there isn't a URL, see if we can 'paste and go'. | 50 // If there isn't a URL, see if we can 'paste and go'. |
51 return GetPasteAndGoURL(data, NULL); | 51 return GetPasteAndGoURL(data, NULL); |
52 } | 52 } |
53 | 53 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return tabstrip()->OnPerformDrop(*mapped_event); | 109 return tabstrip()->OnPerformDrop(*mapped_event); |
110 } | 110 } |
111 | 111 |
112 void BrowserRootView::GetAccessibleState(ui::AccessibleViewState* state) { | 112 void BrowserRootView::GetAccessibleState(ui::AccessibleViewState* state) { |
113 views::internal::RootView::GetAccessibleState(state); | 113 views::internal::RootView::GetAccessibleState(state); |
114 state->name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 114 state->name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
115 } | 115 } |
116 | 116 |
117 bool BrowserRootView::ShouldForwardToTabStrip( | 117 bool BrowserRootView::ShouldForwardToTabStrip( |
118 const views::DropTargetEvent& event) { | 118 const views::DropTargetEvent& event) { |
119 if (!tabstrip()->IsVisible()) | 119 if (!tabstrip()->visible()) |
120 return false; | 120 return false; |
121 | 121 |
122 // Allow the drop as long as the mouse is over the tabstrip or vertically | 122 // Allow the drop as long as the mouse is over the tabstrip or vertically |
123 // before it. | 123 // before it. |
124 gfx::Point tab_loc_in_host; | 124 gfx::Point tab_loc_in_host; |
125 ConvertPointToView(tabstrip(), this, &tab_loc_in_host); | 125 ConvertPointToView(tabstrip(), this, &tab_loc_in_host); |
126 return event.y() < tab_loc_in_host.y() + tabstrip()->height(); | 126 return event.y() < tab_loc_in_host.y() + tabstrip()->height(); |
127 } | 127 } |
128 | 128 |
129 views::DropTargetEvent* BrowserRootView::MapEventToTabStrip( | 129 views::DropTargetEvent* BrowserRootView::MapEventToTabStrip( |
(...skipping 22 matching lines...) Expand all Loading... |
152 AutocompleteMatch match; | 152 AutocompleteMatch match; |
153 browser_view_->browser()->profile()->GetAutocompleteClassifier()->Classify( | 153 browser_view_->browser()->profile()->GetAutocompleteClassifier()->Classify( |
154 text, string16(), false, false, &match, NULL); | 154 text, string16(), false, false, &match, NULL); |
155 if (!match.destination_url.is_valid()) | 155 if (!match.destination_url.is_valid()) |
156 return false; | 156 return false; |
157 | 157 |
158 if (url) | 158 if (url) |
159 *url = match.destination_url; | 159 *url = match.destination_url; |
160 return true; | 160 return true; |
161 } | 161 } |
OLD | NEW |