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
|
// 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_VIEWS_PAGE_ACTION_PAGE_ACTION_CONTAINER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_CONTAINER_VIEW_H_
#include <list>
#include <map>
#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
#include "ui/actions/action_id.h"
#include "ui/views/layout/box_layout_view.h"
namespace page_actions {
class PageActionController;
class PageActionView;
class PageActionPropertiesProviderInterface;
struct PageActionViewParams;
// PageActionContainerView is the parent view of all PageActionViews.
class PageActionContainerView : public views::View {
METADATA_HEADER(PageActionContainerView, views::View)
public:
DECLARE_CLASS_ELEMENT_IDENTIFIER_VALUE(kPageActionContainerViewElementId);
PageActionContainerView(
const std::vector<actions::ActionItem*>& action_items,
const PageActionPropertiesProviderInterface& properties_provider,
const PageActionViewParams& params);
PageActionContainerView(const PageActionContainerView&) = delete;
PageActionContainerView& operator=(const PageActionContainerView&) = delete;
~PageActionContainerView() override;
// Sets the active PageActionController for each PageActionView.
void SetController(PageActionController* controller);
// Gets the PageActionView associated with the given action id. Returns
// nullptr if not found.
PageActionView* GetPageActionView(actions::ActionId page_action_id);
private:
// Invoked when the chip state changes. When the view's suggestion chip is
// shown, it is placed in the front before all other page action view.
// Otherwise, the page action is placed in its initial insertion position.
void OnPageActionSuggestionChipStateChanged(PageActionView* view);
std::map<actions::ActionId, raw_ptr<PageActionView>> page_action_views_;
std::map<actions::ActionId, int> page_action_view_initial_indices_;
// Callbacks used to handle page action view chip state changes. Used to
// ensure that the container reorders the page actions accordingly.
std::vector<base::CallbackListSubscription> chip_state_changed_callbacks_;
};
} // namespace page_actions
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_CONTAINER_VIEW_H_
|