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 74 75 76 77 78 79 80 81 82 83 84
|
// Copyright 2023 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_DOWNLOAD_BUBBLE_DOWNLOAD_BUBBLE_PRIMARY_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_BUBBLE_DOWNLOAD_BUBBLE_PRIMARY_VIEW_H_
#include <string_view>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/download/download_ui_model.h"
#include "chrome/browser/ui/download/download_bubble_row_list_view_info.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/layout/flex_layout_view.h"
class Browser;
class DownloadBubbleNavigationHandler;
class DownloadBubbleRowListView;
class DownloadBubbleRowView;
class DownloadBubbleUIController;
namespace offline_items_collection {
struct ContentId;
}
namespace views {
class ScrollView;
class View;
} // namespace views
// Base class for either type of primary view (partial or main). Consists of
// an optional header, a scrolling view for the download rows, and an optional
// footer.
class DownloadBubblePrimaryView : public views::FlexLayoutView {
METADATA_HEADER(DownloadBubblePrimaryView, views::FlexLayoutView)
public:
DownloadBubblePrimaryView();
~DownloadBubblePrimaryView() override;
DownloadBubblePrimaryView(const DownloadBubblePrimaryView&) = delete;
DownloadBubblePrimaryView& operator=(const DownloadBubblePrimaryView&) =
delete;
// Gets the row view with the given id. Returns nullptr if not found.
DownloadBubbleRowView* GetRow(const offline_items_collection::ContentId& id);
// The view to focus first when the bubble is created. By default, returns
// the transparent button (main button) of the first row in the row list.
virtual views::View* GetInitiallyFocusedView();
// Gets the row view at the given index.
DownloadBubbleRowView* GetRowForTesting(size_t index);
views::ScrollView* scroll_view_for_testing() { return scroll_view_; }
protected:
// TODO(crbug.com/40853007): Add support for refreshing the scroll view
// contents.
void BuildAndAddScrollView(
base::WeakPtr<Browser> browser,
base::WeakPtr<DownloadBubbleUIController> bubble_controller,
base::WeakPtr<DownloadBubbleNavigationHandler> navigation_handler,
const DownloadBubbleRowListViewInfo& info,
int fixed_width);
int DefaultPreferredWidth() const;
// Maybe show the banner informing the user that any files downloaded
// in OTR mode are visible to anyone on the device.
void MaybeAddOtrInfoRow(Browser* browser);
private:
// The ScrollView holding the DownloadBubbleRowListView with the download
// rows.
raw_ptr<views::ScrollView> scroll_view_ = nullptr;
// The contents contained in the above `scroll_view_`.
raw_ptr<DownloadBubbleRowListView> row_list_view_ = nullptr;
// Time when this view was created, for metrics.
base::Time creation_time_;
};
#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_BUBBLE_DOWNLOAD_BUBBLE_PRIMARY_VIEW_H_
|