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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_item_controller.mm

Issue 6257006: Move a bunch of random other files to src/ui/base... (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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/download/download_item_controller.h" 5 #import "chrome/browser/ui/cocoa/download/download_item_controller.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 "app/text_elider.h"
10 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
11 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
12 #include "base/string16.h" 11 #include "base/string16.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
14 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
15 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/download/download_item.h" 15 #include "chrome/browser/download/download_item.h"
17 #include "chrome/browser/download/download_item_model.h" 16 #include "chrome/browser/download/download_item_model.h"
18 #include "chrome/browser/download/download_shelf.h" 17 #include "chrome/browser/download/download_shelf.h"
19 #include "chrome/browser/download/download_util.h" 18 #include "chrome/browser/download/download_util.h"
20 #import "chrome/browser/themes/browser_theme_provider.h" 19 #import "chrome/browser/themes/browser_theme_provider.h"
21 #import "chrome/browser/ui/cocoa/download/download_item_button.h" 20 #import "chrome/browser/ui/cocoa/download/download_item_button.h"
22 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" 21 #import "chrome/browser/ui/cocoa/download/download_item_cell.h"
23 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" 22 #include "chrome/browser/ui/cocoa/download/download_item_mac.h"
24 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 23 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
25 #import "chrome/browser/ui/cocoa/themed_window.h" 24 #import "chrome/browser/ui/cocoa/themed_window.h"
26 #import "chrome/browser/ui/cocoa/ui_localizer.h" 25 #import "chrome/browser/ui/cocoa/ui_localizer.h"
27 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
28 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
29 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 28 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
29 #include "ui/base/text/text_elider.h"
30 30
31 namespace { 31 namespace {
32 32
33 // NOTE: Mac currently doesn't use this like Windows does. Mac uses this to 33 // NOTE: Mac currently doesn't use this like Windows does. Mac uses this to
34 // control the min size on the dangerous download text. TVL sent a query off to 34 // control the min size on the dangerous download text. TVL sent a query off to
35 // UX to fully spec all the the behaviors of download items and truncations 35 // UX to fully spec all the the behaviors of download items and truncations
36 // rules so all platforms can get inline in the future. 36 // rules so all platforms can get inline in the future.
37 const int kTextWidth = 140; // Pixels 37 const int kTextWidth = 140; // Pixels
38 38
39 // The maximum number of characters we show in a file name when displaying the 39 // The maximum number of characters we show in a file name when displaying the
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 FilePath filename(downloadModel->download()->target_name()); 184 FilePath filename(downloadModel->download()->target_name());
185 FilePath::StringType extension = filename.Extension(); 185 FilePath::StringType extension = filename.Extension();
186 186
187 // Remove leading '.' from the extension 187 // Remove leading '.' from the extension
188 if (extension.length() > 0) 188 if (extension.length() > 0)
189 extension = extension.substr(1); 189 extension = extension.substr(1);
190 190
191 // Elide giant extensions. 191 // Elide giant extensions.
192 if (extension.length() > kFileNameMaxLength / 2) { 192 if (extension.length() > kFileNameMaxLength / 2) {
193 std::wstring wide_extension; 193 std::wstring wide_extension;
194 gfx::ElideString(UTF8ToWide(extension), kFileNameMaxLength / 2, 194 ui::ElideString(UTF8ToWide(extension), kFileNameMaxLength / 2,
195 &wide_extension); 195 &wide_extension);
196 extension = WideToUTF8(wide_extension); 196 extension = WideToUTF8(wide_extension);
197 } 197 }
198 198
199 // Rebuild the filename.extension. 199 // Rebuild the filename.extension.
200 std::wstring rootname = UTF8ToWide(filename.RemoveExtension().value()); 200 std::wstring rootname = UTF8ToWide(filename.RemoveExtension().value());
201 gfx::ElideString(rootname, kFileNameMaxLength - extension.length(), 201 ui::ElideString(rootname, kFileNameMaxLength - extension.length(),
202 &rootname); 202 &rootname);
203 std::string new_filename = WideToUTF8(rootname); 203 std::string new_filename = WideToUTF8(rootname);
204 if (extension.length()) 204 if (extension.length())
205 new_filename += std::string(".") + extension; 205 new_filename += std::string(".") + extension;
206 206
207 dangerousWarning = l10n_util::GetNSStringFWithFixup( 207 dangerousWarning = l10n_util::GetNSStringFWithFixup(
208 IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename)); 208 IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename));
209 confirmButtonTitle = l10n_util::GetNSStringWithFixup(IDS_SAVE_DOWNLOAD); 209 confirmButtonTitle = l10n_util::GetNSStringWithFixup(IDS_SAVE_DOWNLOAD);
210 } 210 }
211 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; 211 [dangerousDownloadLabel_ setStringValue:dangerousWarning];
212 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; 212 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle];
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return [progressView_ frame].size; 262 return [progressView_ frame].size;
263 DCHECK_EQ(kDangerous, state_); 263 DCHECK_EQ(kDangerous, state_);
264 return [dangerousDownloadView_ frame].size; 264 return [dangerousDownloadView_ frame].size;
265 } 265 }
266 266
267 - (DownloadItem*)download { 267 - (DownloadItem*)download {
268 return bridge_->download_model()->download(); 268 return bridge_->download_model()->download();
269 } 269 }
270 270
271 - (void)updateToolTip { 271 - (void)updateToolTip {
272 string16 elidedFilename = gfx::ElideFilename( 272 string16 elidedFilename = ui::ElideFilename(
273 [self download]->GetFileNameToReportUser(), 273 [self download]->GetFileNameToReportUser(),
274 gfx::Font(), kToolTipMaxWidth); 274 gfx::Font(), kToolTipMaxWidth);
275 [progressView_ setToolTip:base::SysUTF16ToNSString(elidedFilename)]; 275 [progressView_ setToolTip:base::SysUTF16ToNSString(elidedFilename)];
276 } 276 }
277 277
278 - (void)clearDangerousMode { 278 - (void)clearDangerousMode {
279 [self setState:kNormal]; 279 [self setState:kNormal];
280 // The state change hide the dangerouse download view and is now showing the 280 // The state change hide the dangerouse download view and is now showing the
281 // download progress view. This means the view is likely to be a different 281 // download progress view. This means the view is likely to be a different
282 // size, so trigger a shelf layout to fix up spacing. 282 // size, so trigger a shelf layout to fix up spacing.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 [sender setTitle:l10n_util::GetNSStringWithFixup( 392 [sender setTitle:l10n_util::GetNSStringWithFixup(
393 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; 393 IDS_DOWNLOAD_MENU_PAUSE_ITEM)];
394 } else { 394 } else {
395 [sender setTitle:l10n_util::GetNSStringWithFixup( 395 [sender setTitle:l10n_util::GetNSStringWithFixup(
396 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; 396 IDS_DOWNLOAD_MENU_RESUME_ITEM)];
397 } 397 }
398 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); 398 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE);
399 } 399 }
400 400
401 @end 401 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_item_cell.mm ('k') | chrome/browser/ui/cocoa/external_protocol_dialog.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698