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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 165853002: [OSX, OmniTheatre] URL hiding for Origin Chip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove file that depends on different CL Created 6 years, 10 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 | « no previous file | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/autocomplete/autocomplete_input.h" 14 #include "chrome/browser/autocomplete/autocomplete_input.h"
15 #include "chrome/browser/autocomplete/autocomplete_match.h" 15 #include "chrome/browser/autocomplete/autocomplete_match.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/search/search.h"
17 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 18 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
18 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 19 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
19 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 21 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
21 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
22 #include "chrome/browser/ui/toolbar/toolbar_model.h" 23 #include "chrome/browser/ui/toolbar/toolbar_model.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "extensions/common/constants.h" 25 #include "extensions/common/constants.h"
25 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
26 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // store existing state before anyone tries to setup the new 198 // store existing state before anyone tries to setup the new
198 // state. Anyhow, it would look something like this. 199 // state. Anyhow, it would look something like this.
199 #if 0 200 #if 0
200 [[field_ window] makeFirstResponder:field_]; 201 [[field_ window] makeFirstResponder:field_];
201 [[field_ currentEditor] setSelectedRange:state->selection]; 202 [[field_ currentEditor] setSelectedRange:state->selection];
202 #endif 203 #endif
203 } 204 }
204 } 205 }
205 206
206 void OmniboxViewMac::Update() { 207 void OmniboxViewMac::Update() {
208 if (chrome::ShouldDisplayOriginChipV2()) {
209 [[field_ cell] setPlaceholderString:
210 base::SysUTF16ToNSString(GetHintText())];
211 }
207 if (model()->UpdatePermanentText()) { 212 if (model()->UpdatePermanentText()) {
208 // Something visibly changed. Re-enable URL replacement. 213 // Something visibly changed. Re-enable URL replacement.
209 controller()->GetToolbarModel()->set_url_replacement_enabled(true); 214 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
210 model()->UpdatePermanentText(); 215 model()->UpdatePermanentText();
211 216
212 // Restore everything to the baseline look. 217 // Restore everything to the baseline look.
213 RevertAll(); 218 RevertAll();
214 219
215 // TODO(shess): Figure out how this case is used, to make sure 220 // TODO(shess): Figure out how this case is used, to make sure
216 // we're getting the selection and popup right. 221 // we're getting the selection and popup right.
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 767 }
763 } 768 }
764 } 769 }
765 770
766 return false; 771 return false;
767 } 772 }
768 773
769 void OmniboxViewMac::OnSetFocus(bool control_down) { 774 void OmniboxViewMac::OnSetFocus(bool control_down) {
770 model()->OnSetFocus(control_down); 775 model()->OnSetFocus(control_down);
771 controller()->OnSetFocus(); 776 controller()->OnSetFocus();
777
778 // TODO(groby): Not entirely correct, since the chip should only be disabled
779 // after mouseDown: was handled, to allow clicking on the origin chip.
780 if (chrome::ShouldDisplayOriginChipV2()) {
781 controller()->GetToolbarModel()->set_origin_chip_enabled(false);
782 controller()->OnChanged();
783 }
772 } 784 }
773 785
774 void OmniboxViewMac::OnKillFocus() { 786 void OmniboxViewMac::OnKillFocus() {
775 // Tell the model to reset itself. 787 // Tell the model to reset itself.
776 model()->OnWillKillFocus(NULL); 788 model()->OnWillKillFocus(NULL);
777 model()->OnKillFocus(); 789 model()->OnKillFocus();
790
791 // If user input is not in progress, re-enable the origin chip and URL
792 // replacement. This addresses the case where the URL was shown by a call
793 // to ShowURL(). If the Omnibox achieved focus by other means, the calls to
794 // set_url_replacement_enabled, UpdatePermanentText and RevertAll are not
795 // required (a call to OnChanged would be sufficient) but do no harm.
796 if (chrome::ShouldDisplayOriginChipV2() &&
797 !model()->user_input_in_progress()) {
798 controller()->GetToolbarModel()->set_origin_chip_enabled(true);
799 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
800 model()->UpdatePermanentText();
801 RevertAll();
802 }
778 } 803 }
779 804
780 void OmniboxViewMac::OnMouseDown(NSInteger button_number) { 805 void OmniboxViewMac::OnMouseDown(NSInteger button_number) {
781 // Restore caret visibility whenever the user clicks in the the omnibox. This 806 // Restore caret visibility whenever the user clicks in the the omnibox. This
782 // is not always covered by OnSetFocus() because when clicking while the 807 // is not always covered by OnSetFocus() because when clicking while the
783 // omnibox has invisible focus does not trigger a new OnSetFocus() call. 808 // omnibox has invisible focus does not trigger a new OnSetFocus() call.
784 if (button_number == 0 || button_number == 1) 809 if (button_number == 0 || button_number == 1)
785 model()->SetCaretVisibility(true); 810 model()->SetCaretVisibility(true);
786 } 811 }
787 812
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 979
955 NSUInteger OmniboxViewMac::GetTextLength() const { 980 NSUInteger OmniboxViewMac::GetTextLength() const {
956 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 981 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
957 [[field_ stringValue] length]; 982 [[field_ stringValue] length];
958 } 983 }
959 984
960 bool OmniboxViewMac::IsCaretAtEnd() const { 985 bool OmniboxViewMac::IsCaretAtEnd() const {
961 const NSRange selection = GetSelectedRange(); 986 const NSRange selection = GetSelectedRange();
962 return NSMaxRange(selection) == GetTextLength(); 987 return NSMaxRange(selection) == GetTextLength();
963 } 988 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698