search_box_view_delegate.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_APP_LIST_VIEWS_SEARCH_BOX_VIEW_DELEGATE_H_
  5. #define ASH_APP_LIST_VIEWS_SEARCH_BOX_VIEW_DELEGATE_H_
  6. #include <string>
  7. namespace ui {
  8. class KeyEvent;
  9. } // namespace ui
  10. namespace ash {
  11. class SearchBoxViewBase;
  12. class SearchBoxViewDelegate {
  13. public:
  14. // Invoked when query text in the search box changes, just before initiating
  15. // search request for the query.
  16. // `trimmed_query` - the search boxt textfiled contents with whitespace
  17. // trimmed (which will generally match the query sent to search providers).
  18. // `initiated_by_user` - whether the query changed as a result of user input
  19. // (as opposed to the search box getting cleared).
  20. virtual void QueryChanged(const std::u16string& trimmed_query,
  21. bool initiated_by_user) = 0;
  22. // Invoked when the back button has been pressed.
  23. virtual void AssistantButtonPressed() = 0;
  24. // Invoked when the close button has been pressed. Implementations should
  25. // clear the search box, but may or may not want to take focus.
  26. virtual void CloseButtonPressed() = 0;
  27. // Invoked when search box active status has changed.
  28. virtual void ActiveChanged(SearchBoxViewBase* sender) = 0;
  29. // Invoked for key events on the search box itself (e.g. arrow keys when one
  30. // of the buttons is focused).
  31. virtual void OnSearchBoxKeyEvent(ui::KeyEvent* event) = 0;
  32. // Returns true if search results can be selected with the keyboard (e.g.
  33. // search results exist and are visible to the user).
  34. virtual bool CanSelectSearchResults() = 0;
  35. protected:
  36. virtual ~SearchBoxViewDelegate() = default;
  37. };
  38. } // namespace ash
  39. #endif // ASH_APP_LIST_VIEWS_SEARCH_BOX_VIEW_DELEGATE_H_