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

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

Issue 245009: L10N pass through download item and download shelf.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/download_item_controller.h" 5 #import "chrome/browser/cocoa/download_item_controller.h"
6 6
7 #include "app/gfx/text_elider.h" 7 #include "app/gfx/text_elider.h"
8 #include "app/l10n_util_mac.h" 8 #include "app/l10n_util_mac.h"
9 #include "base/mac_util.h" 9 #include "base/mac_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #import "chrome/browser/cocoa/download_item_cell.h" 11 #import "chrome/browser/cocoa/download_item_cell.h"
12 #include "chrome/browser/cocoa/download_item_mac.h" 12 #include "chrome/browser/cocoa/download_item_mac.h"
13 #import "chrome/browser/cocoa/download_shelf_controller.h" 13 #import "chrome/browser/cocoa/download_shelf_controller.h"
14 #include "chrome/browser/download/download_item_model.h" 14 #include "chrome/browser/download/download_item_model.h"
15 #include "chrome/browser/download/download_shelf.h" 15 #include "chrome/browser/download/download_shelf.h"
16 #include "chrome/browser/download/download_util.h" 16 #include "chrome/browser/download/download_util.h"
17 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
18 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
18 19
19 static const int kTextWidth = 140; // Pixels 20 static const int kTextWidth = 140; // Pixels
20 21
22 namespace {
23
24 // Helper to widen a view.
25 void WidenView(NSView* view, CGFloat widthChange) {
26 // If it is an NSBox, the autoresize of the contentView is the issue.
27 NSView* contentView = view;
28 if ([view isKindOfClass:[NSBox class]]) {
29 contentView = [(NSBox*)view contentView];
30 }
31 BOOL autoresizesSubviews = [contentView autoresizesSubviews];
32 if (autoresizesSubviews) {
33 [contentView setAutoresizesSubviews:NO];
34 }
35
36 NSRect frame = [view frame];
37 frame.size.width += widthChange;
38 [view setFrame:frame];
39
40 if (autoresizesSubviews) {
41 [contentView setAutoresizesSubviews:YES];
42 }
43 }
44
45 } // namespace
46
21 // A class for the chromium-side part of the download shelf context menu. 47 // A class for the chromium-side part of the download shelf context menu.
22 48
23 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { 49 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
24 public: 50 public:
25 DownloadShelfContextMenuMac(BaseDownloadItemModel* model) 51 DownloadShelfContextMenuMac(BaseDownloadItemModel* model)
26 : DownloadShelfContextMenu(model) { } 52 : DownloadShelfContextMenu(model) { }
27 53
28 using DownloadShelfContextMenu::ExecuteItemCommand; 54 using DownloadShelfContextMenu::ExecuteItemCommand;
29 using DownloadShelfContextMenu::ItemIsChecked; 55 using DownloadShelfContextMenu::ItemIsChecked;
30 using DownloadShelfContextMenu::IsItemCommandEnabled; 56 using DownloadShelfContextMenu::IsItemCommandEnabled;
(...skipping 28 matching lines...) Expand all
59 return self; 85 return self;
60 } 86 }
61 87
62 - (void)dealloc { 88 - (void)dealloc {
63 [[NSNotificationCenter defaultCenter] removeObserver:self]; 89 [[NSNotificationCenter defaultCenter] removeObserver:self];
64 [[self view] removeFromSuperview]; 90 [[self view] removeFromSuperview];
65 [super dealloc]; 91 [super dealloc];
66 } 92 }
67 93
68 - (void)awakeFromNib { 94 - (void)awakeFromNib {
95 // Since the shelf keeps relaying out views as more items are added, relaying
Mark Mentovai 2009/09/25 20:20:41 "relaying" 1: "relaying" means something other tha
96 // on the WidthBaseTweaker to resize the dangerous download part does not
97 // work.
98 DCHECK(buttonTweaker_ != nil);
99 CGFloat widthChange = [buttonTweaker_ changedWidth];
100 // Grow the parent views
101 WidenView([self view], widthChange);
102 WidenView(dangerousDownloadView_, widthChange);
103 // Slide the two buttons over.
104 NSPoint frameOrigin = [buttonTweaker_ frame].origin;
105 frameOrigin.x += widthChange;
106 [buttonTweaker_ setFrameOrigin:frameOrigin];
107
69 [self setStateFromDownload:bridge_->download_model()]; 108 [self setStateFromDownload:bridge_->download_model()];
70 bridge_->LoadIcon(); 109 bridge_->LoadIcon();
71 } 110 }
72 111
73 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel { 112 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel {
74 DCHECK_EQ(bridge_->download_model(), downloadModel); 113 DCHECK_EQ(bridge_->download_model(), downloadModel);
75 114
76 // Handle dangerous downloads. 115 // Handle dangerous downloads.
77 if (downloadModel->download()->safety_state() == DownloadItem::DANGEROUS) { 116 if (downloadModel->download()->safety_state() == DownloadItem::DANGEROUS) {
78 [self setState:kDangerous]; 117 [self setState:kDangerous];
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 271
233 - (IBAction)handleRemove:(id)sender { 272 - (IBAction)handleRemove:(id)sender {
234 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::REMOVE_ITEM); 273 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::REMOVE_ITEM);
235 } 274 }
236 275
237 - (IBAction)handleCancel:(id)sender { 276 - (IBAction)handleCancel:(id)sender {
238 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::CANCEL); 277 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::CANCEL);
239 } 278 }
240 279
241 @end 280 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698