1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_EDITOR_MENU_EDITOR_MANAGER_ASH_H_
#define CHROME_BROWSER_UI_ASH_EDITOR_MENU_EDITOR_MANAGER_ASH_H_
#include <string_view>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/ash/input_method/editor_consent_enums.h"
#include "chrome/browser/ash/input_method/editor_panel_manager.h"
#include "chrome/browser/ui/ash/editor_menu/editor_manager.h"
#include "chromeos/ash/components/editor_menu/public/cpp/editor_context.h"
#include "chromeos/ash/components/editor_menu/public/cpp/editor_mode.h"
namespace chromeos::editor_menu {
class EditorManagerAsh : public EditorManager {
public:
explicit EditorManagerAsh(
ash::input_method::EditorPanelManagerImpl* panel_manager);
~EditorManagerAsh() override;
// EditorManager overrides
void GetEditorPanelContext(
base::OnceCallback<void(const EditorContext&)> callback) override;
void OnPromoCardDismissed() override;
void OnPromoCardDeclined() override;
void StartEditingFlow() override;
void StartEditingFlowWithPreset(std::string_view text_query_id) override;
void StartEditingFlowWithFreeform(std::string_view text) override;
void OnEditorMenuVisibilityChanged(bool visible) override;
void LogEditorMode(EditorMode mode) override;
void AddObserver(EditorManager::Observer* observer) override;
void RemoveObserver(EditorManager::Observer* observer) override;
void NotifyEditorModeChanged(EditorMode mode) override;
void RequestCacheContext() override;
private:
class AshObserver
: public ash::input_method::EditorPanelManagerImpl::Observer {
public:
explicit AshObserver(EditorManagerAsh* manager);
~AshObserver() override;
// EditorObserver overrides
void OnEditorModeChanged(EditorMode mode) override;
private:
// Not owned by this class
raw_ptr<EditorManagerAsh> manager_;
};
void OnEditorPanelContextResult(
base::OnceCallback<void(const EditorContext&)> callback,
const EditorContext& editor_context);
raw_ptr<ash::input_method::EditorPanelManagerImpl> panel_manager_;
AshObserver ash_observer_;
base::ObserverList<EditorManager::Observer> observers_;
base::WeakPtrFactory<EditorManagerAsh> weak_factory_{this};
};
} // namespace chromeos::editor_menu
#endif // CHROME_BROWSER_UI_ASH_EDITOR_MENU_EDITOR_MANAGER_ASH_H_
|