OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.testshell; | 5 package org.chromium.chrome.testshell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
9 | 9 |
10 import org.chromium.chrome.browser.TabBase; | 10 import org.chromium.chrome.browser.Tab; |
11 import org.chromium.chrome.browser.UrlUtilities; | 11 import org.chromium.chrome.browser.UrlUtilities; |
12 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; | 12 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; |
13 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 13 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
14 import org.chromium.chrome.browser.infobar.AutoLoginProcessor; | 14 import org.chromium.chrome.browser.infobar.AutoLoginProcessor; |
15 import org.chromium.content.browser.ContentView; | 15 import org.chromium.content.browser.ContentView; |
16 import org.chromium.content.browser.ContentViewClient; | 16 import org.chromium.content.browser.ContentViewClient; |
17 import org.chromium.content.browser.LoadUrlParams; | 17 import org.chromium.content.browser.LoadUrlParams; |
18 import org.chromium.ui.base.WindowAndroid; | 18 import org.chromium.ui.base.WindowAndroid; |
19 | 19 |
20 /** | 20 /** |
21 * TestShell's implementation of a tab. This mirrors how Chrome for Android subc
lasses | 21 * TestShell's implementation of a tab. This mirrors how Chrome for Android subc
lasses |
22 * and extends {@link TabBase}. | 22 * and extends {@link Tab}. |
23 */ | 23 */ |
24 public class TestShellTab extends TabBase { | 24 public class TestShellTab extends Tab { |
25 // Tab state | 25 // Tab state |
26 private boolean mIsLoading; | 26 private boolean mIsLoading; |
27 | 27 |
28 /** | 28 /** |
29 * @param context The Context the view is running in. | 29 * @param context The Context the view is running in. |
30 * @param url The URL to start this tab with. | 30 * @param url The URL to start this tab with. |
31 * @param window The WindowAndroid should represent this tab. | 31 * @param window The WindowAndroid should represent this tab. |
32 * @param contentViewClient The client for the {@link ContentView}s of this
Tab. | 32 * @param contentViewClient The client for the {@link ContentView}s of this
Tab. |
33 */ | 33 */ |
34 public TestShellTab(Context context, String url, WindowAndroid window, | 34 public TestShellTab(Context context, String url, WindowAndroid window, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 /** | 76 /** |
77 * Navigates this Tab's {@link ContentView} to a sanitized version of {@code
url}. | 77 * Navigates this Tab's {@link ContentView} to a sanitized version of {@code
url}. |
78 * @param url The potentially unsanitized URL to navigate to. | 78 * @param url The potentially unsanitized URL to navigate to. |
79 */ | 79 */ |
80 public void loadUrlWithSanitization(String url) { | 80 public void loadUrlWithSanitization(String url) { |
81 loadUrlWithSanitization(url, null); | 81 loadUrlWithSanitization(url, null); |
82 } | 82 } |
83 | 83 |
84 @Override | 84 @Override |
85 protected TabBaseChromeWebContentsDelegateAndroid createWebContentsDelegate(
) { | 85 protected TabChromeWebContentsDelegateAndroid createWebContentsDelegate() { |
86 return new TestShellTabBaseChromeWebContentsDelegateAndroid(); | 86 return new TestShellTabChromeWebContentsDelegateAndroid(); |
87 } | 87 } |
88 | 88 |
89 @Override | 89 @Override |
90 protected AutoLoginProcessor createAutoLoginProcessor() { | 90 protected AutoLoginProcessor createAutoLoginProcessor() { |
91 return new AutoLoginProcessor() { | 91 return new AutoLoginProcessor() { |
92 @Override | 92 @Override |
93 public void processAutoLoginResult(String accountName, | 93 public void processAutoLoginResult(String accountName, |
94 String authToken, boolean success, String result) { | 94 String authToken, boolean success, String result) { |
95 getInfoBarContainer().processAutoLogin(accountName, authToken, | 95 getInfoBarContainer().processAutoLogin(accountName, authToken, |
96 success, result); | 96 success, result); |
97 } | 97 } |
98 }; | 98 }; |
99 } | 99 } |
100 | 100 |
101 @Override | 101 @Override |
102 protected ContextMenuPopulator createContextMenuPopulator() { | 102 protected ContextMenuPopulator createContextMenuPopulator() { |
103 return new ChromeContextMenuPopulator(new TabBaseChromeContextMenuItemDe
legate() { | 103 return new ChromeContextMenuPopulator(new TabChromeContextMenuItemDelega
te() { |
104 @Override | 104 @Override |
105 public void onOpenImageUrl(String url) { | 105 public void onOpenImageUrl(String url) { |
106 loadUrlWithSanitization(url); | 106 loadUrlWithSanitization(url); |
107 } | 107 } |
108 }); | 108 }); |
109 } | 109 } |
110 | 110 |
111 private class TestShellTabBaseChromeWebContentsDelegateAndroid | 111 private class TestShellTabChromeWebContentsDelegateAndroid |
112 extends TabBaseChromeWebContentsDelegateAndroid { | 112 extends TabChromeWebContentsDelegateAndroid { |
113 @Override | 113 @Override |
114 public void onLoadStarted() { | 114 public void onLoadStarted() { |
115 mIsLoading = true; | 115 mIsLoading = true; |
116 } | 116 } |
117 | 117 |
118 @Override | 118 @Override |
119 public void onLoadStopped() { | 119 public void onLoadStopped() { |
120 mIsLoading = false; | 120 mIsLoading = false; |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
OLD | NEW |