#include "components/services/app_service/public/cpp/intent_util.h"
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "third_party/blink/public/common/mime_util/mime_util.h"
namespace {
const char kWildCardAny[] = …;
const char kMimeTypeSeparator[] = …;
constexpr size_t kMimeTypeComponentSize = …;
const char kAuthorityHostPortSeparator[] = …;
const char kActionKey[] = …;
const char kUrlKey[] = …;
const char kMimeTypeKey[] = …;
const char kFileUrlsKey[] = …;
const char kActivityNameKey[] = …;
const char kDriveShareUrlKey[] = …;
const char kShareTextKey[] = …;
const char kShareTitleKey[] = …;
const char kStartTypeKey[] = …;
const char kCategoriesKey[] = …;
const char kDataKey[] = …;
const char kUiBypassedKey[] = …;
const char kExtrasKey[] = …;
const char kMimeTypeInodeDirectory[] = …;
bool ComponentMatched(const std::string& intent_component,
const std::string& filter_component) { … }
}
namespace apps_util {
const char kIntentActionMain[] = …;
const char kIntentActionView[] = …;
const char kIntentActionSend[] = …;
const char kIntentActionSendMultiple[] = …;
const char kIntentActionCreateNote[] = …;
const char kIntentActionStartOnLockScreen[] = …;
const char kIntentActionEdit[] = …;
const char kIntentActionPotentialFileHandler[] = …;
const char kUseBrowserForLink[] = …;
const char kGuestOsActivityName[] = …;
apps::IntentPtr MakeShareIntent(const std::vector<GURL>& filesystem_urls,
const std::vector<std::string>& mime_types) { … }
apps::IntentPtr MakeShareIntent(const std::vector<GURL>& filesystem_urls,
const std::vector<std::string>& mime_types,
const std::string& text,
const std::string& title) { … }
apps::IntentPtr MakeShareIntent(const GURL& filesystem_url,
const std::string& mime_type,
const GURL& drive_share_url,
bool is_directory) { … }
apps::IntentPtr MakeShareIntent(const std::string& text,
const std::string& title) { … }
apps::IntentPtr MakeShareIntent(
const std::vector<GURL>& filesystem_urls,
const std::vector<std::string>& mime_types,
const std::vector<std::string>& dlp_source_urls) { … }
apps::IntentPtr MakeEditIntent(const GURL& filesystem_url,
const std::string& mime_type) { … }
apps::IntentPtr MakeIntentForActivity(const std::string& activity,
const std::string& start_type,
const std::string& category) { … }
apps::IntentPtr CreateCreateNoteIntent() { … }
apps::IntentPtr CreateStartOnLockScreenIntent() { … }
bool ConditionValueMatches(std::string_view value,
const apps::ConditionValuePtr& condition_value) { … }
bool PatternMatchValue(std::string_view test_value,
apps::PatternMatchType match_type,
std::string_view match_value) { … }
bool IsGenericFileHandler(const apps::IntentPtr& intent,
const apps::IntentFilterPtr& filter) { … }
bool MatchGlob(std::string_view value, std::string_view pattern) { … }
bool MimeTypeMatched(std::string_view intent_mime_type,
std::string_view filter_mime_type) { … }
bool ExtensionMatched(const std::string& file_name,
const std::string& filter_extension) { … }
base::Value ConvertIntentToValue(const apps::IntentPtr& intent) { … }
std::optional<std::string> GetStringValueFromDict(const base::Value::Dict& dict,
const std::string& key_name) { … }
std::optional<bool> GetBoolValueFromDict(const base::Value::Dict& dict,
const std::string& key_name) { … }
std::optional<GURL> GetGurlValueFromDict(const base::Value::Dict& dict,
const std::string& key_name) { … }
std::vector<apps::IntentFilePtr> GetFilesFromDict(const base::Value::Dict& dict,
const std::string& key_name) { … }
std::vector<std::string> GetCategoriesFromDict(const base::Value::Dict& dict,
const std::string& key_name) { … }
base::flat_map<std::string, std::string> GetExtrasFromDict(
const base::Value::Dict& dict,
const std::string& key_name) { … }
apps::IntentPtr ConvertValueToIntent(base::Value&& value) { … }
apps::IntentPtr ConvertDictToIntent(const base::Value::Dict& dict) { … }
std::string CalculateCommonMimeType(
const std::vector<std::string>& mime_types) { … }
SharedText ExtractSharedText(const std::string& share_text) { … }
std::optional<std::string> AuthorityView::PortToString(const GURL& url) { … }
std::optional<std::string> AuthorityView::PortToString(
const url::Origin& origin) { … }
AuthorityView AuthorityView::Decode(std::string_view encoded_string) { … }
std::string AuthorityView::Encode(const GURL& url) { … }
std::string AuthorityView::Encode(const url::Origin& origin) { … }
std::string AuthorityView::Encode() { … }
}