| // Copyright 2020 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef ASH_HUD_DISPLAY_HUD_SETTINGS_VIEW_H_ |
| #define ASH_HUD_DISPLAY_HUD_SETTINGS_VIEW_H_ |
| |
| #include <memory> |
| #include <vector> |
| |
| #include "ash/hud_display/ash_tracing_manager.h" |
| #include "ash/hud_display/hud_constants.h" |
| #include "base/memory/weak_ptr.h" |
| #include "ui/views/view.h" |
| |
| namespace ui { |
| class Event; |
| } |
| |
| namespace views { |
| class Label; |
| class LabelButton; |
| } |
| |
| namespace ash { |
| namespace hud_display { |
| |
| class HUDCheckboxHandler; |
| class HUDDisplayView; |
| |
| namespace { |
| class HUDActionButton; |
| } |
| |
| class HUDSettingsView : public AshTracingManager::Observer, public views::View { |
| public: |
| METADATA_HEADER(HUDSettingsView); |
| |
| explicit HUDSettingsView(HUDDisplayView* hud_display); |
| ~HUDSettingsView() override; |
| |
| HUDSettingsView(const HUDSettingsView&) = delete; |
| HUDSettingsView& operator=(const HUDSettingsView&) = delete; |
| |
| // AshTracingManager::Observer |
| void OnTracingStatusChange() override; |
| |
| // Shows/hides the view. |
| void ToggleVisibility(); |
| |
| // Creates Ui Dev Tools. |
| void OnEnableUiDevToolsButtonPressed(const ui::Event& event); |
| |
| // Starts tracing. |
| void OnEnableTracingButtonPressed(const ui::Event& event); |
| |
| ASH_EXPORT void ToggleTracingForTesting(); |
| |
| private: |
| // Starts/Stops tracing. |
| void ToggleTracing(); |
| |
| // Replace "Create Ui Dev Tools" button label with "DevTools running". |
| void UpdateDevToolsControlButtonLabel(); |
| |
| // Switches between "Start tracing" and "Stop tracing" button labels. |
| void UpdateTracingControlButton(); |
| |
| std::vector<std::unique_ptr<HUDCheckboxHandler>> checkbox_handlers_; |
| |
| // Container for "Create Ui Dev Tools" button or "DevTools running" label. |
| views::LabelButton* ui_dev_tools_control_button_ = nullptr; |
| |
| HUDActionButton* tracing_control_button_ = nullptr; |
| views::Label* tracing_status_message_ = nullptr; |
| |
| base::WeakPtrFactory<HUDSettingsView> weak_factory_{this}; |
| }; |
| |
| } // namespace hud_display |
| } // namespace ash |
| |
| #endif // ASH_HUD_DISPLAY_HUD_SETTINGS_VIEW_H_ |