Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
index ac87f9e73b3c834bf689fad11d4c21aa1dfa0e1e..f15d3815a073ffedcd606a2ea51037a90d93f748 100644 |
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
@@ -14,6 +14,7 @@ |
#include "chrome/browser/autocomplete/autocomplete_input.h" |
#include "chrome/browser/autocomplete/autocomplete_match.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/search/search.h" |
#include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
#include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
@@ -204,6 +205,11 @@ void OmniboxViewMac::OnTabChanged(const WebContents* web_contents) { |
} |
void OmniboxViewMac::Update() { |
+ if (chrome::ShouldDisplayOriginChip() || |
Justin Donnelly
2014/02/14 14:57:14
Any reason not to check just for V2 here like you
groby-ooo-7-16
2014/02/15 01:28:14
That was based on Views, which does the same thing
|
+ chrome::ShouldDisplayOriginChipV2()) { |
+ [[field_ cell] setPlaceholderString: |
+ base::SysUTF16ToNSString(GetHintText())]; |
+ } |
if (model()->UpdatePermanentText()) { |
// Something visibly changed. Re-enable URL replacement. |
controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
@@ -769,12 +775,32 @@ bool OmniboxViewMac::OnDoCommandBySelector(SEL cmd) { |
void OmniboxViewMac::OnSetFocus(bool control_down) { |
model()->OnSetFocus(control_down); |
controller()->OnSetFocus(); |
+ |
+ // TODO(groby): Not entirely correct, since the chip should only be disabled |
+ // after mouseDown: was handled, to allow clicking on the origin chip. |
+ if (chrome::ShouldDisplayOriginChipV2()) { |
+ controller()->GetToolbarModel()->set_origin_chip_enabled(false); |
+ controller()->OnChanged(); |
+ } |
} |
void OmniboxViewMac::OnKillFocus() { |
// Tell the model to reset itself. |
model()->OnWillKillFocus(NULL); |
model()->OnKillFocus(); |
+ |
+ // If user input is not in progress, re-enable the origin chip and URL |
+ // replacement. This addresses the case where the URL was shown by a call |
+ // to ShowURL(). If the Omnibox acheived focus by other means, the calls to |
Scott Hess - ex-Googler
2014/02/15 00:55:57
achieved.
groby-ooo-7-16
2014/02/15 01:28:14
Done.
|
+ // set_url_replacement_enabled, UpdatePermanentText and RevertAll are not |
+ // required (a call to OnChanged would be sufficient) but do no harm. |
Scott Hess - ex-Googler
2014/02/15 00:55:57
My general take on things is that calls which scal
groby-ooo-7-16
2014/02/15 01:28:14
This is taken verbatim from Views, so there's cert
|
+ if (chrome::ShouldDisplayOriginChipV2() && |
+ !model()->user_input_in_progress()) { |
+ controller()->GetToolbarModel()->set_origin_chip_enabled(true); |
+ controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
+ model()->UpdatePermanentText(); |
+ RevertAll(); |
+ } |
} |
void OmniboxViewMac::OnMouseDown(NSInteger button_number) { |