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

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

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win fixes Created 8 years, 5 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/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 origin.set_x(width() - origin.x()); 532 origin.set_x(width() - origin.x());
533 views::View::ConvertPointToScreen(this, &origin); 533 views::View::ConvertPointToScreen(this, &origin);
534 return origin; 534 return origin;
535 } 535 }
536 536
537 void LocationBarView::SetInstantSuggestion(const string16& text, 537 void LocationBarView::SetInstantSuggestion(const string16& text,
538 bool animate_to_complete) { 538 bool animate_to_complete) {
539 // Don't show the suggested text if inline autocomplete is prevented. 539 // Don't show the suggested text if inline autocomplete is prevented.
540 if (!text.empty()) { 540 if (!text.empty()) {
541 if (!suggested_text_view_) { 541 if (!suggested_text_view_) {
542 suggested_text_view_ = new SuggestedTextView(location_entry_->model()); 542 suggested_text_view_ = new SuggestedTextView(location_entry_->GetModel());
543 suggested_text_view_->SetText(text); 543 suggested_text_view_->SetText(text);
544 suggested_text_view_->SetFont(location_entry_->GetFont()); 544 suggested_text_view_->SetFont(location_entry_->GetFont());
545 AddChildView(suggested_text_view_); 545 AddChildView(suggested_text_view_);
546 } else if (suggested_text_view_->text() != text) { 546 } else if (suggested_text_view_->text() != text) {
547 suggested_text_view_->SetText(text); 547 suggested_text_view_->SetText(text);
548 } 548 }
549 if (animate_to_complete && !location_entry_->IsImeComposing()) 549 if (animate_to_complete && !location_entry_->IsImeComposing())
550 suggested_text_view_->StartAnimation(); 550 suggested_text_view_->StartAnimation();
551 } else if (suggested_text_view_) { 551 } else if (suggested_text_view_) {
552 delete suggested_text_view_; 552 delete suggested_text_view_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // Start by reserving the padding at the right edge. 629 // Start by reserving the padding at the right edge.
630 int entry_width = width() - kEdgeThickness - GetEdgeItemPadding(); 630 int entry_width = width() - kEdgeThickness - GetEdgeItemPadding();
631 631
632 // |location_icon_view_| is visible except when |ev_bubble_view_| or 632 // |location_icon_view_| is visible except when |ev_bubble_view_| or
633 // |selected_keyword_view_| are visible. 633 // |selected_keyword_view_| are visible.
634 int location_icon_width = 0; 634 int location_icon_width = 0;
635 int ev_bubble_width = 0; 635 int ev_bubble_width = 0;
636 location_icon_view_->SetVisible(false); 636 location_icon_view_->SetVisible(false);
637 ev_bubble_view_->SetVisible(false); 637 ev_bubble_view_->SetVisible(false);
638 638
639 const string16 keyword(location_entry_->model()->keyword()); 639 const string16 keyword(location_entry_->GetModel()->keyword());
640 const bool is_keyword_hint(location_entry_->model()->is_keyword_hint()); 640 const bool is_keyword_hint(location_entry_->GetModel()->is_keyword_hint());
641 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint; 641 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint;
642 if (show_selected_keyword) { 642 if (show_selected_keyword) {
643 // Assume the keyword might be hidden. 643 // Assume the keyword might be hidden.
644 entry_width -= (kEdgeThickness + kEdgeEditPadding); 644 entry_width -= (kEdgeThickness + kEdgeEditPadding);
645 } else if (model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { 645 } else if (model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
646 ev_bubble_view_->SetVisible(true); 646 ev_bubble_view_->SetVisible(true);
647 ev_bubble_view_->SetLabel(model_->GetEVCertName()); 647 ev_bubble_view_->SetLabel(model_->GetEVCertName());
648 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width(); 648 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width();
649 // We'll adjust this width and take it out of |entry_width| below. 649 // We'll adjust this width and take it out of |entry_width| below.
650 } else { 650 } else {
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 } 1212 }
1213 1213
1214 std::string LocationBarView::GetClassName() const { 1214 std::string LocationBarView::GetClassName() const {
1215 return kViewClassName; 1215 return kViewClassName;
1216 } 1216 }
1217 1217
1218 bool LocationBarView::SkipDefaultKeyEventProcessing( 1218 bool LocationBarView::SkipDefaultKeyEventProcessing(
1219 const views::KeyEvent& event) { 1219 const views::KeyEvent& event) {
1220 #if defined(OS_WIN) 1220 #if defined(OS_WIN)
1221 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { 1221 if (views::FocusManager::IsTabTraversalKeyEvent(event)) {
1222 if (location_entry_->model()->popup_model()->IsOpen()) { 1222 if (location_entry_->GetModel()->popup_model()->IsOpen()) {
1223 // Return true so that the edit sees the tab and moves the selection. 1223 // Return true so that the edit sees the tab and moves the selection.
1224 return true; 1224 return true;
1225 } 1225 }
1226 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { 1226 if (keyword_hint_view_->visible() && !event.IsShiftDown()) {
1227 // Return true so the edit gets the tab event and enters keyword mode. 1227 // Return true so the edit gets the tab event and enters keyword mode.
1228 return true; 1228 return true;
1229 } 1229 }
1230 1230
1231 // Tab while showing instant commits instant immediately. 1231 // Tab while showing instant commits instant immediately.
1232 // Return true so that focus traversal isn't attempted. The edit ends 1232 // Return true so that focus traversal isn't attempted. The edit ends
1233 // up doing nothing in this case. 1233 // up doing nothing in this case.
1234 if (location_entry_->model()->AcceptCurrentInstantPreview()) 1234 if (location_entry_->GetModel()->AcceptCurrentInstantPreview())
1235 return true; 1235 return true;
1236 } 1236 }
1237 1237
1238 #if defined(USE_AURA) 1238 #if defined(USE_AURA)
1239 NOTIMPLEMENTED(); 1239 NOTIMPLEMENTED();
1240 return false; 1240 return false;
1241 #else 1241 #else
1242 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get()); 1242 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get());
1243 if (omnibox_win) 1243 if (omnibox_win)
1244 return omnibox_win->SkipDefaultKeyEventProcessing(event); 1244 return omnibox_win->SkipDefaultKeyEventProcessing(event);
(...skipping 11 matching lines...) Expand all
1256 state->value = location_entry_->GetText(); 1256 state->value = location_entry_->GetText();
1257 1257
1258 string16::size_type entry_start; 1258 string16::size_type entry_start;
1259 string16::size_type entry_end; 1259 string16::size_type entry_end;
1260 location_entry_->GetSelectionBounds(&entry_start, &entry_end); 1260 location_entry_->GetSelectionBounds(&entry_start, &entry_end);
1261 state->selection_start = entry_start; 1261 state->selection_start = entry_start;
1262 state->selection_end = entry_end; 1262 state->selection_end = entry_end;
1263 } 1263 }
1264 1264
1265 bool LocationBarView::HasFocus() const { 1265 bool LocationBarView::HasFocus() const {
1266 return location_entry_->model()->has_focus(); 1266 return location_entry_->GetModel()->has_focus();
1267 } 1267 }
1268 1268
1269 void LocationBarView::WriteDragDataForView(views::View* sender, 1269 void LocationBarView::WriteDragDataForView(views::View* sender,
1270 const gfx::Point& press_pt, 1270 const gfx::Point& press_pt,
1271 OSExchangeData* data) { 1271 OSExchangeData* data) {
1272 DCHECK_NE(GetDragOperationsForView(sender, press_pt), 1272 DCHECK_NE(GetDragOperationsForView(sender, press_pt),
1273 ui::DragDropTypes::DRAG_NONE); 1273 ui::DragDropTypes::DRAG_NONE);
1274 1274
1275 TabContents* tab_contents = delegate_->GetTabContents(); 1275 TabContents* tab_contents = delegate_->GetTabContents();
1276 DCHECK(tab_contents); 1276 DCHECK(tab_contents);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 template_url_service_ = url_service; 1309 template_url_service_ = url_service;
1310 template_url_service_->AddObserver(this); 1310 template_url_service_->AddObserver(this);
1311 template_url_service_->Load(); 1311 template_url_service_->Load();
1312 return; 1312 return;
1313 } 1313 }
1314 ShowFirstRunBubbleInternal(); 1314 ShowFirstRunBubbleInternal();
1315 } 1315 }
1316 1316
1317 void LocationBarView::SetSuggestedText(const string16& text, 1317 void LocationBarView::SetSuggestedText(const string16& text,
1318 InstantCompleteBehavior behavior) { 1318 InstantCompleteBehavior behavior) {
1319 location_entry_->model()->SetSuggestedText(text, behavior); 1319 location_entry_->GetModel()->SetSuggestedText(text, behavior);
1320 } 1320 }
1321 1321
1322 string16 LocationBarView::GetInputString() const { 1322 string16 LocationBarView::GetInputString() const {
1323 return location_input_; 1323 return location_input_;
1324 } 1324 }
1325 1325
1326 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { 1326 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const {
1327 return disposition_; 1327 return disposition_;
1328 } 1328 }
1329 1329
1330 content::PageTransition LocationBarView::GetPageTransition() const { 1330 content::PageTransition LocationBarView::GetPageTransition() const {
1331 return transition_; 1331 return transition_;
1332 } 1332 }
1333 1333
1334 void LocationBarView::AcceptInput() { 1334 void LocationBarView::AcceptInput() {
1335 location_entry_->model()->AcceptInput(CURRENT_TAB, false); 1335 location_entry_->GetModel()->AcceptInput(CURRENT_TAB, false);
1336 } 1336 }
1337 1337
1338 void LocationBarView::FocusLocation(bool select_all) { 1338 void LocationBarView::FocusLocation(bool select_all) {
1339 location_entry_->SetFocus(); 1339 location_entry_->SetFocus();
1340 if (select_all) 1340 if (select_all)
1341 location_entry_->SelectAll(true); 1341 location_entry_->SelectAll(true);
1342 } 1342 }
1343 1343
1344 void LocationBarView::FocusSearch() { 1344 void LocationBarView::FocusSearch() {
1345 location_entry_->SetFocus(); 1345 location_entry_->SetFocus();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 } 1495 }
1496 1496
1497 void LocationBarView::CleanupFadeAnimation() { 1497 void LocationBarView::CleanupFadeAnimation() {
1498 // Since we're no longer animating we don't need our layer. 1498 // Since we're no longer animating we don't need our layer.
1499 SetPaintToLayer(false); 1499 SetPaintToLayer(false);
1500 // Bubble labels don't need a transparent background anymore. 1500 // Bubble labels don't need a transparent background anymore.
1501 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1501 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1502 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1502 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1503 } 1503 }
1504 #endif // USE_AURA 1504 #endif // USE_AURA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698