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

[Sharesheet] Example ShareAction

This CL adds a single example of a ShareAction for
testing the content previews feature on Chrome
OS devices.

Bug: 1159279
Change-Id: Ia8e0e5dfbc00ab664468667363ece01f4b71ad1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592276Reviewed-by: default avatarMelissa Zhang <melzhang@chromium.org>
Commit-Queue: Angela Gyi <angelagyi@google.com>
Cr-Commit-Position: refs/heads/master@{#840058}
parent c60320d3
......@@ -1607,6 +1607,8 @@ static_library("browser") {
"sessions/session_tab_helper_factory.h",
"sessions/tab_restore_service_factory.cc",
"sessions/tab_restore_service_factory.h",
"sharesheet/example_action.cc",
"sharesheet/example_action.h",
"sharesheet/share_action.cc",
"sharesheet/share_action.h",
"sharesheet/sharesheet_action_cache.cc",
......
// 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.
#include "chrome/browser/sharesheet/example_action.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/sharesheet/sharesheet_types.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
ExampleAction::ExampleAction() {
name_ = "example";
}
ExampleAction::~ExampleAction() = default;
const base::string16 ExampleAction::GetActionName() {
return base::ASCIIToUTF16(name_);
}
const gfx::VectorIcon& ExampleAction::GetActionIcon() {
return kAddIcon;
}
void ExampleAction::LaunchAction(sharesheet::SharesheetController* controller,
views::View* root_view,
apps::mojom::IntentPtr intent) {
LOG(ERROR) << "ExampleAction launches.";
controller_ = controller;
controller_->CloseSharesheet();
}
void ExampleAction::OnClosing(sharesheet::SharesheetController* controller) {
LOG(ERROR) << "ExampleAction knows it needs to spin down now.";
controller_ = nullptr;
}
// 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 CHROME_BROWSER_SHARESHEET_EXAMPLE_ACTION_H_
#define CHROME_BROWSER_SHARESHEET_EXAMPLE_ACTION_H_
#include "chrome/browser/sharesheet/share_action.h"
class ExampleAction : public sharesheet::ShareAction {
public:
ExampleAction();
~ExampleAction() override;
ExampleAction(const ExampleAction&) = delete;
ExampleAction& operator=(const ExampleAction&) = delete;
const base::string16 GetActionName() override;
const gfx::VectorIcon& GetActionIcon() override;
void LaunchAction(sharesheet::SharesheetController* controller,
views::View* root_view,
apps::mojom::IntentPtr intent) override;
void OnClosing(sharesheet::SharesheetController* controller) override;
private:
sharesheet::SharesheetController* controller_ = nullptr;
std::string name_;
};
#endif // CHROME_BROWSER_SHARESHEET_EXAMPLE_ACTION_H_
......@@ -5,8 +5,11 @@
#include "chrome/browser/sharesheet/sharesheet_action_cache.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/sharesheet/example_action.h"
#include "chrome/browser/sharesheet/share_action.h"
#include "chrome/browser/sharesheet/sharesheet_types.h"
#include "chrome/common/chrome_features.h"
#include "ui/gfx/vector_icon_types.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
......@@ -24,6 +27,19 @@ SharesheetActionCache::SharesheetActionCache() {
AddShareAction(std::make_unique<NearbyShareAction>());
}
AddShareAction(std::make_unique<DriveShareAction>());
// Add 9 example actions to show expanded view
if (base::FeatureList::IsEnabled(features::kSharesheetContentPreviews)) {
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>());
AddShareAction(std::make_unique<ExampleAction>());
AddShareAction(std::make_unique<ExampleAction>());
AddShareAction(std::make_unique<ExampleAction>());
}
#endif
}
......
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