OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.externalnav; | 5 package org.chromium.chrome.browser.externalnav; |
6 | 6 |
7 import org.chromium.chrome.browser.tab.Tab; | 7 import org.chromium.chrome.browser.tab.Tab; |
8 import org.chromium.chrome.browser.tab.TabRedirectHandler; | 8 import org.chromium.chrome.browser.tab.TabRedirectHandler; |
9 | 9 |
10 /** | 10 /** |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 /** Whether the intent should force a new tab to open. */ | 37 /** Whether the intent should force a new tab to open. */ |
38 private final boolean mOpenInNewTab; | 38 private final boolean mOpenInNewTab; |
39 | 39 |
40 /** Whether this navigation happens in background tab. */ | 40 /** Whether this navigation happens in background tab. */ |
41 private final boolean mIsBackgroundTabNavigation; | 41 private final boolean mIsBackgroundTabNavigation; |
42 | 42 |
43 /** Whether this navigation happens in main frame. */ | 43 /** Whether this navigation happens in main frame. */ |
44 private final boolean mIsMainFrame; | 44 private final boolean mIsMainFrame; |
45 | 45 |
| 46 /** Whether this navigation is launched by user gesture. */ |
| 47 private final boolean mHasUserGesture; |
| 48 |
46 /** | 49 /** |
47 * Whether the current tab should be closed when an URL load was overridden
and an | 50 * Whether the current tab should be closed when an URL load was overridden
and an |
48 * intent launched. | 51 * intent launched. |
49 */ | 52 */ |
50 private final boolean mShouldCloseContentsOnOverrideUrlLoadingAndLaunchInten
t; | 53 private final boolean mShouldCloseContentsOnOverrideUrlLoadingAndLaunchInten
t; |
51 | 54 |
52 private ExternalNavigationParams(String url, boolean isIncognito, String ref
errerUrl, | 55 private ExternalNavigationParams(String url, boolean isIncognito, String ref
errerUrl, |
53 int pageTransition, boolean isRedirect, boolean appMustBeInForegroun
d, | 56 int pageTransition, boolean isRedirect, boolean appMustBeInForegroun
d, |
54 TabRedirectHandler redirectHandler, Tab tab, | 57 TabRedirectHandler redirectHandler, Tab tab, boolean openInNewTab, |
55 boolean openInNewTab, boolean isBackgroundTabNavigation, boolean isM
ainFrame, | 58 boolean isBackgroundTabNavigation, boolean isMainFrame, boolean hasU
serGesture, |
56 boolean shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent) { | 59 boolean shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent) { |
57 mUrl = url; | 60 mUrl = url; |
58 mIsIncognito = isIncognito; | 61 mIsIncognito = isIncognito; |
59 mPageTransition = pageTransition; | 62 mPageTransition = pageTransition; |
60 mReferrerUrl = referrerUrl; | 63 mReferrerUrl = referrerUrl; |
61 mIsRedirect = isRedirect; | 64 mIsRedirect = isRedirect; |
62 mApplicationMustBeInForeground = appMustBeInForeground; | 65 mApplicationMustBeInForeground = appMustBeInForeground; |
63 mRedirectHandler = redirectHandler; | 66 mRedirectHandler = redirectHandler; |
64 mTab = tab; | 67 mTab = tab; |
65 mOpenInNewTab = openInNewTab; | 68 mOpenInNewTab = openInNewTab; |
66 mIsBackgroundTabNavigation = isBackgroundTabNavigation; | 69 mIsBackgroundTabNavigation = isBackgroundTabNavigation; |
67 mIsMainFrame = isMainFrame; | 70 mIsMainFrame = isMainFrame; |
| 71 mHasUserGesture = hasUserGesture; |
68 mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent = | 72 mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent = |
69 shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; | 73 shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; |
70 } | 74 } |
71 | 75 |
72 /** @return The URL to potentially open externally. */ | 76 /** @return The URL to potentially open externally. */ |
73 public String getUrl() { | 77 public String getUrl() { |
74 return mUrl; | 78 return mUrl; |
75 } | 79 } |
76 | 80 |
77 /** @return Whether we are currently in incognito mode. */ | 81 /** @return Whether we are currently in incognito mode. */ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 /** @return Whether this navigation happens in background tab. */ | 124 /** @return Whether this navigation happens in background tab. */ |
121 public boolean isBackgroundTabNavigation() { | 125 public boolean isBackgroundTabNavigation() { |
122 return mIsBackgroundTabNavigation; | 126 return mIsBackgroundTabNavigation; |
123 } | 127 } |
124 | 128 |
125 /** @return Whether this navigation happens in main frame. */ | 129 /** @return Whether this navigation happens in main frame. */ |
126 public boolean isMainFrame() { | 130 public boolean isMainFrame() { |
127 return mIsMainFrame; | 131 return mIsMainFrame; |
128 } | 132 } |
129 | 133 |
| 134 /** @return Whether this navigation is launched by user gesture. */ |
| 135 public boolean hasUserGesture() { |
| 136 return mHasUserGesture; |
| 137 } |
| 138 |
130 /** | 139 /** |
131 * @return Whether the current tab should be closed when an URL load was ove
rridden and an | 140 * @return Whether the current tab should be closed when an URL load was ove
rridden and an |
132 * intent launched. | 141 * intent launched. |
133 */ | 142 */ |
134 public boolean shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent() { | 143 public boolean shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent() { |
135 return mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; | 144 return mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; |
136 } | 145 } |
137 | 146 |
138 /** The builder for {@link ExternalNavigationParams} objects. */ | 147 /** The builder for {@link ExternalNavigationParams} objects. */ |
139 public static class Builder { | 148 public static class Builder { |
(...skipping 22 matching lines...) Expand all Loading... |
162 | 171 |
163 /** Whether the intent should force a new tab to open. */ | 172 /** Whether the intent should force a new tab to open. */ |
164 private boolean mOpenInNewTab; | 173 private boolean mOpenInNewTab; |
165 | 174 |
166 /** Whether this navigation happens in background tab. */ | 175 /** Whether this navigation happens in background tab. */ |
167 private boolean mIsBackgroundTabNavigation; | 176 private boolean mIsBackgroundTabNavigation; |
168 | 177 |
169 /** Whether this navigation happens in main frame. */ | 178 /** Whether this navigation happens in main frame. */ |
170 private boolean mIsMainFrame; | 179 private boolean mIsMainFrame; |
171 | 180 |
| 181 /** Whether this navigation is launched by user gesture. */ |
| 182 private boolean mHasUserGesture; |
| 183 |
172 /** | 184 /** |
173 * Whether the current tab should be closed when an URL load was overrid
den and an | 185 * Whether the current tab should be closed when an URL load was overrid
den and an |
174 * intent launched. | 186 * intent launched. |
175 */ | 187 */ |
176 private boolean mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; | 188 private boolean mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent; |
177 | 189 |
178 public Builder(String url, boolean isIncognito) { | 190 public Builder(String url, boolean isIncognito) { |
179 mUrl = url; | 191 mUrl = url; |
180 mIsIncognito = isIncognito; | 192 mIsIncognito = isIncognito; |
181 } | 193 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 mIsBackgroundTabNavigation = v; | 230 mIsBackgroundTabNavigation = v; |
219 return this; | 231 return this; |
220 } | 232 } |
221 | 233 |
222 /** Sets whether this navigation happens in main frame. */ | 234 /** Sets whether this navigation happens in main frame. */ |
223 public Builder setIsMainFrame(boolean v) { | 235 public Builder setIsMainFrame(boolean v) { |
224 mIsMainFrame = v; | 236 mIsMainFrame = v; |
225 return this; | 237 return this; |
226 } | 238 } |
227 | 239 |
| 240 /** Sets whether this navigation happens in main frame. */ |
| 241 public Builder setHasUserGesture(boolean v) { |
| 242 mHasUserGesture = v; |
| 243 return this; |
| 244 } |
| 245 |
228 /** Sets whether the current tab should be closed when an URL load was o
verridden and an | 246 /** Sets whether the current tab should be closed when an URL load was o
verridden and an |
229 * intent launched. | 247 * intent launched. |
230 */ | 248 */ |
231 public Builder setShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent
(boolean v) { | 249 public Builder setShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent
(boolean v) { |
232 mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent = v; | 250 mShouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent = v; |
233 return this; | 251 return this; |
234 } | 252 } |
235 | 253 |
236 /** @return A fully constructed {@link ExternalNavigationParams} object.
*/ | 254 /** @return A fully constructed {@link ExternalNavigationParams} object.
*/ |
237 public ExternalNavigationParams build() { | 255 public ExternalNavigationParams build() { |
238 return new ExternalNavigationParams(mUrl, mIsIncognito, mReferrerUrl
, mPageTransition, | 256 return new ExternalNavigationParams(mUrl, mIsIncognito, mReferrerUrl
, mPageTransition, |
239 mIsRedirect, mApplicationMustBeInForeground, mRedirectHandle
r, | 257 mIsRedirect, mApplicationMustBeInForeground, mRedirectHandle
r, |
240 mTab, mOpenInNewTab, mIsBackgroundTabNavigation, | 258 mTab, mOpenInNewTab, mIsBackgroundTabNavigation, mIsMainFram
e, |
241 mIsMainFrame, mShouldCloseContentsOnOverrideUrlLoadingAndLau
nchIntent); | 259 mHasUserGesture, mShouldCloseContentsOnOverrideUrlLoadingAnd
LaunchIntent); |
242 } | 260 } |
243 } | 261 } |
244 } | 262 } |
OLD | NEW |