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

Side by Side Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 8142026: Revert 104076 - Change std::wstring to string16 for views::Link (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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/views/create_application_shortcut_view.h" 5 #include "chrome/browser/ui/views/create_application_shortcut_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 Init(title, description, icon); 86 Init(title, description, icon);
87 } 87 }
88 88
89 void AppInfoView::Init(const string16& title_text, 89 void AppInfoView::Init(const string16& title_text,
90 const string16& description_text, 90 const string16& description_text,
91 const SkBitmap& icon) { 91 const SkBitmap& icon) {
92 icon_ = new views::ImageView(); 92 icon_ = new views::ImageView();
93 icon_->SetImage(icon); 93 icon_->SetImage(icon);
94 icon_->SetImageSize(gfx::Size(kAppIconSize, kAppIconSize)); 94 icon_->SetImageSize(gfx::Size(kAppIconSize, kAppIconSize));
95 95
96 title_ = new views::Label(title_text); 96 title_ = new views::Label(UTF16ToWide(title_text));
97 title_->SetMultiLine(true); 97 title_->SetMultiLine(true);
98 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 98 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
99 title_->SetFont(ResourceBundle::GetSharedInstance().GetFont( 99 title_->SetFont(ResourceBundle::GetSharedInstance().GetFont(
100 ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD)); 100 ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD));
101 101
102 if (!description_text.empty()) { 102 if (!description_text.empty()) {
103 PrepareDescriptionLabel(description_text); 103 PrepareDescriptionLabel(description_text);
104 } 104 }
105 105
106 SetupLayout(); 106 SetupLayout();
107 } 107 }
108 108
109 void AppInfoView::PrepareDescriptionLabel(const string16& description) { 109 void AppInfoView::PrepareDescriptionLabel(const string16& description) {
110 DCHECK(!description.empty()); 110 DCHECK(!description.empty());
111 111
112 static const size_t kMaxLength = 200; 112 static const size_t kMaxLength = 200;
113 static const string16 kEllipsis(ASCIIToUTF16(" ... ")); 113 static const wchar_t* const kEllipsis = L" ... ";
114 114
115 string16 text = description; 115 std::wstring text = UTF16ToWide(description);
116 if (text.length() > kMaxLength) { 116 if (text.length() > kMaxLength) {
117 text = text.substr(0, kMaxLength); 117 text = text.substr(0, kMaxLength);
118 text += kEllipsis; 118 text += kEllipsis;
119 } 119 }
120 120
121 if (description_) { 121 if (description_) {
122 description_->SetText(text); 122 description_->SetText(text);
123 } else { 123 } else {
124 description_ = new views::Label(text); 124 description_ = new views::Label(text);
125 description_->SetMultiLine(true); 125 description_->SetMultiLine(true);
(...skipping 19 matching lines...) Expand all
145 145
146 if (description_) { 146 if (description_) {
147 layout->StartRow(0, kColumnSetId); 147 layout->StartRow(0, kColumnSetId);
148 layout->SkipColumns(1); 148 layout->SkipColumns(1);
149 layout->AddView(description_); 149 layout->AddView(description_);
150 } 150 }
151 } 151 }
152 152
153 void AppInfoView::UpdateText(const string16& title, 153 void AppInfoView::UpdateText(const string16& title,
154 const string16& description) { 154 const string16& description) {
155 title_->SetText(title); 155 title_->SetText(UTF16ToWideHack(title));
156 PrepareDescriptionLabel(description); 156 PrepareDescriptionLabel(description);
157 157
158 SetupLayout(); 158 SetupLayout();
159 } 159 }
160 160
161 void AppInfoView::UpdateIcon(const SkBitmap& new_icon) { 161 void AppInfoView::UpdateIcon(const SkBitmap& new_icon) {
162 icon_->SetImage(new_icon); 162 icon_->SetImage(new_icon);
163 } 163 }
164 164
165 void AppInfoView::OnPaint(gfx::Canvas* canvas) { 165 void AppInfoView::OnPaint(gfx::Canvas* canvas) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 menu_check_box_(NULL), 242 menu_check_box_(NULL),
243 quick_launch_check_box_(NULL) {} 243 quick_launch_check_box_(NULL) {}
244 244
245 CreateApplicationShortcutView::~CreateApplicationShortcutView() {} 245 CreateApplicationShortcutView::~CreateApplicationShortcutView() {}
246 246
247 void CreateApplicationShortcutView::InitControls() { 247 void CreateApplicationShortcutView::InitControls() {
248 // Create controls 248 // Create controls
249 app_info_ = new AppInfoView(shortcut_info_.title, shortcut_info_.description, 249 app_info_ = new AppInfoView(shortcut_info_.title, shortcut_info_.description,
250 shortcut_info_.favicon); 250 shortcut_info_.favicon);
251 create_shortcuts_label_ = new views::Label( 251 create_shortcuts_label_ = new views::Label(
252 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_LABEL)); 252 UTF16ToWide(l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_LABEL)));
253 create_shortcuts_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 253 create_shortcuts_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
254 254
255 desktop_check_box_ = AddCheckbox(UTF16ToWide( 255 desktop_check_box_ = AddCheckbox(UTF16ToWide(
256 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX)), 256 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX)),
257 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateOnDesktop)); 257 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateOnDesktop));
258 258
259 menu_check_box_ = NULL; 259 menu_check_box_ = NULL;
260 quick_launch_check_box_ = NULL; 260 quick_launch_check_box_ = NULL;
261 261
262 #if defined(OS_WIN) 262 #if defined(OS_WIN)
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Called by tracker_ when the app's icon is loaded. 525 // Called by tracker_ when the app's icon is loaded.
526 void CreateChromeApplicationShortcutView::OnImageLoaded( 526 void CreateChromeApplicationShortcutView::OnImageLoaded(
527 SkBitmap* image, const ExtensionResource& resource, int index) { 527 SkBitmap* image, const ExtensionResource& resource, int index) {
528 if (!image || image->isNull()) 528 if (!image || image->isNull())
529 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON); 529 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON);
530 530
531 shortcut_info_.favicon = *image; 531 shortcut_info_.favicon = *image;
532 CHECK(app_info_); 532 CHECK(app_info_);
533 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 533 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
534 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/content_setting_bubble_contents.cc ('k') | chrome/browser/ui/views/default_search_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698