cbf_chrome/data/
browsing_context_open.rs1use cbf::data::browsing_context_open::{
4 BrowsingContextOpenHint, BrowsingContextOpenResponse, BrowsingContextOpenResult,
5};
6
7use super::ids::TabId;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum ChromeBrowsingContextOpenHint {
11 Unknown,
12 CurrentContext,
13 NewForegroundContext,
14 NewBackgroundContext,
15}
16
17impl From<ChromeBrowsingContextOpenHint> for BrowsingContextOpenHint {
18 fn from(value: ChromeBrowsingContextOpenHint) -> Self {
19 match value {
20 ChromeBrowsingContextOpenHint::Unknown => Self::Unknown,
21 ChromeBrowsingContextOpenHint::CurrentContext => Self::CurrentContext,
22 ChromeBrowsingContextOpenHint::NewForegroundContext => Self::NewForegroundContext,
23 ChromeBrowsingContextOpenHint::NewBackgroundContext => Self::NewBackgroundContext,
24 }
25 }
26}
27
28impl From<BrowsingContextOpenHint> for ChromeBrowsingContextOpenHint {
29 fn from(value: BrowsingContextOpenHint) -> Self {
30 match value {
31 BrowsingContextOpenHint::Unknown => Self::Unknown,
32 BrowsingContextOpenHint::CurrentContext => Self::CurrentContext,
33 BrowsingContextOpenHint::NewForegroundContext => Self::NewForegroundContext,
34 BrowsingContextOpenHint::NewBackgroundContext => Self::NewBackgroundContext,
35 }
36 }
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub enum ChromeBrowsingContextOpenResponse {
41 AllowNewContext { activate: bool },
42 AllowExistingContext { tab_id: TabId, activate: bool },
43 Deny,
44}
45
46impl From<ChromeBrowsingContextOpenResponse> for BrowsingContextOpenResponse {
47 fn from(value: ChromeBrowsingContextOpenResponse) -> Self {
48 match value {
49 ChromeBrowsingContextOpenResponse::AllowNewContext { activate } => {
50 Self::AllowNewContext { activate }
51 }
52 ChromeBrowsingContextOpenResponse::AllowExistingContext { tab_id, activate } => {
53 Self::AllowExistingContext {
54 browsing_context_id: tab_id.into(),
55 activate,
56 }
57 }
58 ChromeBrowsingContextOpenResponse::Deny => Self::Deny,
59 }
60 }
61}
62
63impl From<BrowsingContextOpenResponse> for ChromeBrowsingContextOpenResponse {
64 fn from(value: BrowsingContextOpenResponse) -> Self {
65 match value {
66 BrowsingContextOpenResponse::AllowNewContext { activate } => {
67 Self::AllowNewContext { activate }
68 }
69 BrowsingContextOpenResponse::AllowExistingContext {
70 browsing_context_id,
71 activate,
72 } => Self::AllowExistingContext {
73 tab_id: browsing_context_id.into(),
74 activate,
75 },
76 BrowsingContextOpenResponse::Deny => Self::Deny,
77 }
78 }
79}
80
81#[derive(Debug, Clone, Copy, PartialEq, Eq)]
82pub enum ChromeBrowsingContextOpenResult {
83 OpenedNewContext { tab_id: TabId },
84 OpenedExistingContext { tab_id: TabId },
85 Denied,
86 Aborted,
87}
88
89impl From<ChromeBrowsingContextOpenResult> for BrowsingContextOpenResult {
90 fn from(value: ChromeBrowsingContextOpenResult) -> Self {
91 match value {
92 ChromeBrowsingContextOpenResult::OpenedNewContext { tab_id } => {
93 Self::OpenedNewContext {
94 browsing_context_id: tab_id.into(),
95 }
96 }
97 ChromeBrowsingContextOpenResult::OpenedExistingContext { tab_id } => {
98 Self::OpenedExistingContext {
99 browsing_context_id: tab_id.into(),
100 }
101 }
102 ChromeBrowsingContextOpenResult::Denied => Self::Denied,
103 ChromeBrowsingContextOpenResult::Aborted => Self::Aborted,
104 }
105 }
106}
107
108impl From<BrowsingContextOpenResult> for ChromeBrowsingContextOpenResult {
109 fn from(value: BrowsingContextOpenResult) -> Self {
110 match value {
111 BrowsingContextOpenResult::OpenedNewContext {
112 browsing_context_id,
113 } => Self::OpenedNewContext {
114 tab_id: browsing_context_id.into(),
115 },
116 BrowsingContextOpenResult::OpenedExistingContext {
117 browsing_context_id,
118 } => Self::OpenedExistingContext {
119 tab_id: browsing_context_id.into(),
120 },
121 BrowsingContextOpenResult::Denied => Self::Denied,
122 BrowsingContextOpenResult::Aborted => Self::Aborted,
123 }
124 }
125}