#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/omnibox/browser/omnibox_view.h"
#include <stddef.h>
#include <stdio.h>
#include <memory>
#include <string>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/search_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "components/history/core/browser/history_service.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/history_quick_provider.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_popup_selection.h"
#include "components/omnibox/browser/test_location_bar_model.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/policy_constants.h"
#include "components/search_engines/enterprise/site_search_policy_handler.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h"
#include "net/dns/mock_host_resolver.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/point.h"
#include "url/url_features.h"
ASCIIToUTF16;
UTF16ToUTF8;
BookmarkModel;
namespace {
const char16_t kSearchKeyword[] = …;
const char16_t kSearchKeyword2[] = …;
const char16_t kSiteSearchPolicyKeyword[] = …;
const char16_t kSiteSearchPolicyKeywordWithAtPrefix[] = …;
const ui::KeyboardCode kSearchKeywordKeys[] = …;
const ui::KeyboardCode kSiteSearchPolicyKeywordKeys[] = …;
const char kSearchURL[] = …;
const char kSiteSearchPolicyURL[] = …;
const char16_t kSearchShortName[] = …;
const char16_t kSiteSearchPolicyName[] = …;
const char16_t kSearchText[] = …;
const ui::KeyboardCode kSearchTextKeys[] = …;
const char kSearchTextURL[] = …;
const char kSiteSearchPolicyTextURL[] = …;
const char kInlineAutocompleteText[] = …;
const ui::KeyboardCode kInlineAutocompleteTextKeys[] = …;
const char* kBlockedHostnames[] = …;
const struct TestHistoryEntry { … } kHistoryEntries[] = …;
void SetClipboardText(const std::u16string& text) { … }
#if BUILDFLAG(IS_MAC)
const int kCtrlOrCmdMask = ui::EF_COMMAND_DOWN;
#else
const int kCtrlOrCmdMask = …;
#endif
}
class OmniboxViewTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_BrowserAccelerators) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, PopupAccelerators) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BackspaceInKeywordMode) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_DesiredTLD) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_DesiredTLDWithTemporaryText) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, ClearUserTextAfterBackgroundCommit) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AltEnter) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_EnterToSearch) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscapeToDefaultMatch) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest,
RevertDefaultRevertInlineTextWhenSelectingDefaultMatch) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BasicTextOperations) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FocusSearchLongUrl) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordByTypingQuestionMark) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, SearchDisabledDontCrashOnQuestionMark) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, NonSubstitutingKeywordTest) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_DeleteItem) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, TabAcceptKeyword) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, PersistKeywordModeOnTabSwitch) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest,
CtrlKeyPressedWithInlineAutocompleteTest) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, UndoRedo) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BackspaceDeleteHalfWidthKatakana) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DoesNotUpdateAutocompleteOnBlur) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, Paste) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EditSearchEngines) { … }
IN_PROC_BROWSER_TEST_F(OmniboxViewTest,
DISABLED_CtrlArrowAfterArrowSuggestions) { … }
namespace {
size_t GetSelectionSize(OmniboxView* omnibox_view) { … }
}
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_SelectAllStaysAfterUpdate) { … }
class SiteSearchPolicyOmniboxViewTest : public OmniboxViewTest { … };
IN_PROC_BROWSER_TEST_F(SiteSearchPolicyOmniboxViewTest, NonFeatured) { … }
IN_PROC_BROWSER_TEST_F(SiteSearchPolicyOmniboxViewTest, Featured) { … }
IN_PROC_BROWSER_TEST_F(SiteSearchPolicyOmniboxViewTest, FeaturedOnArrowDown) { … }
class NavigationMetricsRecorderIDNABrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(NavigationMetricsRecorderIDNABrowserTest,
IDNA2008Metrics) { … }