Commit 0e2e55ff authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

[WebLayer] Create skeleton Site Settings UI

This CL hooks up a skeleton Site Settings UI, which for now just shows
a single string. The focus of this CL is hooking up the RemoteFragment.
Hooking up the UI Fragments themselves will be in a followup.

Bug: 1049683
Change-Id: Ie9d79d928655067565a90ef96b5cc49dba591c7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199986Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769017}
parent 19dddf3b
...@@ -83,6 +83,7 @@ android_library("java") { ...@@ -83,6 +83,7 @@ android_library("java") {
"org/chromium/weblayer_private/ProfileImpl.java", "org/chromium/weblayer_private/ProfileImpl.java",
"org/chromium/weblayer_private/ProfileManager.java", "org/chromium/weblayer_private/ProfileManager.java",
"org/chromium/weblayer_private/RemoteFragmentImpl.java", "org/chromium/weblayer_private/RemoteFragmentImpl.java",
"org/chromium/weblayer_private/SiteSettingsFragmentImpl.java",
"org/chromium/weblayer_private/TabCallbackProxy.java", "org/chromium/weblayer_private/TabCallbackProxy.java",
"org/chromium/weblayer_private/TabImpl.java", "org/chromium/weblayer_private/TabImpl.java",
"org/chromium/weblayer_private/UrlBarControllerImpl.java", "org/chromium/weblayer_private/UrlBarControllerImpl.java",
...@@ -109,6 +110,7 @@ android_library("java") { ...@@ -109,6 +110,7 @@ android_library("java") {
"//components/autofill/android:provider_java", "//components/autofill/android:provider_java",
"//components/browser_ui/modaldialog/android:java", "//components/browser_ui/modaldialog/android:java",
"//components/browser_ui/notifications/android:java", "//components/browser_ui/notifications/android:java",
"//components/browser_ui/settings/android:java",
"//components/browser_ui/styles/android:java", "//components/browser_ui/styles/android:java",
"//components/browser_ui/styles/android:java_resources", "//components/browser_ui/styles/android:java_resources",
"//components/browser_ui/util/android:java", "//components/browser_ui/util/android:java",
...@@ -232,6 +234,8 @@ android_library("interfaces_java") { ...@@ -232,6 +234,8 @@ android_library("interfaces_java") {
"org/chromium/weblayer_private/interfaces/NavigationState.java", "org/chromium/weblayer_private/interfaces/NavigationState.java",
"org/chromium/weblayer_private/interfaces/NewTabType.java", "org/chromium/weblayer_private/interfaces/NewTabType.java",
"org/chromium/weblayer_private/interfaces/ObjectWrapper.java", "org/chromium/weblayer_private/interfaces/ObjectWrapper.java",
"org/chromium/weblayer_private/interfaces/SiteSettingsFragmentArgs.java",
"org/chromium/weblayer_private/interfaces/SiteSettingsIntentHelper.java",
"org/chromium/weblayer_private/interfaces/StrictModeWorkaround.java", "org/chromium/weblayer_private/interfaces/StrictModeWorkaround.java",
"org/chromium/weblayer_private/interfaces/UrlBarOptionsKeys.java", "org/chromium/weblayer_private/interfaces/UrlBarOptionsKeys.java",
] ]
...@@ -292,6 +296,7 @@ android_aidl("aidl") { ...@@ -292,6 +296,7 @@ android_aidl("aidl") {
"org/chromium/weblayer_private/interfaces/IProfile.aidl", "org/chromium/weblayer_private/interfaces/IProfile.aidl",
"org/chromium/weblayer_private/interfaces/IRemoteFragment.aidl", "org/chromium/weblayer_private/interfaces/IRemoteFragment.aidl",
"org/chromium/weblayer_private/interfaces/IRemoteFragmentClient.aidl", "org/chromium/weblayer_private/interfaces/IRemoteFragmentClient.aidl",
"org/chromium/weblayer_private/interfaces/ISiteSettingsFragment.aidl",
"org/chromium/weblayer_private/interfaces/ITab.aidl", "org/chromium/weblayer_private/interfaces/ITab.aidl",
"org/chromium/weblayer_private/interfaces/ITabClient.aidl", "org/chromium/weblayer_private/interfaces/ITabClient.aidl",
"org/chromium/weblayer_private/interfaces/IUrlBarController.aidl", "org/chromium/weblayer_private/interfaces/IUrlBarController.aidl",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer_private;
import android.content.Context;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import org.chromium.components.browser_ui.styles.R;
import org.chromium.components.embedder_support.application.ClassLoaderContextWrapperFactory;
import org.chromium.weblayer_private.interfaces.IRemoteFragment;
import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient;
import org.chromium.weblayer_private.interfaces.ISiteSettingsFragment;
import org.chromium.weblayer_private.interfaces.SiteSettingsFragmentArgs;
import org.chromium.weblayer_private.interfaces.StrictModeWorkaround;
/**
* WebLayer's implementation of the client library's SiteSettingsFragment.
*
* This class creates an instance of the Fragment given in its FRAGMENT_NAME argument, and forwards
* all incoming lifecycle events from SiteSettingsFragment to it. Because Fragments created in
* WebLayer use a different AndroidX library than the embedder's, we can't attach the Fragment
* created here directly to the embedder's Fragment tree, and have to create a local
* FragmentController to manage it.
*/
public class SiteSettingsFragmentImpl extends RemoteFragmentImpl {
private final ProfileImpl mProfile;
private final String mFragmentName;
private final Bundle mFragmentArguments;
// The WebLayer-wrapped context object. This context gets assets and resources from WebLayer,
// not from the embedder. Use this for the most part, especially to resolve WebLayer-specific
// resource IDs.
private Context mContext;
public SiteSettingsFragmentImpl(ProfileManager profileManager,
IRemoteFragmentClient remoteFragmentClient, Bundle fragmentArgs) {
super(remoteFragmentClient);
mProfile = profileManager.getProfile(
fragmentArgs.getString(SiteSettingsFragmentArgs.PROFILE_NAME));
mFragmentName = fragmentArgs.getString(SiteSettingsFragmentArgs.FRAGMENT_NAME);
mFragmentArguments = fragmentArgs.getBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS);
}
@Override
public void onAttach(Context context) {
StrictModeWorkaround.apply();
super.onAttach(context);
mContext = new ContextThemeWrapper(
ClassLoaderContextWrapperFactory.get(context), R.style.Theme_BrowserUI);
}
@Override
public void onDetach() {
super.onDetach();
mContext = null;
}
// TODO: Actually implement this.
public ISiteSettingsFragment asISiteSettingsFragment() {
return new ISiteSettingsFragment.Stub() {
@Override
public IRemoteFragment asRemoteFragment() {
StrictModeWorkaround.apply();
return SiteSettingsFragmentImpl.this;
}
};
}
}
...@@ -53,6 +53,7 @@ import org.chromium.weblayer_private.interfaces.ICrashReporterController; ...@@ -53,6 +53,7 @@ import org.chromium.weblayer_private.interfaces.ICrashReporterController;
import org.chromium.weblayer_private.interfaces.IObjectWrapper; import org.chromium.weblayer_private.interfaces.IObjectWrapper;
import org.chromium.weblayer_private.interfaces.IProfile; import org.chromium.weblayer_private.interfaces.IProfile;
import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient; import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient;
import org.chromium.weblayer_private.interfaces.ISiteSettingsFragment;
import org.chromium.weblayer_private.interfaces.IWebLayer; import org.chromium.weblayer_private.interfaces.IWebLayer;
import org.chromium.weblayer_private.interfaces.IWebLayerClient; import org.chromium.weblayer_private.interfaces.IWebLayerClient;
import org.chromium.weblayer_private.interfaces.ObjectWrapper; import org.chromium.weblayer_private.interfaces.ObjectWrapper;
...@@ -273,6 +274,16 @@ public final class WebLayerImpl extends IWebLayer.Stub { ...@@ -273,6 +274,16 @@ public final class WebLayerImpl extends IWebLayer.Stub {
return fragment.asIBrowserFragment(); return fragment.asIBrowserFragment();
} }
@Override
public ISiteSettingsFragment createSiteSettingsFragmentImpl(
IRemoteFragmentClient remoteFragmentClient, IObjectWrapper fragmentArgs) {
StrictModeWorkaround.apply();
Bundle unwrappedArgs = ObjectWrapper.unwrap(fragmentArgs, Bundle.class);
SiteSettingsFragmentImpl fragment =
new SiteSettingsFragmentImpl(mProfileManager, remoteFragmentClient, unwrappedArgs);
return fragment.asISiteSettingsFragment();
}
@Override @Override
public IProfile getProfile(String profileName) { public IProfile getProfile(String profileName) {
StrictModeWorkaround.apply(); StrictModeWorkaround.apply();
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer_private.interfaces;
import org.chromium.weblayer_private.interfaces.IRemoteFragment;
interface ISiteSettingsFragment {
IRemoteFragment asRemoteFragment() = 0;
}
...@@ -12,6 +12,7 @@ import org.chromium.weblayer_private.interfaces.ICrashReporterController; ...@@ -12,6 +12,7 @@ import org.chromium.weblayer_private.interfaces.ICrashReporterController;
import org.chromium.weblayer_private.interfaces.IObjectWrapper; import org.chromium.weblayer_private.interfaces.IObjectWrapper;
import org.chromium.weblayer_private.interfaces.IProfile; import org.chromium.weblayer_private.interfaces.IProfile;
import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient; import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient;
import org.chromium.weblayer_private.interfaces.ISiteSettingsFragment;
import org.chromium.weblayer_private.interfaces.IWebLayerClient; import org.chromium.weblayer_private.interfaces.IWebLayerClient;
interface IWebLayer { interface IWebLayer {
...@@ -84,4 +85,15 @@ interface IWebLayer { ...@@ -84,4 +85,15 @@ interface IWebLayer {
// Added in Version 84. // Added in Version 84.
void registerExternalExperimentIDs(in String trialName, in int[] experimentIds) = 15; void registerExternalExperimentIDs(in String trialName, in int[] experimentIds) = 15;
// Creates the WebLayer counterpart to a SiteSettingsFragment - a SiteSettingsFragmentImpl
//
// @param fragmentClient Representative of the Fragment on the client side through which
// WebLayer can call methods on Fragment.
// @param fragmentArgs Bundle of arguments with which the Fragment was created on the client side
// (see Fragment#setArguments).
// Added in Version 84.
ISiteSettingsFragment createSiteSettingsFragmentImpl(
in IRemoteFragmentClient remoteFragmentClient,
in IObjectWrapper fragmentArgs) = 16;
} }
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer_private.interfaces;
/** Keys for the Bundle of arguments with which SiteSettingsFragments are created. */
public interface SiteSettingsFragmentArgs {
String ACTIVITY_CLASS_NAME = "org.chromium.weblayer.SiteSettingsActivity";
// Argument names
String PROFILE_NAME = "profile_name";
String FRAGMENT_NAME = "fragment_name";
String FRAGMENT_ARGUMENTS = "fragment_arguments";
// FRAGMENT_NAME values
String CATEGORY_LIST = "category_list";
String SINGLE_CATEGORY = "single_category";
String SINGLE_WEBSITE = "single_website";
// SINGLE_WEBSITE argument names
String SINGLE_WEBSITE_URL = "url";
// SINGLE_CATEGORY argument names
String SINGLE_CATEGORY_TITLE = "title";
String SINGLE_CATEGORY_TYPE = "type";
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer_private.interfaces;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
/**
* A helper class for creating Intents to start the Site Settings UI.
*/
public class SiteSettingsIntentHelper {
/** Creates an Intent that launches the main category list UI. */
public static Intent createIntentForCategoryList(Context context, String profileName) {
Bundle extras = new Bundle();
extras.putString(SiteSettingsFragmentArgs.PROFILE_NAME, profileName);
extras.putString(
SiteSettingsFragmentArgs.FRAGMENT_NAME, SiteSettingsFragmentArgs.CATEGORY_LIST);
return createIntentWithExtras(context, extras);
}
/** Creates an Intent that launches the settings UI for a single category. */
public static Intent createIntentForSingleCategory(
Context context, String profileName, String categoryType, String categoryTitle) {
Bundle extras = new Bundle();
extras.putString(SiteSettingsFragmentArgs.PROFILE_NAME, profileName);
extras.putString(
SiteSettingsFragmentArgs.FRAGMENT_NAME, SiteSettingsFragmentArgs.SINGLE_CATEGORY);
Bundle fragmentArgs = new Bundle();
fragmentArgs.putString(SiteSettingsFragmentArgs.SINGLE_CATEGORY_TYPE, categoryType);
fragmentArgs.putString(SiteSettingsFragmentArgs.SINGLE_CATEGORY_TITLE, categoryTitle);
extras.putBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS, fragmentArgs);
return createIntentWithExtras(context, extras);
}
/** Creates an Intent that launches the single website settings UI. */
public static Intent createIntentForSingleWebsite(
Context context, String profileName, String url) {
Bundle extras = new Bundle();
extras.putString(SiteSettingsFragmentArgs.PROFILE_NAME, profileName);
extras.putString(
SiteSettingsFragmentArgs.FRAGMENT_NAME, SiteSettingsFragmentArgs.SINGLE_WEBSITE);
Bundle fragmentArgs = new Bundle();
fragmentArgs.putString(SiteSettingsFragmentArgs.SINGLE_WEBSITE_URL, url);
extras.putBundle(SiteSettingsFragmentArgs.FRAGMENT_ARGUMENTS, fragmentArgs);
return createIntentWithExtras(context, extras);
}
private static Intent createIntentWithExtras(Context context, Bundle extras) {
Intent intent = new Intent();
intent.setClassName(context, SiteSettingsFragmentArgs.ACTIVITY_CLASS_NAME);
intent.putExtras(extras);
return intent;
}
private SiteSettingsIntentHelper() {}
}
...@@ -54,6 +54,11 @@ ...@@ -54,6 +54,11 @@
android:resource="@xml/weblayer_file_paths" /> android:resource="@xml/weblayer_file_paths" />
</provider> </provider>
<activity android:name="org.chromium.weblayer.SiteSettingsActivity"
android:theme="@style/Theme.WebLayer.SiteSettings"
android:exported="false">
</activity>
<receiver android:name="org.chromium.weblayer.BroadcastReceiver" <receiver android:name="org.chromium.weblayer.BroadcastReceiver"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
......
...@@ -18,7 +18,10 @@ jinja_template("weblayer_client_manifest") { ...@@ -18,7 +18,10 @@ jinja_template("weblayer_client_manifest") {
} }
android_resources("client_resources") { android_resources("client_resources") {
sources = [ "res/xml/weblayer_file_paths.xml" ] sources = [
"res/values/styles.xml",
"res/xml/weblayer_file_paths.xml",
]
android_manifest = weblayer_client_manifest android_manifest = weblayer_client_manifest
android_manifest_dep = ":weblayer_client_manifest" android_manifest_dep = ":weblayer_client_manifest"
} }
...@@ -59,6 +62,8 @@ android_library("java") { ...@@ -59,6 +62,8 @@ android_library("java") {
"org/chromium/weblayer/ObserverList.java", "org/chromium/weblayer/ObserverList.java",
"org/chromium/weblayer/Profile.java", "org/chromium/weblayer/Profile.java",
"org/chromium/weblayer/RemoteFragment.java", "org/chromium/weblayer/RemoteFragment.java",
"org/chromium/weblayer/SiteSettingsActivity.java",
"org/chromium/weblayer/SiteSettingsFragment.java",
"org/chromium/weblayer/Tab.java", "org/chromium/weblayer/Tab.java",
"org/chromium/weblayer/TabCallback.java", "org/chromium/weblayer/TabCallback.java",
"org/chromium/weblayer/TabListCallback.java", "org/chromium/weblayer/TabListCallback.java",
...@@ -77,6 +82,7 @@ android_library("java") { ...@@ -77,6 +82,7 @@ android_library("java") {
":client_version", ":client_version",
":weblayer_client_manifest", ":weblayer_client_manifest",
"//third_party/android_deps:androidx_annotation_annotation_java", "//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:androidx_appcompat_appcompat_java",
"//third_party/android_deps:androidx_core_core_java", "//third_party/android_deps:androidx_core_core_java",
"//third_party/android_deps:androidx_fragment_fragment_java", "//third_party/android_deps:androidx_fragment_fragment_java",
"//third_party/android_deps:androidx_lifecycle_lifecycle_common_java", "//third_party/android_deps:androidx_lifecycle_lifecycle_common_java",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import org.chromium.weblayer_private.interfaces.SiteSettingsIntentHelper;
/**
* An Activity that displays various Site Settings UIs.
*/
public class SiteSettingsActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG = "siteSettingsFragment";
private static boolean sActivityNotExportedChecked;
/**
* Creates an Intent that will launch the root/full Site Settings UI, which displays a list of
* settings categories.
*/
public static Intent createIntentForCategoryList(Context context, String profileName) {
if (WebLayer.getSupportedMajorVersion(context) < 84) {
throw new UnsupportedOperationException();
}
return SiteSettingsIntentHelper.createIntentForCategoryList(context, profileName);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
ensureActivityNotExported();
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setElevation(0);
if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) {
SiteSettingsFragment siteSettingsFragment = new SiteSettingsFragment();
siteSettingsFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, siteSettingsFragment)
.commitNow();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
private void ensureActivityNotExported() {
if (sActivityNotExportedChecked) return;
sActivityNotExportedChecked = true;
try {
ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), 0);
// If SiteSettingsActivity is exported, then it's vulnerable to a fragment injection
// exploit:
// http://securityintelligence.com/new-vulnerability-android-framework-fragment-injection
if (activityInfo.exported) {
throw new IllegalStateException("SiteSettingsActivity must not be exported.");
}
} catch (NameNotFoundException ex) {
// Something terribly wrong has happened.
throw new RuntimeException(ex);
}
}
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer;
import android.content.Context;
import android.os.Bundle;
import org.chromium.weblayer_private.interfaces.IRemoteFragment;
/**
* The client-side implementation of a SiteSettingsFragment.
*
* This is a Fragment that can be shown within an embedder's UI, and proxies its lifecycle events to
* a SiteSettingsFragmentImpl object on the implementation side.
*/
public class SiteSettingsFragment extends RemoteFragment {
public SiteSettingsFragment() {
super();
}
@Override
protected IRemoteFragment createRemoteFragment(Context appContext) {
try {
Bundle args = getArguments();
if (args == null) {
throw new RuntimeException("SiteSettingsFragment was created without arguments.");
}
return WebLayer.loadSync(appContext)
.connectSiteSettingsFragment(getRemoteFragmentClient(), args)
.asRemoteFragment();
} catch (Exception e) {
throw new RuntimeException("Failed to initialize WebLayer", e);
}
}
}
...@@ -26,6 +26,7 @@ import org.chromium.weblayer_private.interfaces.BrowserFragmentArgs; ...@@ -26,6 +26,7 @@ import org.chromium.weblayer_private.interfaces.BrowserFragmentArgs;
import org.chromium.weblayer_private.interfaces.IBrowserFragment; import org.chromium.weblayer_private.interfaces.IBrowserFragment;
import org.chromium.weblayer_private.interfaces.IProfile; import org.chromium.weblayer_private.interfaces.IProfile;
import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient; import org.chromium.weblayer_private.interfaces.IRemoteFragmentClient;
import org.chromium.weblayer_private.interfaces.ISiteSettingsFragment;
import org.chromium.weblayer_private.interfaces.IWebLayer; import org.chromium.weblayer_private.interfaces.IWebLayer;
import org.chromium.weblayer_private.interfaces.IWebLayerClient; import org.chromium.weblayer_private.interfaces.IWebLayerClient;
import org.chromium.weblayer_private.interfaces.IWebLayerFactory; import org.chromium.weblayer_private.interfaces.IWebLayerFactory;
...@@ -563,6 +564,22 @@ public class WebLayer { ...@@ -563,6 +564,22 @@ public class WebLayer {
} }
} }
/**
* Returns the remote counterpart of the SiteSettingsFragment.
*/
/* package */ ISiteSettingsFragment connectSiteSettingsFragment(
IRemoteFragmentClient remoteFragmentClient, Bundle fragmentArgs) {
if (getSupportedMajorVersionInternal() < 84) {
throw new UnsupportedOperationException();
}
try {
return mImpl.createSiteSettingsFragmentImpl(
remoteFragmentClient, ObjectWrapper.wrap(fragmentArgs));
} catch (RemoteException e) {
throw new APICallException(e);
}
}
/* package */ static IWebLayer getIWebLayer(Context appContext) { /* package */ static IWebLayer getIWebLayer(Context appContext) {
return getWebLayerLoader(appContext).getIWebLayer(appContext); return getWebLayerLoader(appContext).getIWebLayer(appContext);
} }
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.WebLayer.SiteSettings" parent="Theme.AppCompat.Light">
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
<item name="actionBarStyle">@style/SettingsActionBarModern</item>
</style>
<style name="SettingsActionBarModern" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
</style>
</resources>
...@@ -15,4 +15,6 @@ ...@@ -15,4 +15,6 @@
<item android:id="@+id/toggle_bottom_view_id" <item android:id="@+id/toggle_bottom_view_id"
android:checkable="true" android:checkable="true"
android:title="Bottom view" /> android:title="Bottom view" />
<item android:id="@+id/site_settings_menu_id"
android:title="Site Settings" />
</menu> </menu>
...@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentActivity; ...@@ -32,6 +32,7 @@ import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import org.chromium.base.IntentUtils;
import org.chromium.weblayer.Browser; import org.chromium.weblayer.Browser;
import org.chromium.weblayer.ContextMenuParams; import org.chromium.weblayer.ContextMenuParams;
import org.chromium.weblayer.ErrorPageCallback; import org.chromium.weblayer.ErrorPageCallback;
...@@ -42,6 +43,7 @@ import org.chromium.weblayer.NavigationController; ...@@ -42,6 +43,7 @@ import org.chromium.weblayer.NavigationController;
import org.chromium.weblayer.NewTabCallback; import org.chromium.weblayer.NewTabCallback;
import org.chromium.weblayer.NewTabType; import org.chromium.weblayer.NewTabType;
import org.chromium.weblayer.Profile; import org.chromium.weblayer.Profile;
import org.chromium.weblayer.SiteSettingsActivity;
import org.chromium.weblayer.Tab; import org.chromium.weblayer.Tab;
import org.chromium.weblayer.TabCallback; import org.chromium.weblayer.TabCallback;
import org.chromium.weblayer.TabListCallback; import org.chromium.weblayer.TabListCallback;
...@@ -56,6 +58,8 @@ import java.util.List; ...@@ -56,6 +58,8 @@ import java.util.List;
* Activity for managing the Demo Shell. * Activity for managing the Demo Shell.
*/ */
public class WebLayerShellActivity extends FragmentActivity { public class WebLayerShellActivity extends FragmentActivity {
private static final String PROFILE_NAME = "DefaultProfile";
private static class ContextMenuCreator private static class ContextMenuCreator
implements View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener { implements View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener {
private static final int MENU_ID_COPY_LINK_URI = 1; private static final int MENU_ID_COPY_LINK_URI = 1;
...@@ -200,6 +204,13 @@ public class WebLayerShellActivity extends FragmentActivity { ...@@ -200,6 +204,13 @@ public class WebLayerShellActivity extends FragmentActivity {
return true; return true;
} }
if (item.getItemId() == R.id.site_settings_menu_id) {
Intent intent =
SiteSettingsActivity.createIntentForCategoryList(this, PROFILE_NAME);
IntentUtils.safeStartActivity(this, intent);
return true;
}
return false; return false;
}); });
popup.show(); popup.show();
...@@ -416,8 +427,7 @@ public class WebLayerShellActivity extends FragmentActivity { ...@@ -416,8 +427,7 @@ public class WebLayerShellActivity extends FragmentActivity {
} }
} }
String profileName = "DefaultProfile"; Fragment fragment = WebLayer.createBrowserFragment(PROFILE_NAME);
Fragment fragment = WebLayer.createBrowserFragment(profileName);
FragmentTransaction transaction = fragmentManager.beginTransaction(); FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(mMainViewId, fragment); transaction.add(mMainViewId, fragment);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment