#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/search/search.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_model.h"
+#include "components/omnibox/autocomplete_match.h"
+#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_service.h"
+#include "grit/component_scaled_resources.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/l10n/l10n_util.h"
// static
base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) {
const base::string16 kJsPrefix(
- base::ASCIIToUTF16(content::kJavaScriptScheme) + base::ASCIIToUTF16(":"));
+ base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":"));
base::string16 out(text);
while (StartsWith(out, kJsPrefix, false)) {
base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING,
}
void OmniboxView::HandleOriginChipMouseRelease() {
- // HIDE_ON_MOUSE_RELEASE only hides if there isn't any current text in the
- // Omnibox (e.g. search terms).
- if ((chrome::GetOriginChipV2Condition() ==
- chrome::ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE) &&
- controller()->GetToolbarModel()->GetText().empty()) {
+ // Only hide if there isn't any current text in the Omnibox (e.g. search
+ // terms).
+ if (controller()->GetToolbarModel()->GetText().empty())
controller()->HideOriginChip();
- }
}
void OmniboxView::OnDidKillFocus() {
- if (chrome::ShouldDisplayOriginChipV2() &&
- !model()->user_input_in_progress()) {
+ if (chrome::ShouldDisplayOriginChip() && !model()->user_input_in_progress())
controller()->ShowOriginChip();
- }
}
void OmniboxView::OpenMatch(const AutocompleteMatch& match,
return;
model_->OpenMatch(
match, disposition, alternate_nav_url, pasted_text, selected_line);
- OnMatchOpened(match, model_->profile(), controller_->GetWebContents());
+ OnMatchOpened(match, controller_->GetWebContents());
}
bool OmniboxView::IsEditingOrEmpty() const {
int OmniboxView::GetIcon() const {
if (!IsEditingOrEmpty())
return controller_->GetToolbarModel()->GetIcon();
- return AutocompleteMatch::TypeToLocationBarIcon(model_.get() ?
+ int id = AutocompleteMatch::TypeToIcon(model_.get() ?
model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED);
+ return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id;
}
base::string16 OmniboxView::GetHintText() const {
+ // If the user is in keyword mode (the "Search <some site>:" chip is showing)
+ // then it doesn't make sense to show the "Search <default search engine>"
+ // hint text.
+ if (model_->is_keyword_selected())
+ return base::string16();
+
// Attempt to determine the default search provider and use that in the hint
// text.
TemplateURLService* template_url_service =
}
void OmniboxView::RevertAll() {
+ controller_->GetToolbarModel()->set_origin_chip_enabled(true);
controller_->GetToolbarModel()->set_url_replacement_enabled(true);
RevertWithoutResettingSearchTermReplacement();
}
}
void OmniboxView::OnMatchOpened(const AutocompleteMatch& match,
- Profile* profile,
- content::WebContents* web_contents) const {}
+ content::WebContents* web_contents) {
+}
OmniboxView::OmniboxView(Profile* profile,
OmniboxEditController* controller,