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 85 86 87 88 89 90 91 92
|
// Copyright 2016 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_CHROMEOS_ARC_ARC_EXTERNAL_PROTOCOL_DIALOG_H_
#define CHROME_BROWSER_CHROMEOS_ARC_ARC_EXTERNAL_PROTOCOL_DIALOG_H_
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "chrome/browser/apps/link_capturing/intent_picker_info.h"
#include "chromeos/ash/experiences/arc/intent_helper/arc_icon_cache_delegate.h"
#include "chromeos/ash/experiences/arc/intent_helper/arc_intent_helper_mojo_delegate.h"
#include "ui/base/page_transition_types.h"
#include "url/origin.h"
class GURL;
class SharingTargetDeviceInfo;
namespace content {
class WebContents;
} // namespace content
namespace arc {
using GurlAndActivityInfo = std::pair<GURL, ArcIconCacheDelegate::ActivityName>;
// An enum returned from GetAction function. This is visible for testing.
enum class GetActionResult {
// ARC cannot handle the |original_url|, but the URL did have a fallback URL
// which Chrome can handle. Chrome should show the fallback URL now.
OPEN_URL_IN_CHROME,
// ARC can handle the |original_url|, and one of the ARC activities is a
// preferred one. ARC should handle the URL now.
HANDLE_URL_IN_ARC,
// Chrome should show the disambig UI because 1) ARC can handle the
// |original_url| but none of the ARC activities is a preferred one, or
// 2) there are two or more browsers (e.g. Chrome and a browser app in ARC)
// that can handle a fallback URL.
ASK_USER,
};
// Checks if ARC is supported, running, and in a context where it is allowed to
// handle external protocol, then either shows the dialog, or directly launches
// the app if a user has previously made a choice. Invokes |handled_cb| with
// true if the protocol has been handled by ARC.
void RunArcExternalProtocolDialog(
const GURL& url,
const std::optional<url::Origin>& initiating_origin,
base::WeakPtr<content::WebContents> web_contents,
ui::PageTransition page_transition,
bool has_user_gesture,
bool is_in_fenced_frame_tree,
std::unique_ptr<ArcIntentHelperMojoDelegate> mojo_delegate,
base::OnceCallback<void(bool)> handled_cb);
GetActionResult GetActionForTesting(
const GURL& original_url,
const std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo>& handlers,
size_t selected_app_index,
GurlAndActivityInfo* out_url_and_activity_name,
bool* safe_to_bypass_ui);
GURL GetUrlToNavigateOnDeactivateForTesting(
const std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo>&
handlers);
bool GetAndResetSafeToRedirectToArcWithoutUserConfirmationFlagForTesting(
content::WebContents* web_contents);
bool IsChromeAnAppCandidateForTesting(
const std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo>&
handlers);
void OnIntentPickerClosedForTesting(
base::WeakPtr<content::WebContents> web_contents,
const GURL& url,
bool safe_to_bypass_ui,
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers,
std::unique_ptr<ArcIntentHelperMojoDelegate> mojo_delegate,
std::vector<SharingTargetDeviceInfo> devices,
const std::string& selected_app_package,
apps::PickerEntryType entry_type,
apps::IntentPickerCloseReason reason,
bool should_persist);
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_EXTERNAL_PROTOCOL_DIALOG_H_
|