Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" // IDC_* | 9 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 10 #include "chrome/browser/themes/theme_service.h" | |
| 10 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 14 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 15 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 16 #import "ui/base/cocoa/find_pasteboard.h" | 17 #import "ui/base/cocoa/find_pasteboard.h" |
| 17 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
| 19 #include "ui/base/material_design/material_design_controller.h" | |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 // When too much data is put into a single-line text field, things get | 23 // When too much data is put into a single-line text field, things get |
| 22 // janky due to the cost of computing the blink rect. Sometimes users | 24 // janky due to the cost of computing the blink rect. Sometimes users |
| 23 // accidentally paste large amounts, so place a limit on what will be | 25 // accidentally paste large amounts, so place a limit on what will be |
| 24 // accepted. | 26 // accepted. |
| 25 // | 27 // |
| 26 // 10k characters was arbitrarily chosen by seeing how much a text | 28 // 10k characters was arbitrarily chosen by seeing how much a text |
| 27 // field could handle in a single line before it started getting too | 29 // field could handle in a single line before it started getting too |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 // selectively enable them via context menu, but that submenu is not enabled | 62 // selectively enable them via context menu, but that submenu is not enabled |
| 61 // for the omnibox. The substitutions are unlikely to be useful in any case. | 63 // for the omnibox. The substitutions are unlikely to be useful in any case. |
| 62 // | 64 // |
| 63 // Also see http://crbug.com/173405 and http://crbug.com/528014. | 65 // Also see http://crbug.com/173405 and http://crbug.com/528014. |
| 64 NSTextCheckingTypes checkingTypes = 0; | 66 NSTextCheckingTypes checkingTypes = 0; |
| 65 [self setEnabledTextCheckingTypes:checkingTypes]; | 67 [self setEnabledTextCheckingTypes:checkingTypes]; |
| 66 } | 68 } |
| 67 return self; | 69 return self; |
| 68 } | 70 } |
| 69 | 71 |
| 72 - (void)viewDidMoveToWindow { | |
| 73 // Only care about landing in a window when in Material Design mode. | |
| 74 if (![self window] || !ui::MaterialDesignController::IsModeMaterial()) { | |
| 75 return; | |
| 76 } | |
| 77 | |
| 78 // Only care about Incognito mode with a non-custom theme. | |
| 79 if (![[self window] inIncognitoModeWithSystemTheme]) { | |
| 80 return; | |
| 81 } | |
| 82 | |
| 83 // Draw a light insertion point for MD Incognito. | |
| 84 [self setInsertionPointColor: | |
| 85 [NSColor colorWithCalibratedWhite:1 alpha:0.75]]; | |
| 86 // In MD Incognito the text is light gray against a dark background. When | |
| 87 // selected, the light gray text against the selection color is illegible. | |
| 88 // Rather than tweak or change the selection color, make the text black when | |
| 89 // selected. | |
| 90 NSColor* textSelectionColor = [NSColor selectedTextBackgroundColor]; | |
| 91 [self setSelectedTextAttributes: | |
| 92 @{NSForegroundColorAttributeName : [NSColor blackColor], | |
| 93 NSBackgroundColorAttributeName : textSelectionColor}]; | |
|
Avi (use Gerrit)
2016/03/01 19:59:06
This isn't quite the container literal style that
shrike
2016/03/01 20:30:14
Acknowledged. Thank you. I think it's correct now,
| |
| 94 } | |
| 95 | |
| 70 // If the entire field is selected, drag the same data as would be | 96 // If the entire field is selected, drag the same data as would be |
| 71 // dragged from the field's location icon. In some cases the textual | 97 // dragged from the field's location icon. In some cases the textual |
| 72 // contents will not contain relevant data (for instance, "http://" is | 98 // contents will not contain relevant data (for instance, "http://" is |
| 73 // stripped from URLs). | 99 // stripped from URLs). |
| 74 - (BOOL)dragSelectionWithEvent:(NSEvent *)event | 100 - (BOOL)dragSelectionWithEvent:(NSEvent *)event |
| 75 offset:(NSSize)mouseOffset | 101 offset:(NSSize)mouseOffset |
| 76 slideBack:(BOOL)slideBack { | 102 slideBack:(BOOL)slideBack { |
| 77 AutocompleteTextFieldObserver* observer = [self observer]; | 103 AutocompleteTextFieldObserver* observer = [self observer]; |
| 78 DCHECK(observer); | 104 DCHECK(observer); |
| 79 if (observer && observer->CanCopy()) { | 105 if (observer && observer->CanCopy()) { |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 [[self delegate] suggestText], | 563 [[self delegate] suggestText], |
| 538 [[self delegate] suggestColor], | 564 [[self delegate] suggestColor], |
| 539 self, | 565 self, |
| 540 [self bounds]); | 566 [self bounds]); |
| 541 AutocompleteTextFieldObserver* observer = [self observer]; | 567 AutocompleteTextFieldObserver* observer = [self observer]; |
| 542 if (observer) | 568 if (observer) |
| 543 observer->OnDidDrawRect(); | 569 observer->OnDidDrawRect(); |
| 544 } | 570 } |
| 545 | 571 |
| 546 @end | 572 @end |
| OLD | NEW |