Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 23983039: Merge 221688 "Implement put_accvalue for textfields and location..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 keyword_hint_view_(NULL), 185 keyword_hint_view_(NULL),
186 mic_search_view_(NULL), 186 mic_search_view_(NULL),
187 zoom_view_(NULL), 187 zoom_view_(NULL),
188 generated_credit_card_view_(NULL), 188 generated_credit_card_view_(NULL),
189 open_pdf_in_reader_view_(NULL), 189 open_pdf_in_reader_view_(NULL),
190 script_bubble_icon_view_(NULL), 190 script_bubble_icon_view_(NULL),
191 star_view_(NULL), 191 star_view_(NULL),
192 is_popup_mode_(is_popup_mode), 192 is_popup_mode_(is_popup_mode),
193 show_focus_rect_(false), 193 show_focus_rect_(false),
194 template_url_service_(NULL), 194 template_url_service_(NULL),
195 animation_offset_(0) { 195 animation_offset_(0),
196 weak_ptr_factory_(this) {
196 if (!views::Textfield::IsViewsTextfieldEnabled()) 197 if (!views::Textfield::IsViewsTextfieldEnabled())
197 set_id(VIEW_ID_OMNIBOX); 198 set_id(VIEW_ID_OMNIBOX);
198 199
199 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER); 200 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER);
200 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER); 201 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER);
201 background_border_painter_.reset( 202 background_border_painter_.reset(
202 views::Painter::CreateImageGridPainter( 203 views::Painter::CreateImageGridPainter(
203 is_popup_mode_ ? kOmniboxPopupImages : kOmniboxBorderImages)); 204 is_popup_mode_ ? kOmniboxPopupImages : kOmniboxBorderImages));
204 #if defined(OS_CHROMEOS) 205 #if defined(OS_CHROMEOS)
205 if (!is_popup_mode_) { 206 if (!is_popup_mode_) {
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 return omnibox_win->SkipDefaultKeyEventProcessing(event); 1314 return omnibox_win->SkipDefaultKeyEventProcessing(event);
1314 #endif // USE_AURA 1315 #endif // USE_AURA
1315 #endif // OS_WIN 1316 #endif // OS_WIN
1316 1317
1317 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in 1318 // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in
1318 // src/ui/views/focus/focus_manager.cc for details. 1319 // src/ui/views/focus/focus_manager.cc for details.
1319 return false; 1320 return false;
1320 } 1321 }
1321 1322
1322 void LocationBarView::GetAccessibleState(ui::AccessibleViewState* state) { 1323 void LocationBarView::GetAccessibleState(ui::AccessibleViewState* state) {
1324 if (!location_entry_)
1325 return;
1326
1323 state->role = ui::AccessibilityTypes::ROLE_LOCATION_BAR; 1327 state->role = ui::AccessibilityTypes::ROLE_LOCATION_BAR;
1324 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION); 1328 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION);
1325 state->value = location_entry_->GetText(); 1329 state->value = location_entry_->GetText();
1326 1330
1327 string16::size_type entry_start; 1331 string16::size_type entry_start;
1328 string16::size_type entry_end; 1332 string16::size_type entry_end;
1329 location_entry_->GetSelectionBounds(&entry_start, &entry_end); 1333 location_entry_->GetSelectionBounds(&entry_start, &entry_end);
1330 state->selection_start = entry_start; 1334 state->selection_start = entry_start;
1331 state->selection_end = entry_end; 1335 state->selection_end = entry_end;
1336
1337 if (is_popup_mode_) {
1338 state->state |= ui::AccessibilityTypes::STATE_READONLY;
1339 } else {
1340 state->set_value_callback =
1341 base::Bind(&LocationBarView::AccessibilitySetValue,
1342 weak_ptr_factory_.GetWeakPtr());
1343 }
1332 } 1344 }
1333 1345
1334 bool LocationBarView::HasFocus() const { 1346 bool LocationBarView::HasFocus() const {
1335 return location_entry_->model()->has_focus(); 1347 return location_entry_->model()->has_focus();
1336 } 1348 }
1337 1349
1338 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1350 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1339 if (browser_ && browser_->instant_controller() && parent()) 1351 if (browser_ && browser_->instant_controller() && parent())
1340 browser_->instant_controller()->SetOmniboxBounds(bounds()); 1352 browser_->instant_controller()->SetOmniboxBounds(bounds());
1341 OmniboxPopupView* popup = location_entry_->model()->popup_model()->view(); 1353 OmniboxPopupView* popup = location_entry_->model()->popup_model()->view();
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 1553 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
1542 int total_height = 1554 int total_height =
1543 use_preferred_size ? GetPreferredSize().height() : height(); 1555 use_preferred_size ? GetPreferredSize().height() : height();
1544 return std::max(total_height - (vertical_edge_thickness() * 2), 0); 1556 return std::max(total_height - (vertical_edge_thickness() * 2), 0);
1545 } 1557 }
1546 1558
1547 bool LocationBarView::HasValidSuggestText() const { 1559 bool LocationBarView::HasValidSuggestText() const {
1548 return suggested_text_view_->visible() && 1560 return suggested_text_view_->visible() &&
1549 !suggested_text_view_->size().IsEmpty(); 1561 !suggested_text_view_->size().IsEmpty();
1550 } 1562 }
1563
1564 void LocationBarView::AccessibilitySetValue(const string16& new_value) {
1565 location_entry_->SetUserText(new_value);
1566 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698