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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/device_permissions_view_controller.mm

Issue 2390823005: Update device permissions dialog ui for Chrome apps and extensions (Closed)
Patch Set: address more comments Created 4 years 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "base/mac/bundle_locations.h"
6 #include "base/strings/sys_string_conversions.h"
7 #import "chrome/browser/ui/cocoa/extensions/device_permissions_dialog_controller .h"
8 #import "chrome/browser/ui/cocoa/extensions/device_permissions_view_controller.h "
9 #include "chrome/grit/generated_resources.h"
10 #include "components/strings/grit/components_strings.h"
11 #import "ui/base/l10n/l10n_util_mac.h"
12
13 using extensions::DevicePermissionsPrompt;
14
15 @implementation DevicePermissionsViewController
16
17 - (id)initWithController:(DevicePermissionsDialogController*)controller
18 prompt:
19 (scoped_refptr<DevicePermissionsPrompt::Prompt>)prompt {
20 if ((self = [super initWithNibName:@"DevicePermissionsPrompt"
21 bundle:base::mac::FrameworkBundle()])) {
22 controller_ = controller;
23 prompt_ = prompt;
24 }
25 return self;
26 }
27
28 - (IBAction)cancel:(id)sender {
29 controller_->Dismissed();
30 }
31
32 - (IBAction)ok:(id)sender {
33 [[tableView_ selectedRowIndexes]
34 enumerateIndexesUsingBlock:^(NSUInteger index, BOOL* stop) {
35 prompt_->GrantDevicePermission(index);
36 }];
37 controller_->Dismissed();
38 }
39
40 - (void)devicesChanged {
41 [tableView_ reloadData];
42 }
43
44 - (void)awakeFromNib {
45 [titleField_ setStringValue:base::SysUTF16ToNSString(prompt_->GetHeading())];
46 [promptField_
47 setStringValue:base::SysUTF16ToNSString(prompt_->GetPromptMessage())];
48 [tableView_ setAllowsMultipleSelection:prompt_->multiple()];
49 [tableView_ setDelegate:self];
50 [tableView_ setDataSource:self];
51 [[deviceNameColumn_ headerCell]
52 setStringValue:l10n_util::GetNSString(
53 IDS_DEVICE_PERMISSIONS_DIALOG_DEVICE_NAME_COLUMN)];
54 [[serialNumberColumn_ headerCell]
55 setStringValue:l10n_util::GetNSString(
56 IDS_DEVICE_PERMISSIONS_DIALOG_SERIAL_NUMBER_COLUMN)];
57 [okButton_
58 setTitle:l10n_util::GetNSString(IDS_DEVICE_PERMISSIONS_DIALOG_SELECT)];
59 [okButton_ setEnabled:NO];
60 [cancelButton_ setTitle:l10n_util::GetNSString(IDS_CANCEL)];
61 }
62
63 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView {
64 DCHECK_EQ(tableView_, tableView);
65 return prompt_->GetDeviceCount();
66 }
67
68 - (id)tableView:(NSTableView*)tableView
69 objectValueForTableColumn:(NSTableColumn*)tableColumn
70 row:(NSInteger)rowIndex {
71 if (tableColumn == deviceNameColumn_) {
72 return base::SysUTF16ToNSString(prompt_->GetDeviceName(rowIndex));
73 } else if (tableColumn == serialNumberColumn_) {
74 return base::SysUTF16ToNSString(prompt_->GetDeviceSerialNumber(rowIndex));
75 } else {
76 NOTREACHED();
77 return @"";
78 }
79 }
80
81 - (void)tableViewSelectionDidChange:(NSNotification*)aNotification {
82 [okButton_ setEnabled:[tableView_ numberOfSelectedRows] > 0];
83 }
84
85 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698