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

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

Issue 6278007: Remove wstring from TemplateURL and friends.... (Closed) Base URL: svn://chrome-svn/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
OLDNEW
1 // Copyright (c) 2010 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 "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 [cell frameForDecoration:location_icon_decoration_.get() 520 [cell frameForDecoration:location_icon_decoration_.get()
521 inFrame:[field_ bounds]]; 521 inFrame:[field_ bounds]];
522 const NSPoint point = 522 const NSPoint point =
523 location_icon_decoration_->GetBubblePointInFrame(frame); 523 location_icon_decoration_->GetBubblePointInFrame(frame);
524 return [field_ convertPoint:point toView:nil]; 524 return [field_ convertPoint:point toView:nil];
525 } 525 }
526 } 526 }
527 527
528 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) { 528 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) {
529 const TemplateURL* template_url = 529 const TemplateURL* template_url =
530 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); 530 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
531 WideToUTF16Hack(keyword));
531 if (template_url && template_url->IsExtensionKeyword()) { 532 if (template_url && template_url->IsExtensionKeyword()) {
532 const SkBitmap& bitmap = profile_->GetExtensionService()-> 533 const SkBitmap& bitmap = profile_->GetExtensionService()->
533 GetOmniboxIcon(template_url->GetExtensionId()); 534 GetOmniboxIcon(template_url->GetExtensionId());
534 return gfx::SkBitmapToNSImage(bitmap); 535 return gfx::SkBitmapToNSImage(bitmap);
535 } 536 }
536 537
537 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); 538 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
538 } 539 }
539 540
540 void LocationBarViewMac::Observe(NotificationType type, 541 void LocationBarViewMac::Observe(NotificationType type,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 [cell addRightDecoration:keyword_hint_decoration_.get()]; 650 [cell addRightDecoration:keyword_hint_decoration_.get()];
650 651
651 // By default only the location icon is visible. 652 // By default only the location icon is visible.
652 location_icon_decoration_->SetVisible(true); 653 location_icon_decoration_->SetVisible(true);
653 selected_keyword_decoration_->SetVisible(false); 654 selected_keyword_decoration_->SetVisible(false);
654 ev_bubble_decoration_->SetVisible(false); 655 ev_bubble_decoration_->SetVisible(false);
655 keyword_hint_decoration_->SetVisible(false); 656 keyword_hint_decoration_->SetVisible(false);
656 657
657 // Get the keyword to use for keyword-search and hinting. 658 // Get the keyword to use for keyword-search and hinting.
658 const std::wstring keyword(edit_view_->model()->keyword()); 659 const std::wstring keyword(edit_view_->model()->keyword());
659 std::wstring short_name; 660 string16 short_name;
660 bool is_extension_keyword = false; 661 bool is_extension_keyword = false;
661 if (!keyword.empty()) { 662 if (!keyword.empty()) {
662 short_name = profile_->GetTemplateURLModel()-> 663 short_name = profile_->GetTemplateURLModel()->
663 GetKeywordShortName(keyword, &is_extension_keyword); 664 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
664 } 665 }
665 666
666 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint(); 667 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint();
667 668
668 if (!keyword.empty() && !is_keyword_hint) { 669 if (!keyword.empty() && !is_keyword_hint) {
669 // Switch from location icon to keyword mode. 670 // Switch from location icon to keyword mode.
670 location_icon_decoration_->SetVisible(false); 671 location_icon_decoration_->SetVisible(false);
671 selected_keyword_decoration_->SetVisible(true); 672 selected_keyword_decoration_->SetVisible(true);
672 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); 673 selected_keyword_decoration_->SetKeyword(UTF16ToWideHack(short_name),
674 is_extension_keyword);
673 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); 675 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
674 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { 676 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
675 // Switch from location icon to show the EV bubble instead. 677 // Switch from location icon to show the EV bubble instead.
676 location_icon_decoration_->SetVisible(false); 678 location_icon_decoration_->SetVisible(false);
677 ev_bubble_decoration_->SetVisible(true); 679 ev_bubble_decoration_->SetVisible(true);
678 680
679 std::wstring label(toolbar_model_->GetEVCertName()); 681 std::wstring label(toolbar_model_->GetEVCertName());
680 ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label)); 682 ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label));
681 } else if (!keyword.empty() && is_keyword_hint) { 683 } else if (!keyword.empty() && is_keyword_hint) {
682 keyword_hint_decoration_->SetKeyword(WideToUTF16Hack(short_name), 684 keyword_hint_decoration_->SetKeyword(short_name,
683 is_extension_keyword); 685 is_extension_keyword);
684 keyword_hint_decoration_->SetVisible(true); 686 keyword_hint_decoration_->SetVisible(true);
685 } 687 }
686 688
687 // These need to change anytime the layout changes. 689 // These need to change anytime the layout changes.
688 // TODO(shess): Anytime the field editor might have changed, the 690 // TODO(shess): Anytime the field editor might have changed, the
689 // cursor rects almost certainly should have changed. The tooltips 691 // cursor rects almost certainly should have changed. The tooltips
690 // might change even when the rects don't change. 692 // might change even when the rects don't change.
691 [field_ resetFieldEditorFrameIfNeeded]; 693 [field_ resetFieldEditorFrameIfNeeded];
692 [field_ updateCursorAndToolTipRects]; 694 [field_ updateCursorAndToolTipRects];
693 695
694 [field_ setNeedsDisplay:YES]; 696 [field_ setNeedsDisplay:YES];
695 } 697 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init.cc ('k') | chrome/browser/ui/cocoa/options/edit_search_engine_cocoa_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698