Commit c70d4cc3 authored by Angela Gyi's avatar Angela Gyi Committed by Chromium LUCI CQ

[Sharesheet] Add File Title Preview for Content Previews.

This CL adds a single file title preview for share sheet feature on Chrome OS devices.

Note: This feature is not in its final form and is still open to extension

Bug: 1157628

Change-Id: I44acc5a0c3fc231e66f1a77b77542d39931bb772
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584632
Commit-Queue: Angela Gyi <angelagyi@google.com>
Reviewed-by: default avatarMaggie Cai <mxcai@chromium.org>
Reviewed-by: default avatarMelissa Zhang <melzhang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841382}
parent d5c951e8
...@@ -38,7 +38,6 @@ SharesheetActionCache::SharesheetActionCache() { ...@@ -38,7 +38,6 @@ SharesheetActionCache::SharesheetActionCache() {
AddShareAction(std::make_unique<ExampleAction>()); AddShareAction(std::make_unique<ExampleAction>());
AddShareAction(std::make_unique<ExampleAction>()); AddShareAction(std::make_unique<ExampleAction>());
AddShareAction(std::make_unique<ExampleAction>()); AddShareAction(std::make_unique<ExampleAction>());
AddShareAction(std::make_unique<ExampleAction>());
} }
#endif #endif
} }
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sharesheet/sharesheet_metrics.h" #include "chrome/browser/sharesheet/sharesheet_metrics.h"
#include "chrome/browser/sharesheet/sharesheet_service_delegate.h" #include "chrome/browser/sharesheet/sharesheet_service_delegate.h"
#include "chrome/browser/ui/ash/sharesheet/sharesheet_expand_button.h" #include "chrome/browser/ui/ash/sharesheet/sharesheet_expand_button.h"
#include "chrome/browser/ui/ash/sharesheet/sharesheet_target_button.h" #include "chrome/browser/ui/ash/sharesheet/sharesheet_target_button.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "extensions/browser/app_window/app_window.h" #include "extensions/browser/app_window/app_window.h"
...@@ -165,6 +167,24 @@ void SharesheetBubbleView::ShowBubble( ...@@ -165,6 +167,24 @@ void SharesheetBubbleView::ShowBubble(
title->SetHorizontalAlignment(gfx::ALIGN_LEFT); title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title->SetProperty(views::kMarginsKey, gfx::Insets(kSpacing)); title->SetProperty(views::kMarginsKey, gfx::Insets(kSpacing));
// Add content preview text descriptor.
if (base::FeatureList::IsEnabled(features::kSharesheetContentPreviews) &&
(intent_->file_urls.has_value())) {
// Remove the margin under the title for file_title
title->SetProperty(views::kMarginsKey,
gfx::Insets(kSpacing, kSpacing, 0, kSpacing));
// This displays text data only for the first file_url provided.
auto* file_title = main_view_->AddChildView(std::make_unique<views::Label>(
base::ASCIIToUTF16(
(intent_->file_urls.value().front().ExtractFileName())),
ash::CONTEXT_SHARESHEET_BUBBLE_BODY_SECONDARY));
file_title->SetLineHeight(kTitleLineHeight);
file_title->SetEnabledColor(kShareTargetTitleColor);
file_title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
file_title->SetProperty(views::kMarginsKey,
gfx::Insets(3, kSpacing, kSpacing, kSpacing));
}
if (targets.empty()) { if (targets.empty()) {
auto* image = auto* image =
main_view_->AddChildView(std::make_unique<views::ImageView>()); main_view_->AddChildView(std::make_unique<views::ImageView>());
...@@ -210,6 +230,11 @@ void SharesheetBubbleView::ShowBubble( ...@@ -210,6 +230,11 @@ void SharesheetBubbleView::ShowBubble(
expand_button_separator_->SetVisible(false); expand_button_separator_->SetVisible(false);
} }
UpdateAnchorPosition(); UpdateAnchorPosition();
// Expanding the sharesheet is needed for content previews
if (base::FeatureList::IsEnabled(features::kSharesheetContentPreviews)) {
ResizeBubble(kDefaultBubbleWidth, GetBubbleHeight());
}
} }
std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView( std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView(
...@@ -510,8 +535,7 @@ void SharesheetBubbleView::CreateBubble() { ...@@ -510,8 +535,7 @@ void SharesheetBubbleView::CreateBubble() {
void SharesheetBubbleView::ExpandButtonPressed() { void SharesheetBubbleView::ExpandButtonPressed() {
show_expanded_view_ = !show_expanded_view_; show_expanded_view_ = !show_expanded_view_;
ResizeBubble(kDefaultBubbleWidth, show_expanded_view_ ? kExpandedBubbleHeight ResizeBubble(kDefaultBubbleWidth, GetBubbleHeight());
: kDefaultBubbleHeight);
// Scrollview has separators that overlaps with |expand_button_separator_| // Scrollview has separators that overlaps with |expand_button_separator_|
// to create a double line when both are visible, so when scrollview is // to create a double line when both are visible, so when scrollview is
...@@ -580,7 +604,7 @@ void SharesheetBubbleView::UpdateAnchorPosition() { ...@@ -580,7 +604,7 @@ void SharesheetBubbleView::UpdateAnchorPosition() {
void SharesheetBubbleView::SetToDefaultBubbleSizing() { void SharesheetBubbleView::SetToDefaultBubbleSizing() {
width_ = kDefaultBubbleWidth; width_ = kDefaultBubbleWidth;
height_ = kDefaultBubbleHeight; height_ = GetBubbleHeight();
} }
void SharesheetBubbleView::ShowWidgetWithAnimateFadeIn() { void SharesheetBubbleView::ShowWidgetWithAnimateFadeIn() {
...@@ -641,6 +665,16 @@ void SharesheetBubbleView::CloseWidgetWithReason( ...@@ -641,6 +665,16 @@ void SharesheetBubbleView::CloseWidgetWithReason(
delegate_->OnBubbleClosed(active_target_); delegate_->OnBubbleClosed(active_target_);
} }
int SharesheetBubbleView::GetBubbleHeight() {
int height =
show_expanded_view_ ? kExpandedBubbleHeight : kDefaultBubbleHeight;
if (base::FeatureList::IsEnabled(features::kSharesheetContentPreviews)) {
height += kTitleLineHeight + 3;
}
return height;
}
void SharesheetBubbleView::RecordFormFactorMetric() { void SharesheetBubbleView::RecordFormFactorMetric() {
auto form_factor = auto form_factor =
ash::TabletMode::Get()->InTabletMode() ash::TabletMode::Get()->InTabletMode()
......
...@@ -73,6 +73,7 @@ class SharesheetBubbleView : public views::BubbleDialogDelegateView { ...@@ -73,6 +73,7 @@ class SharesheetBubbleView : public views::BubbleDialogDelegateView {
void ShowWidgetWithAnimateFadeIn(); void ShowWidgetWithAnimateFadeIn();
void CloseWidgetWithAnimateFadeOut(views::Widget::ClosedReason closed_reason); void CloseWidgetWithAnimateFadeOut(views::Widget::ClosedReason closed_reason);
void CloseWidgetWithReason(views::Widget::ClosedReason closed_reason); void CloseWidgetWithReason(views::Widget::ClosedReason closed_reason);
int GetBubbleHeight();
void RecordFormFactorMetric(); void RecordFormFactorMetric();
// Owns this class. // Owns this class.
......
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