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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 // mid-point between two page actions in the bounding rectangle. For even | 1293 // mid-point between two page actions in the bounding rectangle. For even |
| 1294 // paddings, the +1 is dropped, which is right since there is no pixel at | 1294 // paddings, the +1 is dropped, which is right since there is no pixel at |
| 1295 // the mid-point. | 1295 // the mid-point. |
| 1296 bounds.Inset(-(horizontal_padding + 1) / 2, 0); | 1296 bounds.Inset(-(horizontal_padding + 1) / 2, 0); |
| 1297 location_bar_util::PaintExtensionActionBackground( | 1297 location_bar_util::PaintExtensionActionBackground( |
| 1298 *(*page_action_view)->image_view()->page_action(), | 1298 *(*page_action_view)->image_view()->page_action(), |
| 1299 tab_id, canvas, bounds, text_color, background_color); | 1299 tab_id, canvas, bounds, text_color, background_color); |
| 1300 } | 1300 } |
| 1301 } | 1301 } |
| 1302 | 1302 |
| 1303 void LocationBarView::AccessibilitySetValue(const string16& new_value) { | |
| 1304 location_entry_->SetUserText(new_value); | |
| 1305 location_entry_->SelectAll(false); | |
|
msw
2013/08/31 20:22:36
This does not clear the selection as the Accessibi
dmazzoni
2013/09/03 20:20:11
Done.
| |
| 1306 } | |
| 1307 | |
| 1303 const char* LocationBarView::GetClassName() const { | 1308 const char* LocationBarView::GetClassName() const { |
| 1304 return kViewClassName; | 1309 return kViewClassName; |
| 1305 } | 1310 } |
| 1306 | 1311 |
| 1307 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { | 1312 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { |
| 1308 #if defined(OS_WIN) | 1313 #if defined(OS_WIN) |
| 1309 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1314 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
| 1310 if (location_entry_->model()->popup_model()->IsOpen()) { | 1315 if (location_entry_->model()->popup_model()->IsOpen()) { |
| 1311 // Return true so that the edit sees the tab and moves the selection. | 1316 // Return true so that the edit sees the tab and moves the selection. |
| 1312 return true; | 1317 return true; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1334 void LocationBarView::GetAccessibleState(ui::AccessibleViewState* state) { | 1339 void LocationBarView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 1335 state->role = ui::AccessibilityTypes::ROLE_LOCATION_BAR; | 1340 state->role = ui::AccessibilityTypes::ROLE_LOCATION_BAR; |
| 1336 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); | 1341 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); |
| 1337 state->value = location_entry_->GetText(); | 1342 state->value = location_entry_->GetText(); |
| 1338 | 1343 |
| 1339 string16::size_type entry_start; | 1344 string16::size_type entry_start; |
| 1340 string16::size_type entry_end; | 1345 string16::size_type entry_end; |
| 1341 location_entry_->GetSelectionBounds(&entry_start, &entry_end); | 1346 location_entry_->GetSelectionBounds(&entry_start, &entry_end); |
| 1342 state->selection_start = entry_start; | 1347 state->selection_start = entry_start; |
| 1343 state->selection_end = entry_end; | 1348 state->selection_end = entry_end; |
| 1349 | |
| 1350 state->set_value_callback = base::Bind( | |
| 1351 &LocationBarView::AccessibilitySetValue, base::Unretained(this)); | |
|
msw
2013/08/31 20:22:36
base::Unretained is probably not correct here, I t
dmazzoni
2013/09/03 20:20:11
I don't think we need to bind to location_entry_,
msw
2013/09/03 21:06:57
Binding to a LocationBarView WeakPtr is just as go
| |
| 1344 } | 1352 } |
| 1345 | 1353 |
| 1346 bool LocationBarView::HasFocus() const { | 1354 bool LocationBarView::HasFocus() const { |
| 1347 return location_entry_->model()->has_focus(); | 1355 return location_entry_->model()->has_focus(); |
| 1348 } | 1356 } |
| 1349 | 1357 |
| 1350 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1358 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1351 if (browser_ && browser_->instant_controller() && parent()) | 1359 if (browser_ && browser_->instant_controller() && parent()) |
| 1352 browser_->instant_controller()->SetOmniboxBounds(bounds()); | 1360 browser_->instant_controller()->SetOmniboxBounds(bounds()); |
| 1353 OmniboxPopupView* popup = location_entry_->model()->popup_model()->view(); | 1361 OmniboxPopupView* popup = location_entry_->model()->popup_model()->view(); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1561 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1554 int total_height = | 1562 int total_height = |
| 1555 use_preferred_size ? GetPreferredSize().height() : height(); | 1563 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1556 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1564 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
| 1557 } | 1565 } |
| 1558 | 1566 |
| 1559 bool LocationBarView::HasValidSuggestText() const { | 1567 bool LocationBarView::HasValidSuggestText() const { |
| 1560 return suggested_text_view_->visible() && | 1568 return suggested_text_view_->visible() && |
| 1561 !suggested_text_view_->size().IsEmpty(); | 1569 !suggested_text_view_->size().IsEmpty(); |
| 1562 } | 1570 } |
| OLD | NEW |