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

Side by Side Diff: chrome/browser/ui/omnibox/location_bar_util.cc

Issue 7669040: content: Move render_widget_host_view_gtk to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos fix. Created 9 years, 4 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) 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 #include "chrome/browser/ui/omnibox/location_bar_util.h" 5 #include "chrome/browser/ui/omnibox/location_bar_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
11 #include "chrome/browser/search_engines/template_url_service.h" 11 #include "chrome/browser/search_engines/template_url_service.h"
12 #include "chrome/browser/search_engines/template_url_service_factory.h" 12 #include "chrome/browser/search_engines/template_url_service_factory.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/text/text_elider.h"
14 15
15 namespace location_bar_util { 16 namespace location_bar_util {
16 17
17 std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) { 18 std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) {
18 // Make sure the TemplateURL still exists. 19 // Make sure the TemplateURL still exists.
19 // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService 20 // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService
20 // to track changes to the model, this should become a DCHECK. 21 // to track changes to the model, this should become a DCHECK.
21 const TemplateURL* template_url = 22 const TemplateURL* template_url =
22 TemplateURLServiceFactory::GetForProfile(profile)-> 23 TemplateURLServiceFactory::GetForProfile(profile)->
23 GetTemplateURLForKeyword(WideToUTF16Hack(keyword)); 24 GetTemplateURLForKeyword(WideToUTF16Hack(keyword));
24 if (template_url) 25 if (template_url)
25 return UTF16ToWideHack(template_url->AdjustedShortNameForLocaleDirection()); 26 return UTF16ToWideHack(template_url->AdjustedShortNameForLocaleDirection());
26 return std::wstring(); 27 return std::wstring();
27 } 28 }
28 29
29 std::wstring CalculateMinString(const std::wstring& description) { 30 std::wstring CalculateMinString(const std::wstring& description) {
30 // Chop at the first '.' or whitespace. 31 // Chop at the first '.' or whitespace.
31 const size_t dot_index = description.find('.'); 32 const size_t dot_index = description.find('.');
32 const size_t ws_index = description.find_first_of(kWhitespaceWide); 33 const size_t ws_index = description.find_first_of(kWhitespaceWide);
33 size_t chop_index = std::min(dot_index, ws_index); 34 size_t chop_index = std::min(dot_index, ws_index);
34 string16 min_string; 35 string16 min_string;
35 if (chop_index == std::wstring::npos) { 36 if (chop_index == std::wstring::npos) {
36 // No dot or whitespace, truncate to at most 3 chars. 37 // No dot or whitespace, truncate to at most 3 chars.
37 min_string = l10n_util::TruncateString(WideToUTF16Hack(description), 3); 38 min_string = ui::TruncateString(WideToUTF16Hack(description), 3);
38 } else { 39 } else {
39 min_string = WideToUTF16(description.substr(0, chop_index)); 40 min_string = WideToUTF16(description.substr(0, chop_index));
40 } 41 }
41 base::i18n::AdjustStringForLocaleDirection(&min_string); 42 base::i18n::AdjustStringForLocaleDirection(&min_string);
42 return UTF16ToWide(min_string); 43 return UTF16ToWide(min_string);
43 } 44 }
44 45
45 } // namespace location_bar_util 46 } // namespace location_bar_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | chrome/browser/ui/views/extensions/extension_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698