OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chooser_content_view_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/browser/chooser_controller/chooser_controller.h" | 11 #include "chrome/browser/chooser_controller/chooser_controller.h" |
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
13 #include "chrome/browser/ui/cocoa/spinner_view.h" | 13 #include "chrome/browser/ui/cocoa/spinner_view.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "skia/ext/skia_utils_mac.h" | 15 #include "skia/ext/skia_utils_mac.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 void ChooserContentViewController::UpdateTableView() { | 382 void ChooserContentViewController::UpdateTableView() { |
383 [table_view_ setEnabled:chooser_controller_->NumOptions() > 0]; | 383 [table_view_ setEnabled:chooser_controller_->NumOptions() > 0]; |
384 // For NSView-based table views, calling reloadData will deselect the | 384 // For NSView-based table views, calling reloadData will deselect the |
385 // currently selected row, so |selected_rows| stores the currently selected | 385 // currently selected row, so |selected_rows| stores the currently selected |
386 // rows in order to select them again. | 386 // rows in order to select them again. |
387 NSIndexSet* selected_rows = [table_view_ selectedRowIndexes]; | 387 NSIndexSet* selected_rows = [table_view_ selectedRowIndexes]; |
388 [table_view_ reloadData]; | 388 [table_view_ reloadData]; |
389 [table_view_ selectRowIndexes:selected_rows byExtendingSelection:NO]; | 389 [table_view_ selectRowIndexes:selected_rows byExtendingSelection:NO]; |
390 } | 390 } |
391 | 391 |
392 @implementation ChooserContentViewCocoa | 392 @implementation DeviceChooserContentViewCocoa |
393 | 393 |
394 // TODO(juncai): restructure this function to be some smaller methods to | |
395 // create the pieces for the view. By doing so, the methods that calculate | |
396 // the frame and origins can be moved into those methods, rather than as | |
397 // helper functions. | |
398 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle | 394 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle |
399 chooserController: | 395 chooserController: |
400 (std::unique_ptr<ChooserController>)chooserController { | 396 (std::unique_ptr<ChooserController>)chooserController { |
401 // ------------------------------------ | 397 // ------------------------------------ |
402 // | Chooser title | | 398 // | Chooser title | |
403 // | -------------------------------- | | 399 // | -------------------------------- | |
404 // | | option 0 | | | 400 // | | option 0 | | |
405 // | | option 1 | | | 401 // | | option 1 | | |
406 // | | option 2 | | | 402 // | | option 2 | | |
407 // | | | | | 403 // | | | | |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 | 900 |
905 - (void)drawRect:(NSRect)rect { | 901 - (void)drawRect:(NSRect)rect { |
906 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; | 902 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; |
907 NSRect footnoteFrame = | 903 NSRect footnoteFrame = |
908 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); | 904 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); |
909 NSRectFill(footnoteFrame); | 905 NSRectFill(footnoteFrame); |
910 [super drawRect:footnoteFrame]; | 906 [super drawRect:footnoteFrame]; |
911 } | 907 } |
912 | 908 |
913 @end | 909 @end |
OLD | NEW |