omnibox: experiment with restoring placeholder when caret shows

Shows the "Search Google or type a URL" omnibox placeholder even when
the caret (text edit cursor) is showing / when focused. views::Textfield
works this way, as does <input placeholder="">. Omnibox and the NTP's
"fakebox" are exceptions in this regard and this experiment makes this
more consistent.

R=tommycli@chromium.org
BUG=955585

Change-Id: I23c299c0973f2feb43f7a2be3bd3425a80b06c2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582315
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654279}
void OmniboxViewViews::EmphasizeURLComponents() {
  if (!location_bar_view_)
    return;

  if (path_fade_animation_)
    path_fade_animation_->Stop();

  bool text_is_url = model()->CurrentTextIsURL();
  GetRenderText()->SetDirectionalityMode(
      text_is_url ? gfx::DIRECTIONALITY_AS_URL : gfx::DIRECTIONALITY_FROM_TEXT);
  SetStyle(gfx::TEXT_STYLE_STRIKE, false);

  base::string16 text = GetText();
  bool path_eligible_for_fading = UpdateTextStyle(
      text, text_is_url, model()->client()->GetSchemeClassifier());

  if (path_fade_animation_ && path_eligible_for_fading && !HasFocus() &&
      !model()->user_input_in_progress()) {
    url::Component scheme, host;
    AutocompleteInput::ParseForEmphasizeComponents(
        text, model()->client()->GetSchemeClassifier(), &scheme, &host);
    gfx::Range path_bounds(host.end(), text.size());

    path_fade_animation_->Start(path_bounds);
  }
}

void OmniboxViewViews::EmphasizeURLComponents() {
  if (!location_bar_view_)
    return;

  if (path_fade_animation_)
    path_fade_animation_->Stop();

  bool text_is_url = model()->CurrentTextIsURL();
  GetRenderText()->SetDirectionalityMode(
      text_is_url ? gfx::DIRECTIONALITY_AS_URL : gfx::DIRECTIONALITY_FROM_TEXT);
  SetStyle(gfx::TEXT_STYLE_STRIKE, false);

  base::string16 text = GetText();
  bool path_eligible_for_fading = UpdateTextStyle(
      text, text_is_url, model()->client()->GetSchemeClassifier());

  if (path_fade_animation_ && path_eligible_for_fading && !HasFocus() &&
      !model()->user_input_in_progress()) {
    url::Component scheme, host;
    AutocompleteInput::ParseForEmphasizeComponents(
        text, model()->client()->GetSchemeClassifier(), &scheme, &host);
    gfx::Range path_bounds(host.end(), text.size());

    path_fade_animation_->Start(path_bounds);
  }
}
