Commit 414e3c9a authored by Yue Li's avatar Yue Li Committed by Commit Bot

Check board type for metalayer tool

The stylus Assistant mode feature is restricted to Google devices. Add a
util method to check the board type while adding the metalayer tool.

Bug: 996312
Test: Run existing tests
Change-Id: Iaa75fe8901d6be382c2525dfa64bb193f84ccaeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1779187
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692228}
parent d1789687
......@@ -5,6 +5,16 @@
#include "ash/assistant/util/assistant_util.h"
#include "ash/assistant/model/assistant_ui_model.h"
#include "base/system/sys_info.h"
namespace {
constexpr char kEveBoardName[] = "eve";
constexpr char kNocturneBoardName[] = "nocturne";
bool g_override_is_google_device = false;
} // namespace
namespace ash {
namespace assistant {
......@@ -57,6 +67,16 @@ bool ShouldAttemptWarmerWelcome(AssistantEntryPoint entry_point) {
}
}
bool IsGoogleDevice() {
const std::string board_name = base::SysInfo::GetLsbReleaseBoard();
return g_override_is_google_device || board_name == kEveBoardName ||
board_name == kNocturneBoardName;
}
void OverrideIsGoogleDeviceForTesting() {
g_override_is_google_device = true;
}
} // namespace util
} // namespace assistant
} // namespace ash
......@@ -35,6 +35,12 @@ bool IsVoiceEntryPoint(AssistantEntryPoint entry_point, bool prefer_voice);
COMPONENT_EXPORT(ASSISTANT_UTIL)
bool ShouldAttemptWarmerWelcome(AssistantEntryPoint entry_point);
COMPONENT_EXPORT(ASSISTANT_UTIL)
bool IsGoogleDevice();
COMPONENT_EXPORT(ASSISTANT_UTIL)
void OverrideIsGoogleDeviceForTesting();
} // namespace util
} // namespace assistant
} // namespace ash
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "ash/assistant/util/assistant_util.h"
#include "ash/system/palette/palette_tool_manager.h"
#include "ash/system/palette/palette_utils.h"
#include "ash/system/palette/tools/capture_region_mode.h"
......@@ -14,7 +15,6 @@
#include "ash/system/palette/tools/laser_pointer_mode.h"
#include "ash/system/palette/tools/magnifier_mode.h"
#include "ash/system/palette/tools/metalayer_mode.h"
#include "chromeos/constants/chromeos_features.h"
#include "ui/gfx/paint_vector_icon.h"
namespace ash {
......@@ -24,7 +24,8 @@ void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {
tool_manager->AddTool(std::make_unique<CaptureRegionMode>(tool_manager));
tool_manager->AddTool(std::make_unique<CaptureScreenAction>(tool_manager));
tool_manager->AddTool(std::make_unique<CreateNoteAction>(tool_manager));
tool_manager->AddTool(std::make_unique<MetalayerMode>(tool_manager));
if (assistant::util::IsGoogleDevice())
tool_manager->AddTool(std::make_unique<MetalayerMode>(tool_manager));
tool_manager->AddTool(std::make_unique<LaserPointerMode>(tool_manager));
tool_manager->AddTool(std::make_unique<MagnifierMode>(tool_manager));
}
......
......@@ -9,6 +9,7 @@
#include "ash/assistant/assistant_controller.h"
#include "ash/assistant/test/test_assistant_service.h"
#include "ash/assistant/util/assistant_util.h"
#include "ash/highlighter/highlighter_controller.h"
#include "ash/highlighter/highlighter_controller_test_api.h"
#include "ash/public/cpp/ash_pref_names.h"
......@@ -243,6 +244,8 @@ class PaletteTrayTestWithAssistant : public PaletteTrayTest {
// PaletteTrayTest:
void SetUp() override {
assistant::util::OverrideIsGoogleDeviceForTesting();
PaletteTrayTest::SetUp();
// Instantiate EventGenerator now so that its constructor does not overwrite
......
......@@ -6,13 +6,13 @@
#include <memory>
#include "ash/assistant/util/assistant_util.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/palette/palette_tray.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "ui/aura/window.h"
......@@ -58,9 +58,10 @@ class PaletteWelcomeBubble::WelcomeBubbleView
void Init() override {
SetLayoutManager(std::make_unique<views::FillLayout>());
// TODO(crbug.com/996312): Check if the board type is eligibile here.
auto* label = new views::Label(l10n_util::GetStringUTF16(
IDS_ASH_STYLUS_WARM_WELCOME_BUBBLE_WITH_ASSISTANT_DESCRIPTION));
assistant::util::IsGoogleDevice()
? IDS_ASH_STYLUS_WARM_WELCOME_BUBBLE_WITH_ASSISTANT_DESCRIPTION
: IDS_ASH_STYLUS_WARM_WELCOME_BUBBLE_DESCRIPTION));
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetMultiLine(true);
label->SizeToFit(kBubbleContentLabelPreferredWidthDp);
......
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