Commit d68ffc1e authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

Add assistant button in launcher search box

Bug: b:112281423
Test: locally build and run
Change-Id: I6fc9fe7c462be053a54b48c8a6ffdc23e565bb83
Reviewed-on: https://chromium-review.googlesource.com/1173533
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583493}
parent 2128f094
...@@ -101,6 +101,7 @@ component("app_list") { ...@@ -101,6 +101,7 @@ component("app_list") {
"//ash/app_menu", "//ash/app_menu",
"//ash/assistant/ui:constants", "//ash/assistant/ui:constants",
"//ash/public/cpp/app_list/vector_icons", "//ash/public/cpp/app_list/vector_icons",
"//ash/public/cpp/vector_icons",
"//base", "//base",
"//base:i18n", "//base:i18n",
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
......
...@@ -13,11 +13,14 @@ ...@@ -13,11 +13,14 @@
#include "ash/app_list/views/app_list_main_view.h" #include "ash/app_list/views/app_list_main_view.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/app_list/views/contents_view.h" #include "ash/app_list/views/contents_view.h"
#include "ash/assistant/assistant_controller.h"
#include "ash/assistant/assistant_ui_controller.h"
#include "ash/public/cpp/app_list/answer_card_contents_registry.h" #include "ash/public/cpp/app_list/answer_card_contents_registry.h"
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/config.h" #include "ash/public/cpp/config.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/voice_interaction/voice_interaction_controller.h"
#include "ash/wallpaper/wallpaper_controller.h" #include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -40,7 +43,8 @@ namespace ash { ...@@ -40,7 +43,8 @@ namespace ash {
AppListControllerImpl::AppListControllerImpl() AppListControllerImpl::AppListControllerImpl()
: presenter_(std::make_unique<AppListPresenterDelegateImpl>(this)), : presenter_(std::make_unique<AppListPresenterDelegateImpl>(this)),
is_home_launcher_enabled_(app_list::features::IsHomeLauncherEnabled()) { is_home_launcher_enabled_(app_list::features::IsHomeLauncherEnabled()),
voice_interaction_binding_(this) {
model_.AddObserver(this); model_.AddObserver(this);
// Create only for non-mash. Mash uses window tree embed API to get a // Create only for non-mash. Mash uses window tree embed API to get a
...@@ -62,6 +66,10 @@ AppListControllerImpl::AppListControllerImpl() ...@@ -62,6 +66,10 @@ AppListControllerImpl::AppListControllerImpl()
Shell::Get()->wallpaper_controller()->AddObserver(this); Shell::Get()->wallpaper_controller()->AddObserver(this);
Shell::Get()->AddShellObserver(this); Shell::Get()->AddShellObserver(this);
keyboard::KeyboardController::Get()->AddObserver(this); keyboard::KeyboardController::Get()->AddObserver(this);
mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr));
Shell::Get()->voice_interaction_controller()->AddObserver(std::move(ptr));
} }
AppListControllerImpl::~AppListControllerImpl() { AppListControllerImpl::~AppListControllerImpl() {
...@@ -524,6 +532,15 @@ void AppListControllerImpl::OnWallpaperPreviewEnded() { ...@@ -524,6 +532,15 @@ void AppListControllerImpl::OnWallpaperPreviewEnded() {
UpdateHomeLauncherVisibility(); UpdateHomeLauncherVisibility();
} }
void AppListControllerImpl::OnVoiceInteractionSettingsEnabled(bool enabled) {
UpdateAssistantVisibility();
}
void AppListControllerImpl::OnAssistantFeatureAllowedChanged(
mojom::AssistantAllowedState state) {
UpdateAssistantVisibility();
}
bool AppListControllerImpl::IsHomeLauncherEnabledInTabletMode() const { bool AppListControllerImpl::IsHomeLauncherEnabledInTabletMode() const {
return is_home_launcher_enabled_ && Shell::Get() return is_home_launcher_enabled_ && Shell::Get()
->tablet_mode_controller() ->tablet_mode_controller()
...@@ -533,6 +550,14 @@ bool AppListControllerImpl::IsHomeLauncherEnabledInTabletMode() const { ...@@ -533,6 +550,14 @@ bool AppListControllerImpl::IsHomeLauncherEnabledInTabletMode() const {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Methods of |client_|: // Methods of |client_|:
void AppListControllerImpl::StartAssistant() {
if (!IsHomeLauncherEnabledInTabletMode())
DismissAppList();
ash::Shell::Get()->assistant_controller()->ui_controller()->ShowUi(
ash::AssistantSource::kLauncherSearchBox);
}
void AppListControllerImpl::StartSearch(const base::string16& raw_query) { void AppListControllerImpl::StartSearch(const base::string16& raw_query) {
last_raw_query_ = raw_query; last_raw_query_ = raw_query;
if (client_) { if (client_) {
...@@ -734,4 +759,11 @@ void AppListControllerImpl::UpdateHomeLauncherVisibility() { ...@@ -734,4 +759,11 @@ void AppListControllerImpl::UpdateHomeLauncherVisibility() {
presenter_.GetWindow()->Show(); presenter_.GetWindow()->Show();
} }
void AppListControllerImpl::UpdateAssistantVisibility() {
auto* controller = Shell::Get()->voice_interaction_controller();
GetSearchModel()->search_box()->SetShowAssistantButton(
controller->settings_enabled() &&
controller->allowed_state() == mojom::AssistantAllowedState::ALLOWED);
}
} // namespace ash } // namespace ash
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/public/cpp/app_list/app_list_constants.h" #include "ash/public/cpp/app_list/app_list_constants.h"
#include "ash/public/interfaces/app_list.mojom.h" #include "ash/public/interfaces/app_list.mojom.h"
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "ash/session/session_observer.h" #include "ash/session/session_observer.h"
#include "ash/shell_observer.h" #include "ash/shell_observer.h"
#include "ash/wallpaper/wallpaper_controller_observer.h" #include "ash/wallpaper/wallpaper_controller_observer.h"
...@@ -48,7 +49,8 @@ class ASH_EXPORT AppListControllerImpl ...@@ -48,7 +49,8 @@ class ASH_EXPORT AppListControllerImpl
public ash::ShellObserver, public ash::ShellObserver,
public TabletModeObserver, public TabletModeObserver,
public keyboard::KeyboardControllerObserver, public keyboard::KeyboardControllerObserver,
public WallpaperControllerObserver { public WallpaperControllerObserver,
public mojom::VoiceInteractionObserver {
public: public:
using AppListItemMetadataPtr = mojom::AppListItemMetadataPtr; using AppListItemMetadataPtr = mojom::AppListItemMetadataPtr;
using SearchResultMetadataPtr = mojom::SearchResultMetadataPtr; using SearchResultMetadataPtr = mojom::SearchResultMetadataPtr;
...@@ -137,6 +139,7 @@ class ASH_EXPORT AppListControllerImpl ...@@ -137,6 +139,7 @@ class ASH_EXPORT AppListControllerImpl
// app_list::AppListViewDelegate: // app_list::AppListViewDelegate:
app_list::AppListModel* GetModel() override; app_list::AppListModel* GetModel() override;
app_list::SearchModel* GetSearchModel() override; app_list::SearchModel* GetSearchModel() override;
void StartAssistant() override;
void StartSearch(const base::string16& raw_query) override; void StartSearch(const base::string16& raw_query) override;
void OpenSearchResult(const std::string& result_id, int event_flags) override; void OpenSearchResult(const std::string& result_id, int event_flags) override;
void InvokeSearchResultAction(const std::string& result_id, void InvokeSearchResultAction(const std::string& result_id,
...@@ -185,6 +188,16 @@ class ASH_EXPORT AppListControllerImpl ...@@ -185,6 +188,16 @@ class ASH_EXPORT AppListControllerImpl
void OnWallpaperPreviewStarted() override; void OnWallpaperPreviewStarted() override;
void OnWallpaperPreviewEnded() override; void OnWallpaperPreviewEnded() override;
// mojom::VoiceInteractionObserver:
void OnVoiceInteractionStatusChanged(
mojom::VoiceInteractionState state) override {}
void OnVoiceInteractionSettingsEnabled(bool enabled) override;
void OnVoiceInteractionContextEnabled(bool enabled) override {}
void OnVoiceInteractionHotwordEnabled(bool enabled) override {}
void OnVoiceInteractionSetupCompleted(bool completed) override {}
void OnAssistantFeatureAllowedChanged(
mojom::AssistantAllowedState state) override;
bool onscreen_keyboard_shown() const { return onscreen_keyboard_shown_; } bool onscreen_keyboard_shown() const { return onscreen_keyboard_shown_; }
// Returns true if the home launcher is enabled in tablet mode. // Returns true if the home launcher is enabled in tablet mode.
...@@ -200,6 +213,9 @@ class ASH_EXPORT AppListControllerImpl ...@@ -200,6 +213,9 @@ class ASH_EXPORT AppListControllerImpl
// in overview mode. // in overview mode.
void UpdateHomeLauncherVisibility(); void UpdateHomeLauncherVisibility();
// Update the visibility of Assistant functionality.
void UpdateAssistantVisibility();
base::string16 last_raw_query_; base::string16 last_raw_query_;
mojom::AppListClientPtr client_; mojom::AppListClientPtr client_;
...@@ -232,6 +248,8 @@ class ASH_EXPORT AppListControllerImpl ...@@ -232,6 +248,8 @@ class ASH_EXPORT AppListControllerImpl
// should be hidden during wallpaper preview. // should be hidden during wallpaper preview.
bool in_wallpaper_preview_ = false; bool in_wallpaper_preview_ = false;
mojo::Binding<mojom::VoiceInteractionObserver> voice_interaction_binding_;
DISALLOW_COPY_AND_ASSIGN(AppListControllerImpl); DISALLOW_COPY_AND_ASSIGN(AppListControllerImpl);
}; };
......
...@@ -32,6 +32,9 @@ class ASH_PUBLIC_EXPORT AppListViewDelegate { ...@@ -32,6 +32,9 @@ class ASH_PUBLIC_EXPORT AppListViewDelegate {
// owned by the delegate, or owned elsewhere (e.g. a profile keyed service). // owned by the delegate, or owned elsewhere (e.g. a profile keyed service).
virtual SearchModel* GetSearchModel() = 0; virtual SearchModel* GetSearchModel() = 0;
// Invoked to start a new Google Assistant session.
virtual void StartAssistant() = 0;
// Invoked to start a new search. This collects a list of search results // Invoked to start a new search. This collects a list of search results
// matching the raw query, which is an unhandled string typed into the search // matching the raw query, which is an unhandled string typed into the search
// box by the user. // box by the user.
......
...@@ -57,6 +57,14 @@ void SearchBoxModel::SetTabletMode(bool is_tablet_mode) { ...@@ -57,6 +57,14 @@ void SearchBoxModel::SetTabletMode(bool is_tablet_mode) {
UpdateAccessibleName(); UpdateAccessibleName();
} }
void SearchBoxModel::SetShowAssistantButton(bool show) {
if (show_assistant_button_ == show)
return;
show_assistant_button_ = show;
for (auto& observer : observers_)
observer.ShowAssistantChanged();
}
void SearchBoxModel::SetSearchEngineIsGoogle(bool is_google) { void SearchBoxModel::SetSearchEngineIsGoogle(bool is_google) {
if (is_google == search_engine_is_google_) if (is_google == search_engine_is_google_)
return; return;
......
...@@ -52,6 +52,9 @@ class APP_LIST_MODEL_EXPORT SearchBoxModel { ...@@ -52,6 +52,9 @@ class APP_LIST_MODEL_EXPORT SearchBoxModel {
void SetTabletMode(bool is_tablet_mode); void SetTabletMode(bool is_tablet_mode);
bool is_tablet_mode() const { return is_tablet_mode_; } bool is_tablet_mode() const { return is_tablet_mode_; }
void SetShowAssistantButton(bool show);
bool show_assistant_button() const { return show_assistant_button_; }
void SetSearchEngineIsGoogle(bool is_google); void SetSearchEngineIsGoogle(bool is_google);
bool search_engine_is_google() const { return search_engine_is_google_; } bool search_engine_is_google() const { return search_engine_is_google_; }
...@@ -73,6 +76,7 @@ class APP_LIST_MODEL_EXPORT SearchBoxModel { ...@@ -73,6 +76,7 @@ class APP_LIST_MODEL_EXPORT SearchBoxModel {
base::string16 text_; base::string16 text_;
bool search_engine_is_google_ = false; bool search_engine_is_google_ = false;
bool is_tablet_mode_ = false; bool is_tablet_mode_ = false;
bool show_assistant_button_ = false;
base::ObserverList<SearchBoxModelObserver> observers_; base::ObserverList<SearchBoxModelObserver> observers_;
......
...@@ -23,6 +23,9 @@ class APP_LIST_MODEL_EXPORT SearchBoxModelObserver { ...@@ -23,6 +23,9 @@ class APP_LIST_MODEL_EXPORT SearchBoxModelObserver {
// Invoked when the search engine is changed. // Invoked when the search engine is changed.
virtual void SearchEngineChanged() = 0; virtual void SearchEngineChanged() = 0;
// Invoked when whether to show Assistant is changed.
virtual void ShowAssistantChanged() = 0;
protected: protected:
virtual ~SearchBoxModelObserver() {} virtual ~SearchBoxModelObserver() {}
}; };
......
...@@ -48,6 +48,7 @@ class AppListTestViewDelegate : public AppListViewDelegate, ...@@ -48,6 +48,7 @@ class AppListTestViewDelegate : public AppListViewDelegate,
// AppListViewDelegate overrides: // AppListViewDelegate overrides:
AppListModel* GetModel() override; AppListModel* GetModel() override;
SearchModel* GetSearchModel() override; SearchModel* GetSearchModel() override;
void StartAssistant() override {}
void StartSearch(const base::string16& raw_query) override {} void StartSearch(const base::string16& raw_query) override {}
void OpenSearchResult(const std::string& result_id, int event_flags) override; void OpenSearchResult(const std::string& result_id, int event_flags) override;
void InvokeSearchResultAction(const std::string& result_id, void InvokeSearchResultAction(const std::string& result_id,
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chromeos/chromeos_switches.h"
#include "ui/chromeos/search_box/search_box_view_base.h" #include "ui/chromeos/search_box/search_box_view_base.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/views/border.h" #include "ui/views/border.h"
...@@ -192,6 +193,11 @@ void AppListMainView::ActiveChanged(search_box::SearchBoxViewBase* sender) { ...@@ -192,6 +193,11 @@ void AppListMainView::ActiveChanged(search_box::SearchBoxViewBase* sender) {
} }
} }
void AppListMainView::AssistantButtonPressed() {
DCHECK(chromeos::switches::IsAssistantEnabled());
delegate_->StartAssistant();
}
void AppListMainView::BackButtonPressed() { void AppListMainView::BackButtonPressed() {
if (!contents_view_->Back()) if (!contents_view_->Back())
app_list_view_->Dismiss(); app_list_view_->Dismiss();
......
...@@ -90,6 +90,7 @@ class APP_LIST_EXPORT AppListMainView ...@@ -90,6 +90,7 @@ class APP_LIST_EXPORT AppListMainView
// Overridden from SearchBoxViewDelegate: // Overridden from SearchBoxViewDelegate:
void QueryChanged(search_box::SearchBoxViewBase* sender) override; void QueryChanged(search_box::SearchBoxViewBase* sender) override;
void AssistantButtonPressed() override;
void BackButtonPressed() override; void BackButtonPressed() override;
void ActiveChanged(search_box::SearchBoxViewBase* sender) override; void ActiveChanged(search_box::SearchBoxViewBase* sender) override;
......
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
#include "ash/public/cpp/app_list/app_list_constants.h" #include "ash/public/cpp/app_list/app_list_constants.h"
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/app_list/vector_icons/vector_icons.h" #include "ash/public/cpp/app_list/vector_icons/vector_icons.h"
#include "ash/public/cpp/vector_icons/vector_icons.h"
#include "ash/public/cpp/wallpaper_types.h" #include "ash/public/cpp/wallpaper_types.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chromeos/chromeos_switches.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/chromeos/search_box/search_box_constants.h" #include "ui/chromeos/search_box/search_box_constants.h"
...@@ -59,6 +61,7 @@ constexpr SkColor kSearchBoxBorderColor = ...@@ -59,6 +61,7 @@ constexpr SkColor kSearchBoxBorderColor =
SkColorSetARGB(0x3D, 0xFF, 0xFF, 0xFF); SkColorSetARGB(0x3D, 0xFF, 0xFF, 0xFF);
constexpr int kSearchBoxBorderCornerRadiusSearchResult = 4; constexpr int kSearchBoxBorderCornerRadiusSearchResult = 4;
constexpr int kAssistantIconSize = 24;
constexpr int kCloseIconSize = 24; constexpr int kCloseIconSize = 24;
constexpr int kSearchBoxFocusBorderCornerRadius = 28; constexpr int kSearchBoxFocusBorderCornerRadius = 28;
...@@ -77,6 +80,12 @@ int GetBoxLayoutPaddingForState(ash::AppListState state) { ...@@ -77,6 +80,12 @@ int GetBoxLayoutPaddingForState(ash::AppListState state) {
return search_box::kPadding; return search_box::kPadding;
} }
float GetAssistantButtonOpacityForState(ash::AppListState state) {
if (state == ash::AppListState::kStateSearchResults)
return .0f;
return 1.f;
}
} // namespace } // namespace
SearchBoxView::SearchBoxView(search_box::SearchBoxViewDelegate* delegate, SearchBoxView::SearchBoxView(search_box::SearchBoxViewDelegate* delegate,
...@@ -130,6 +139,7 @@ void SearchBoxView::ModelChanged() { ...@@ -130,6 +139,7 @@ void SearchBoxView::ModelChanged() {
HintTextChanged(); HintTextChanged();
OnWallpaperColorsChanged(); OnWallpaperColorsChanged();
ShowAssistantChanged();
} }
void SearchBoxView::UpdateKeyboardVisibility() { void SearchBoxView::UpdateKeyboardVisibility() {
...@@ -276,9 +286,16 @@ void SearchBoxView::UpdateLayout(double progress, ...@@ -276,9 +286,16 @@ void SearchBoxView::UpdateLayout(double progress,
ash::AppListState current_state, ash::AppListState current_state,
ash::AppListState target_state) { ash::AppListState target_state) {
box_layout()->set_inside_border_insets( box_layout()->set_inside_border_insets(
gfx::Insets(0, gfx::Tween::LinearIntValueBetween( gfx::Insets(0,
progress, GetBoxLayoutPaddingForState(current_state), gfx::Tween::LinearIntValueBetween(
GetBoxLayoutPaddingForState(target_state)))); progress, GetBoxLayoutPaddingForState(current_state),
GetBoxLayoutPaddingForState(target_state)),
0, 0));
if (show_assistant_button()) {
assistant_button()->layer()->SetOpacity(gfx::Tween::LinearIntValueBetween(
progress, GetAssistantButtonOpacityForState(current_state),
GetAssistantButtonOpacityForState(target_state)));
}
InvalidateLayout(); InvalidateLayout();
} }
...@@ -537,7 +554,7 @@ void SearchBoxView::SelectionModelChanged() { ...@@ -537,7 +554,7 @@ void SearchBoxView::SelectionModelChanged() {
void SearchBoxView::Update() { void SearchBoxView::Update() {
search_box()->SetText(search_model_->search_box()->text()); search_box()->SetText(search_model_->search_box()->text());
UpdateCloseButtonVisisbility(); UpdateButtonsVisisbility();
NotifyQueryChanged(); NotifyQueryChanged();
} }
...@@ -545,4 +562,25 @@ void SearchBoxView::SearchEngineChanged() { ...@@ -545,4 +562,25 @@ void SearchBoxView::SearchEngineChanged() {
UpdateSearchIcon(); UpdateSearchIcon();
} }
void SearchBoxView::ShowAssistantChanged() {
if (search_model_) {
SetShowAssistantButton(
search_model_->search_box()->show_assistant_button());
}
}
void SearchBoxView::SetupAssistantButton() {
if (search_model_ && !search_model_->search_box()->show_assistant_button()) {
return;
}
views::ImageButton* assistant = assistant_button();
assistant->SetImage(
views::ImageButton::STATE_NORMAL,
gfx::CreateVectorIcon(ash::kAssistantIcon, kAssistantIconSize,
search_box_color()));
assistant->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_LIST_START_ASSISTANT));
}
} // namespace app_list } // namespace app_list
...@@ -46,6 +46,7 @@ class APP_LIST_EXPORT SearchBoxView : public search_box::SearchBoxViewBase, ...@@ -46,6 +46,7 @@ class APP_LIST_EXPORT SearchBoxView : public search_box::SearchBoxViewBase,
void UpdateModel(bool initiated_by_user) override; void UpdateModel(bool initiated_by_user) override;
void UpdateSearchIcon() override; void UpdateSearchIcon() override;
void UpdateSearchBoxBorder() override; void UpdateSearchBoxBorder() override;
void SetupAssistantButton() override;
void SetupCloseButton() override; void SetupCloseButton() override;
void SetupBackButton() override; void SetupBackButton() override;
void RecordSearchBoxActivationHistogram(ui::EventType event_type) override; void RecordSearchBoxActivationHistogram(ui::EventType event_type) override;
...@@ -127,6 +128,7 @@ class APP_LIST_EXPORT SearchBoxView : public search_box::SearchBoxViewBase, ...@@ -127,6 +128,7 @@ class APP_LIST_EXPORT SearchBoxView : public search_box::SearchBoxViewBase,
void SelectionModelChanged() override; void SelectionModelChanged() override;
void Update() override; void Update() override;
void SearchEngineChanged() override; void SearchEngineChanged() override;
void ShowAssistantChanged() override;
// The range of highlighted text for autocomplete. // The range of highlighted text for autocomplete.
gfx::Range highlight_range_; gfx::Range highlight_range_;
......
...@@ -151,6 +151,7 @@ class SearchBoxViewTest : public views::test::WidgetTest, ...@@ -151,6 +151,7 @@ class SearchBoxViewTest : public views::test::WidgetTest,
last_query_ = sender->search_box()->text(); last_query_ = sender->search_box()->text();
} }
void AssistantButtonPressed() override {}
void BackButtonPressed() override {} void BackButtonPressed() override {}
void ActiveChanged(search_box::SearchBoxViewBase* sender) override {} void ActiveChanged(search_box::SearchBoxViewBase* sender) override {}
......
...@@ -21,6 +21,7 @@ enum class AssistantSource { ...@@ -21,6 +21,7 @@ enum class AssistantSource {
kLongPressLauncher, kLongPressLauncher,
kSetup, kSetup,
kStylus, kStylus,
kLauncherSearchBox,
}; };
// Enumeration of Assistant UI modes. // Enumeration of Assistant UI modes.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/assistant/ui/assistant_mini_view.h" #include "ash/assistant/ui/assistant_mini_view.h"
#include <algorithm>
#include <memory> #include <memory>
#include "ash/assistant/assistant_controller.h" #include "ash/assistant/assistant_controller.h"
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
#include "ash/assistant/assistant_ui_controller.h" #include "ash/assistant/assistant_ui_controller.h"
#include "ash/assistant/model/assistant_query.h" #include "ash/assistant/model/assistant_query.h"
#include "ash/assistant/ui/assistant_ui_constants.h" #include "ash/assistant/ui/assistant_ui_constants.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/public/cpp/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
......
...@@ -62,6 +62,7 @@ class KeyboardShortcutView : public views::WidgetDelegateView, ...@@ -62,6 +62,7 @@ class KeyboardShortcutView : public views::WidgetDelegateView,
// search_box::SearchBoxViewDelegate: // search_box::SearchBoxViewDelegate:
void QueryChanged(search_box::SearchBoxViewBase* sender) override; void QueryChanged(search_box::SearchBoxViewBase* sender) override;
void AssistantButtonPressed() override {}
void BackButtonPressed() override; void BackButtonPressed() override;
void ActiveChanged(search_box::SearchBoxViewBase* sender) override; void ActiveChanged(search_box::SearchBoxViewBase* sender) override;
......
...@@ -39,6 +39,7 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase { ...@@ -39,6 +39,7 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase {
void UpdateModel(bool initiated_by_user) override {} void UpdateModel(bool initiated_by_user) override {}
void UpdateSearchIcon() override {} void UpdateSearchIcon() override {}
void UpdateSearchBoxBorder() override; void UpdateSearchBoxBorder() override;
void SetupAssistantButton() override {}
void SetupCloseButton() override; void SetupCloseButton() override;
void SetupBackButton() override; void SetupBackButton() override;
......
...@@ -9,6 +9,7 @@ aggregate_vector_icons("ash_public_vector_icons") { ...@@ -9,6 +9,7 @@ aggregate_vector_icons("ash_public_vector_icons") {
icon_directory = "." icon_directory = "."
icons = [ icons = [
"assistant.icon",
"notification_assistant.icon", "notification_assistant.icon",
"notification_captive_portal.icon", "notification_captive_portal.icon",
"notification_cellular_alert.icon", "notification_cellular_alert.icon",
......
...@@ -9,7 +9,6 @@ aggregate_vector_icons("ash_vector_icons") { ...@@ -9,7 +9,6 @@ aggregate_vector_icons("ash_vector_icons") {
icon_directory = "." icon_directory = "."
icons = [ icons = [
"assistant.icon",
"auto_hide.icon", "auto_hide.icon",
"captive_portal.icon", "captive_portal.icon",
"check_circle.icon", "check_circle.icon",
......
...@@ -1108,6 +1108,8 @@ void Shell::Init( ...@@ -1108,6 +1108,8 @@ void Shell::Init(
display::Screen::GetScreen()->GetPrimaryDisplay()); display::Screen::GetScreen()->GetPrimaryDisplay());
accelerator_controller_ = std::make_unique<AcceleratorController>(nullptr); accelerator_controller_ = std::make_unique<AcceleratorController>(nullptr);
voice_interaction_controller_ =
std::make_unique<VoiceInteractionController>();
// |app_list_controller_| is put after |tablet_mode_controller_| as the former // |app_list_controller_| is put after |tablet_mode_controller_| as the former
// uses the latter in constructor. // uses the latter in constructor.
...@@ -1185,8 +1187,6 @@ void Shell::Init( ...@@ -1185,8 +1187,6 @@ void Shell::Init(
laser_pointer_controller_.reset(new LaserPointerController()); laser_pointer_controller_.reset(new LaserPointerController());
partial_magnification_controller_.reset(new PartialMagnificationController()); partial_magnification_controller_.reset(new PartialMagnificationController());
highlighter_controller_.reset(new HighlighterController()); highlighter_controller_.reset(new HighlighterController());
voice_interaction_controller_ =
std::make_unique<VoiceInteractionController>();
assistant_controller_ = chromeos::switches::IsAssistantEnabled() assistant_controller_ = chromeos::switches::IsAssistantEnabled()
? std::make_unique<AssistantController>() ? std::make_unique<AssistantController>()
......
...@@ -235,6 +235,8 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { ...@@ -235,6 +235,8 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void StartAssistant() override { NOTIMPLEMENTED(); }
void StartSearch(const base::string16& raw_query) override { void StartSearch(const base::string16& raw_query) override {
base::string16 query; base::string16 query;
base::TrimWhitespace(raw_query, base::TRIM_ALL, &query); base::TrimWhitespace(raw_query, base::TRIM_ALL, &query);
......
...@@ -14,9 +14,14 @@ ...@@ -14,9 +14,14 @@
#include "ui/chromeos/search_box/search_box_view_delegate.h" #include "ui/chromeos/search_box/search_box_view_delegate.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
...@@ -34,6 +39,8 @@ namespace { ...@@ -34,6 +39,8 @@ namespace {
constexpr int kInnerPadding = 16; constexpr int kInnerPadding = 16;
constexpr int kButtonSizeDip = 48;
// Preferred width of search box. // Preferred width of search box.
constexpr int kSearchBoxPreferredWidth = 544; constexpr int kSearchBoxPreferredWidth = 544;
...@@ -88,6 +95,14 @@ class SearchBoxImageButton : public views::ImageButton { ...@@ -88,6 +95,14 @@ class SearchBoxImageButton : public views::ImageButton {
// Avoid drawing default dashed focus and draw customized focus in // Avoid drawing default dashed focus and draw customized focus in
// OnPaintBackground(); // OnPaintBackground();
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetInkDropMode(InkDropMode::ON);
SetPreferredSize({kButtonSizeDip, kButtonSizeDip});
SetImageAlignment(HorizontalAlignment::ALIGN_CENTER,
VerticalAlignment::ALIGN_MIDDLE);
} }
~SearchBoxImageButton() override {} ~SearchBoxImageButton() override {}
...@@ -107,11 +122,49 @@ class SearchBoxImageButton : public views::ImageButton { ...@@ -107,11 +122,49 @@ class SearchBoxImageButton : public views::ImageButton {
void OnBlur() override { SchedulePaint(); } void OnBlur() override { SchedulePaint(); }
// views::InkDropHost overrides:
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
return CreateDefaultFloodFillInkDropImpl();
}
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
const gfx::Point center = GetLocalBounds().CenterPoint();
const int ripple_radius = GetInkDropRadius();
gfx::Rect bounds(center.x() - ripple_radius, center.y() - ripple_radius,
2 * ripple_radius, 2 * ripple_radius);
constexpr SkColor ripple_color = SkColorSetA(gfx::kGoogleGrey900, 0x17);
return std::make_unique<views::FloodFillInkDropRipple>(
size(), GetLocalBounds().InsetsFrom(bounds),
GetInkDropCenterBasedOnLastEvent(), ripple_color, 1.0f);
}
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override {
return std::make_unique<views::CircleInkDropMask>(
size(), GetLocalBounds().CenterPoint(), GetInkDropRadius());
}
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override {
constexpr SkColor ripple_color = SkColorSetA(gfx::kGoogleGrey900, 0x12);
return std::make_unique<views::InkDropHighlight>(
gfx::PointF(GetLocalBounds().CenterPoint()),
std::make_unique<views::CircleLayerDelegate>(ripple_color,
GetInkDropRadius()));
}
private: private:
int GetInkDropRadius() const { return width() / 2; }
// views::View overrides: // views::View overrides:
void OnPaintBackground(gfx::Canvas* canvas) override { void OnPaintBackground(gfx::Canvas* canvas) override {
if (state() == STATE_PRESSED || HasFocus()) { if (HasFocus()) {
canvas->FillRect(gfx::Rect(size()), kSelectedColor); cc::PaintFlags circle_flags;
circle_flags.setAntiAlias(true);
circle_flags.setColor(kSelectedColor);
circle_flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawCircle(GetLocalBounds().CenterPoint(), GetInkDropRadius(),
circle_flags);
} }
} }
...@@ -184,7 +237,7 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate) ...@@ -184,7 +237,7 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate)
search_box_->SetBorder(views::NullBorder()); search_box_->SetBorder(views::NullBorder());
search_box_->SetTextColor(kSearchTextColor); search_box_->SetTextColor(kSearchTextColor);
search_box_->SetBackgroundColor(background_color_); search_box_->SetBackgroundColor(SK_ColorTRANSPARENT);
search_box_->set_controller(this); search_box_->set_controller(this);
search_box_->SetTextInputType(ui::TEXT_INPUT_TYPE_SEARCH); search_box_->SetTextInputType(ui::TEXT_INPUT_TYPE_SEARCH);
search_box_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF); search_box_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
...@@ -207,6 +260,11 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate) ...@@ -207,6 +260,11 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate)
search_box_right_space_->SetPreferredSize(gfx::Size(kSearchIconSize, 0)); search_box_right_space_->SetPreferredSize(gfx::Size(kSearchIconSize, 0));
content_container_->AddChildView(search_box_right_space_); content_container_->AddChildView(search_box_right_space_);
assistant_button_ = new SearchBoxImageButton(this);
// Default hidden, child class should decide if it should shown.
assistant_button_->SetVisible(false);
content_container_->AddChildView(assistant_button_);
close_button_ = new SearchBoxImageButton(this); close_button_ = new SearchBoxImageButton(this);
content_container_->AddChildView(close_button_); content_container_->AddChildView(close_button_);
} }
...@@ -218,6 +276,7 @@ void SearchBoxViewBase::Init() { ...@@ -218,6 +276,7 @@ void SearchBoxViewBase::Init() {
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
layer()->SetMasksToBounds(true); layer()->SetMasksToBounds(true);
UpdateSearchBoxBorder(); UpdateSearchBoxBorder();
SetupAssistantButton();
SetupBackButton(); SetupBackButton();
SetupCloseButton(); SetupCloseButton();
ModelChanged(); ModelChanged();
...@@ -234,6 +293,10 @@ gfx::Rect SearchBoxViewBase::GetViewBoundsForSearchBoxContentsBounds( ...@@ -234,6 +293,10 @@ gfx::Rect SearchBoxViewBase::GetViewBoundsForSearchBoxContentsBounds(
return view_bounds; return view_bounds;
} }
views::ImageButton* SearchBoxViewBase::assistant_button() {
return static_cast<views::ImageButton*>(assistant_button_);
}
views::ImageButton* SearchBoxViewBase::back_button() { views::ImageButton* SearchBoxViewBase::back_button() {
return static_cast<views::ImageButton*>(back_button_); return static_cast<views::ImageButton*>(back_button_);
} }
...@@ -275,7 +338,7 @@ void SearchBoxViewBase::SetSearchBoxActive(bool active, ...@@ -275,7 +338,7 @@ void SearchBoxViewBase::SetSearchBoxActive(bool active,
UpdateSearchBoxBorder(); UpdateSearchBoxBorder();
UpdateKeyboardVisibility(); UpdateKeyboardVisibility();
UpdateCloseButtonVisisbility(); UpdateButtonsVisisbility();
NotifyActiveChanged(); NotifyActiveChanged();
...@@ -331,7 +394,9 @@ bool SearchBoxViewBase::ShouldAdvanceFocusToTopLevelWidget() const { ...@@ -331,7 +394,9 @@ bool SearchBoxViewBase::ShouldAdvanceFocusToTopLevelWidget() const {
void SearchBoxViewBase::ButtonPressed(views::Button* sender, void SearchBoxViewBase::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (back_button_ && sender == back_button_) { if (assistant_button_ && sender == assistant_button_) {
delegate_->AssistantButtonPressed();
} else if (back_button_ && sender == back_button_) {
delegate_->BackButtonPressed(); delegate_->BackButtonPressed();
} else if (close_button_ && sender == close_button_) { } else if (close_button_ && sender == close_button_) {
ClearSearch(); ClearSearch();
...@@ -360,7 +425,7 @@ bool SearchBoxViewBase::IsSearchBoxTrimmedQueryEmpty() const { ...@@ -360,7 +425,7 @@ bool SearchBoxViewBase::IsSearchBoxTrimmedQueryEmpty() const {
void SearchBoxViewBase::ClearSearch() { void SearchBoxViewBase::ClearSearch() {
search_box_->SetText(base::string16()); search_box_->SetText(base::string16());
UpdateCloseButtonVisisbility(); UpdateButtonsVisisbility();
// Updates model and fires query changed manually because SetText() above // Updates model and fires query changed manually because SetText() above
// does not generate ContentsChanged() notification. // does not generate ContentsChanged() notification.
UpdateModel(false); UpdateModel(false);
...@@ -395,15 +460,22 @@ void SearchBoxViewBase::SetSearchBoxColor(SkColor color) { ...@@ -395,15 +460,22 @@ void SearchBoxViewBase::SetSearchBoxColor(SkColor color) {
SK_ColorTRANSPARENT == color ? kDefaultSearchboxColor : color; SK_ColorTRANSPARENT == color ? kDefaultSearchboxColor : color;
} }
void SearchBoxViewBase::UpdateCloseButtonVisisbility() { void SearchBoxViewBase::UpdateButtonsVisisbility() {
if (!close_button_) DCHECK(close_button_ && assistant_button_);
return;
bool should_show_close_button_ = bool should_show_close_button =
!search_box_->text().empty() || !search_box_->text().empty() ||
(show_close_button_when_active_ && is_search_box_active_); (show_close_button_when_active_ && is_search_box_active_);
if (close_button_->visible() == should_show_close_button_) bool should_show_assistant_button =
show_assistant_button_ && !should_show_close_button;
if (close_button_->visible() == should_show_close_button &&
assistant_button_->visible() == should_show_assistant_button) {
return; return;
close_button_->SetVisible(should_show_close_button_); }
close_button_->SetVisible(should_show_close_button);
assistant_button_->SetVisible(should_show_assistant_button);
content_container_->Layout(); content_container_->Layout();
} }
...@@ -414,7 +486,7 @@ void SearchBoxViewBase::ContentsChanged(views::Textfield* sender, ...@@ -414,7 +486,7 @@ void SearchBoxViewBase::ContentsChanged(views::Textfield* sender,
UpdateModel(true); UpdateModel(true);
NotifyQueryChanged(); NotifyQueryChanged();
SetSearchBoxActive(true, ui::ET_KEY_PRESSED); SetSearchBoxActive(true, ui::ET_KEY_PRESSED);
UpdateCloseButtonVisisbility(); UpdateButtonsVisisbility();
} }
bool SearchBoxViewBase::HandleMouseEvent(views::Textfield* sender, bool SearchBoxViewBase::HandleMouseEvent(views::Textfield* sender,
...@@ -440,6 +512,11 @@ void SearchBoxViewBase::SetSearchIconImage(gfx::ImageSkia image) { ...@@ -440,6 +512,11 @@ void SearchBoxViewBase::SetSearchIconImage(gfx::ImageSkia image) {
search_icon_->SetImage(image); search_icon_->SetImage(image);
} }
void SearchBoxViewBase::SetShowAssistantButton(bool show) {
show_assistant_button_ = show;
UpdateButtonsVisisbility();
}
void SearchBoxViewBase::HandleSearchBoxEvent(ui::LocatedEvent* located_event) { void SearchBoxViewBase::HandleSearchBoxEvent(ui::LocatedEvent* located_event) {
if (located_event->type() == ui::ET_MOUSE_PRESSED || if (located_event->type() == ui::ET_MOUSE_PRESSED ||
located_event->type() == ui::ET_GESTURE_TAP) { located_event->type() == ui::ET_GESTURE_TAP) {
...@@ -462,7 +539,6 @@ void SearchBoxViewBase::UpdateBackgroundColor(SkColor color) { ...@@ -462,7 +539,6 @@ void SearchBoxViewBase::UpdateBackgroundColor(SkColor color) {
if (is_search_box_active_) if (is_search_box_active_)
color = kSearchBoxBackgroundDefault; color = kSearchBoxBackgroundDefault;
GetSearchBoxBackground()->set_color(color); GetSearchBoxBackground()->set_color(color);
search_box_->SetBackgroundColor(color);
} }
SearchBoxBackground* SearchBoxViewBase::GetSearchBoxBackground() const { SearchBoxBackground* SearchBoxViewBase::GetSearchBoxBackground() const {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_ #ifndef UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_
#define UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_ #define UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_
#include <vector> #include <vector>
...@@ -66,6 +66,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -66,6 +66,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
gfx::Rect GetViewBoundsForSearchBoxContentsBounds( gfx::Rect GetViewBoundsForSearchBoxContentsBounds(
const gfx::Rect& rect) const; const gfx::Rect& rect) const;
views::ImageButton* assistant_button();
views::ImageButton* back_button(); views::ImageButton* back_button();
views::ImageButton* close_button(); views::ImageButton* close_button();
views::Textfield* search_box() { return search_box_; } views::Textfield* search_box() { return search_box_; }
...@@ -113,6 +114,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -113,6 +114,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
show_close_button_when_active_ = show_button; show_close_button_when_active_ = show_button;
} }
bool show_assistant_button() { return show_assistant_button_; }
void OnOnSearchBoxFocusedChanged(); void OnOnSearchBoxFocusedChanged();
// Whether the trimmed query in the search box is empty. // Whether the trimmed query in the search box is empty.
...@@ -139,7 +142,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -139,7 +142,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
SkColor search_box_color() const { return search_box_color_; } SkColor search_box_color() const { return search_box_color_; }
// Updates the visibility of close button. // Updates the visibility of close button.
void UpdateCloseButtonVisisbility(); void UpdateButtonsVisisbility();
// Overridden from views::TextfieldController: // Overridden from views::TextfieldController:
void ContentsChanged(views::Textfield* sender, void ContentsChanged(views::Textfield* sender,
...@@ -161,6 +164,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -161,6 +164,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
void SetSearchIconImage(gfx::ImageSkia image); void SetSearchIconImage(gfx::ImageSkia image);
void SetShowAssistantButton(bool show);
// Detects |ET_MOUSE_PRESSED| and |ET_GESTURE_TAP| events on the white // Detects |ET_MOUSE_PRESSED| and |ET_GESTURE_TAP| events on the white
// background of the search box. // background of the search box.
virtual void HandleSearchBoxEvent(ui::LocatedEvent* located_event); virtual void HandleSearchBoxEvent(ui::LocatedEvent* located_event);
...@@ -184,11 +189,12 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -184,11 +189,12 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
virtual void UpdateSearchBoxBorder() = 0; virtual void UpdateSearchBoxBorder() = 0;
// Setup button's image, accessible name, and tooltip text etc. // Setup button's image, accessible name, and tooltip text etc.
virtual void SetupAssistantButton() = 0;
virtual void SetupCloseButton() = 0; virtual void SetupCloseButton() = 0;
virtual void SetupBackButton() = 0; virtual void SetupBackButton() = 0;
// Records in histograms the activation of the searchbox. // Records in histograms the activation of the searchbox.
virtual void RecordSearchBoxActivationHistogram(ui::EventType event_type){}; virtual void RecordSearchBoxActivationHistogram(ui::EventType event_type) {}
// Gets the search box background. // Gets the search box background.
SearchBoxBackground* GetSearchBoxBackground() const; SearchBoxBackground* GetSearchBoxBackground() const;
...@@ -198,6 +204,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -198,6 +204,7 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
// Owned by views hierarchy. // Owned by views hierarchy.
views::View* content_container_; views::View* content_container_;
views::ImageView* search_icon_ = nullptr; views::ImageView* search_icon_ = nullptr;
SearchBoxImageButton* assistant_button_ = nullptr;
SearchBoxImageButton* back_button_ = nullptr; SearchBoxImageButton* back_button_ = nullptr;
SearchBoxImageButton* close_button_ = nullptr; SearchBoxImageButton* close_button_ = nullptr;
views::Textfield* search_box_; views::Textfield* search_box_;
...@@ -210,6 +217,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -210,6 +217,8 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
bool is_search_box_active_ = false; bool is_search_box_active_ = false;
// Whether to show close button if the search box is active. // Whether to show close button if the search box is active.
bool show_close_button_when_active_ = false; bool show_close_button_when_active_ = false;
// Whether to show assistant button.
bool show_assistant_button_ = false;
// Whether tablet mode is active. // Whether tablet mode is active.
bool is_tablet_mode_ = false; bool is_tablet_mode_ = false;
// The current background color. // The current background color.
...@@ -222,4 +231,4 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView, ...@@ -222,4 +231,4 @@ class SEARCH_BOX_EXPORT SearchBoxViewBase : public views::WidgetDelegateView,
} // namespace search_box } // namespace search_box
#endif // UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_ #endif // UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_BASE_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_ #ifndef UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_
#define UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_ #define UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_
#include "ui/chromeos/search_box/search_box_export.h" #include "ui/chromeos/search_box/search_box_export.h"
...@@ -16,6 +16,9 @@ class SEARCH_BOX_EXPORT SearchBoxViewDelegate { ...@@ -16,6 +16,9 @@ class SEARCH_BOX_EXPORT SearchBoxViewDelegate {
// Invoked when query text has changed by the user. // Invoked when query text has changed by the user.
virtual void QueryChanged(SearchBoxViewBase* sender) = 0; virtual void QueryChanged(SearchBoxViewBase* sender) = 0;
// Invoked when the back button has been pressed.
virtual void AssistantButtonPressed() = 0;
// Invoked when the back button has been pressed. // Invoked when the back button has been pressed.
virtual void BackButtonPressed() = 0; virtual void BackButtonPressed() = 0;
...@@ -28,4 +31,4 @@ class SEARCH_BOX_EXPORT SearchBoxViewDelegate { ...@@ -28,4 +31,4 @@ class SEARCH_BOX_EXPORT SearchBoxViewDelegate {
} // namespace search_box } // namespace search_box
#endif // UI_CHOMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_ #endif // UI_CHROMEOS_SEARCH_BOX_SEARCH_BOX_VIEW_DELEGATE_H_
...@@ -794,6 +794,9 @@ need to be translated for each locale.--> ...@@ -794,6 +794,9 @@ need to be translated for each locale.-->
<message name="IDS_APP_LIST_CLEAR_SEARCHBOX" desc="Tooltip for the button that clears all text from the search box in the app list."> <message name="IDS_APP_LIST_CLEAR_SEARCHBOX" desc="Tooltip for the button that clears all text from the search box in the app list.">
Clear searchbox text Clear searchbox text
</message> </message>
<message name="IDS_APP_LIST_START_ASSISTANT" desc="Tooltip for the button that starts Google Assistant from the search box in the app list.">
Start Google Assistant
</message>
<message name="IDS_APP_LIST_PAGE_SWITCHER" desc="Tooltip for page switcher for each page in fullscreen view which shows all apps."> <message name="IDS_APP_LIST_PAGE_SWITCHER" desc="Tooltip for page switcher for each page in fullscreen view which shows all apps.">
Page <ph name="selected_page">$1<ex>1</ex></ph> of <ph name="total_page_num">$2<ex>3</ex></ph> Page <ph name="selected_page">$1<ex>1</ex></ph> of <ph name="total_page_num">$2<ex>3</ex></ph>
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment