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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 6256010: Revert 72380 - Remove wstring from autocomplete.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
Property Changes:
Added: svn:mergeinfo
OLDNEW
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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 instant->SetCommitOnMouseUp(); 241 instant->SetCommitOnMouseUp();
242 } else { 242 } else {
243 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); 243 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST);
244 } 244 }
245 } 245 }
246 246
247 void LocationBarViewMac::OnAutocompleteWillAccept() { 247 void LocationBarViewMac::OnAutocompleteWillAccept() {
248 update_instant_ = false; 248 update_instant_ = false;
249 } 249 }
250 250
251 bool LocationBarViewMac::OnCommitSuggestedText(const string16& typed_text) { 251 bool LocationBarViewMac::OnCommitSuggestedText(const std::wstring& typed_text) {
252 return edit_view_->CommitSuggestText(); 252 return edit_view_->CommitSuggestText();
253 } 253 }
254 254
255 bool LocationBarViewMac::AcceptCurrentInstantPreview() { 255 bool LocationBarViewMac::AcceptCurrentInstantPreview() {
256 return InstantController::CommitIfCurrent(browser_->instant()); 256 return InstantController::CommitIfCurrent(browser_->instant());
257 } 257 }
258 258
259 void LocationBarViewMac::OnPopupBoundsChanged(const gfx::Rect& bounds) { 259 void LocationBarViewMac::OnPopupBoundsChanged(const gfx::Rect& bounds) {
260 InstantController* instant = browser_->instant(); 260 InstantController* instant = browser_->instant();
261 if (instant) 261 if (instant)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 Layout(); 310 Layout();
311 311
312 InstantController* instant = browser_->instant(); 312 InstantController* instant = browser_->instant();
313 string16 suggested_text; 313 string16 suggested_text;
314 if (update_instant_ && instant && GetTabContents()) { 314 if (update_instant_ && instant && GetTabContents()) {
315 if (edit_view_->model()->user_input_in_progress() && 315 if (edit_view_->model()->user_input_in_progress() &&
316 edit_view_->model()->popup_model()->IsOpen()) { 316 edit_view_->model()->popup_model()->IsOpen()) {
317 instant->Update 317 instant->Update
318 (browser_->GetSelectedTabContentsWrapper(), 318 (browser_->GetSelectedTabContentsWrapper(),
319 edit_view_->model()->CurrentMatch(), 319 edit_view_->model()->CurrentMatch(),
320 edit_view_->GetText(), 320 WideToUTF16(edit_view_->GetText()),
321 edit_view_->model()->UseVerbatimInstant(), 321 edit_view_->model()->UseVerbatimInstant(),
322 &suggested_text); 322 &suggested_text);
323 if (!instant->MightSupportInstant()) { 323 if (!instant->MightSupportInstant()) {
324 edit_view_->model()->FinalizeInstantQuery(string16(), 324 edit_view_->model()->FinalizeInstantQuery(std::wstring(),
325 string16()); 325 std::wstring());
326 } 326 }
327 } else { 327 } else {
328 instant->DestroyPreviewContents(); 328 instant->DestroyPreviewContents();
329 edit_view_->model()->FinalizeInstantQuery(string16(), 329 edit_view_->model()->FinalizeInstantQuery(std::wstring(),
330 string16()); 330 std::wstring());
331 } 331 }
332 } 332 }
333 333
334 SetSuggestedText(suggested_text); 334 SetSuggestedText(suggested_text);
335 } 335 }
336 336
337 void LocationBarViewMac::OnSelectionBoundsChanged() { 337 void LocationBarViewMac::OnSelectionBoundsChanged() {
338 NOTIMPLEMENTED(); 338 NOTIMPLEMENTED();
339 } 339 }
340 340
341 void LocationBarViewMac::OnInputInProgress(bool in_progress) { 341 void LocationBarViewMac::OnInputInProgress(bool in_progress) {
342 toolbar_model_->set_input_in_progress(in_progress); 342 toolbar_model_->set_input_in_progress(in_progress);
343 Update(NULL, false); 343 Update(NULL, false);
344 } 344 }
345 345
346 void LocationBarViewMac::OnSetFocus() { 346 void LocationBarViewMac::OnSetFocus() {
347 // Update the keyword and search hint states. 347 // Update the keyword and search hint states.
348 OnChanged(); 348 OnChanged();
349 } 349 }
350 350
351 void LocationBarViewMac::OnKillFocus() { 351 void LocationBarViewMac::OnKillFocus() {
352 // Do nothing. 352 // Do nothing.
353 } 353 }
354 354
355 SkBitmap LocationBarViewMac::GetFavIcon() const { 355 SkBitmap LocationBarViewMac::GetFavIcon() const {
356 NOTIMPLEMENTED(); 356 NOTIMPLEMENTED();
357 return SkBitmap(); 357 return SkBitmap();
358 } 358 }
359 359
360 string16 LocationBarViewMac::GetTitle() const { 360 std::wstring LocationBarViewMac::GetTitle() const {
361 NOTIMPLEMENTED(); 361 NOTIMPLEMENTED();
362 return string16(); 362 return std::wstring();
363 } 363 }
364 364
365 void LocationBarViewMac::Revert() { 365 void LocationBarViewMac::Revert() {
366 edit_view_->RevertAll(); 366 edit_view_->RevertAll();
367 } 367 }
368 368
369 // TODO(pamg): Change all these, here and for other platforms, to size_t. 369 // TODO(pamg): Change all these, here and for other platforms, to size_t.
370 int LocationBarViewMac::PageActionCount() { 370 int LocationBarViewMac::PageActionCount() {
371 return static_cast<int>(page_action_decorations_.size()); 371 return static_cast<int>(page_action_decorations_.size());
372 } 372 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } else { 513 } else {
514 const NSRect frame = 514 const NSRect frame =
515 [cell frameForDecoration:location_icon_decoration_.get() 515 [cell frameForDecoration:location_icon_decoration_.get()
516 inFrame:[field_ bounds]]; 516 inFrame:[field_ bounds]];
517 const NSPoint point = 517 const NSPoint point =
518 location_icon_decoration_->GetBubblePointInFrame(frame); 518 location_icon_decoration_->GetBubblePointInFrame(frame);
519 return [field_ convertPoint:point toView:nil]; 519 return [field_ convertPoint:point toView:nil];
520 } 520 }
521 } 521 }
522 522
523 NSImage* LocationBarViewMac::GetKeywordImage(const string16& keyword) { 523 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) {
524 const TemplateURL* template_url = 524 const TemplateURL* template_url =
525 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); 525 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
526 WideToUTF16Hack(keyword));
526 if (template_url && template_url->IsExtensionKeyword()) { 527 if (template_url && template_url->IsExtensionKeyword()) {
527 const SkBitmap& bitmap = profile_->GetExtensionService()-> 528 const SkBitmap& bitmap = profile_->GetExtensionService()->
528 GetOmniboxIcon(template_url->GetExtensionId()); 529 GetOmniboxIcon(template_url->GetExtensionId());
529 return gfx::SkBitmapToNSImage(bitmap); 530 return gfx::SkBitmapToNSImage(bitmap);
530 } 531 }
531 532
532 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); 533 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
533 } 534 }
534 535
535 void LocationBarViewMac::Observe(NotificationType type, 536 void LocationBarViewMac::Observe(NotificationType type,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 644
644 [cell addRightDecoration:keyword_hint_decoration_.get()]; 645 [cell addRightDecoration:keyword_hint_decoration_.get()];
645 646
646 // By default only the location icon is visible. 647 // By default only the location icon is visible.
647 location_icon_decoration_->SetVisible(true); 648 location_icon_decoration_->SetVisible(true);
648 selected_keyword_decoration_->SetVisible(false); 649 selected_keyword_decoration_->SetVisible(false);
649 ev_bubble_decoration_->SetVisible(false); 650 ev_bubble_decoration_->SetVisible(false);
650 keyword_hint_decoration_->SetVisible(false); 651 keyword_hint_decoration_->SetVisible(false);
651 652
652 // Get the keyword to use for keyword-search and hinting. 653 // Get the keyword to use for keyword-search and hinting.
653 const string16 keyword = edit_view_->model()->keyword(); 654 const std::wstring keyword(edit_view_->model()->keyword());
654 string16 short_name; 655 string16 short_name;
655 bool is_extension_keyword = false; 656 bool is_extension_keyword = false;
656 if (!keyword.empty()) { 657 if (!keyword.empty()) {
657 short_name = profile_->GetTemplateURLModel()-> 658 short_name = profile_->GetTemplateURLModel()->
658 GetKeywordShortName(keyword, &is_extension_keyword); 659 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
659 } 660 }
660 661
661 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint(); 662 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint();
662 663
663 if (!keyword.empty() && !is_keyword_hint) { 664 if (!keyword.empty() && !is_keyword_hint) {
664 // Switch from location icon to keyword mode. 665 // Switch from location icon to keyword mode.
665 location_icon_decoration_->SetVisible(false); 666 location_icon_decoration_->SetVisible(false);
666 selected_keyword_decoration_->SetVisible(true); 667 selected_keyword_decoration_->SetVisible(true);
667 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); 668 selected_keyword_decoration_->SetKeyword(UTF16ToWideHack(short_name),
669 is_extension_keyword);
668 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); 670 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
669 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { 671 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
670 // Switch from location icon to show the EV bubble instead. 672 // Switch from location icon to show the EV bubble instead.
671 location_icon_decoration_->SetVisible(false); 673 location_icon_decoration_->SetVisible(false);
672 ev_bubble_decoration_->SetVisible(true); 674 ev_bubble_decoration_->SetVisible(true);
673 675
674 std::wstring label(toolbar_model_->GetEVCertName()); 676 std::wstring label(toolbar_model_->GetEVCertName());
675 ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label)); 677 ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label));
676 } else if (!keyword.empty() && is_keyword_hint) { 678 } else if (!keyword.empty() && is_keyword_hint) {
677 keyword_hint_decoration_->SetKeyword(short_name, 679 keyword_hint_decoration_->SetKeyword(short_name,
678 is_extension_keyword); 680 is_extension_keyword);
679 keyword_hint_decoration_->SetVisible(true); 681 keyword_hint_decoration_->SetVisible(true);
680 } 682 }
681 683
682 // These need to change anytime the layout changes. 684 // These need to change anytime the layout changes.
683 // TODO(shess): Anytime the field editor might have changed, the 685 // TODO(shess): Anytime the field editor might have changed, the
684 // cursor rects almost certainly should have changed. The tooltips 686 // cursor rects almost certainly should have changed. The tooltips
685 // might change even when the rects don't change. 687 // might change even when the rects don't change.
686 [field_ resetFieldEditorFrameIfNeeded]; 688 [field_ resetFieldEditorFrameIfNeeded];
687 [field_ updateCursorAndToolTipRects]; 689 [field_ updateCursorAndToolTipRects];
688 690
689 [field_ setNeedsDisplay:YES]; 691 [field_ setNeedsDisplay:YES];
690 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698