Commit bf201644 authored by tapted's avatar tapted Committed by Commit bot

Disable bookmark apps on non-ChromeOS platforms.

The world isn't quite ready for them....

BUG=459504
TBR=benwells@chromium.org,thestig@chromium.org
Original patch from benwells; reviewed in http://crrev.com/938603002

Review URL: https://codereview.chromium.org/937843004

Cr-Commit-Position: refs/heads/master@{#317013}
parent 4df4bf62
...@@ -6666,11 +6666,11 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -6666,11 +6666,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
Do not use Smart Lock, which allows you to unlock your Chromebook when in proximity to your phone. If you are the owner of the device, this also turns off Smart Lock on sign-in screen. Do not use Smart Lock, which allows you to unlock your Chromebook when in proximity to your phone. If you are the owner of the device, this also turns off Smart Lock on sign-in screen.
</message> </message>
</if> </if>
<message name="IDS_FLAGS_DISABLE_NEW_BOOKMARK_APPS_NAME" desc="Name of the flag to disable the new bookmark app system."> <message name="IDS_FLAGS_NEW_BOOKMARK_APPS_NAME" desc="Name of the flag to enable the new bookmark app system.">
Disable the new bookmark app system. Enable the new bookmark app system.
</message> </message>
<message name="IDS_FLAGS_DISABLE_NEW_BOOKMARK_APPS_DESCRIPTION" desc="Description for the flag to disable the new bookmark app system."> <message name="IDS_FLAGS_NEW_BOOKMARK_APPS_DESCRIPTION" desc="Description for the flag to enable the new bookmark app system.">
Disables the new system for creating bookmark apps. Enables the new system for creating bookmark apps.
</message> </message>
<message name="IDS_FLAGS_DISABLE_HOSTED_APP_SHIM_CREATION_NAME" desc="Name of the flag to enable creation of app shims for hosted apps on Mac."> <message name="IDS_FLAGS_DISABLE_HOSTED_APP_SHIM_CREATION_NAME" desc="Name of the flag to enable creation of app shims for hosted apps on Mac.">
Disable creation of app shims for hosted apps on Mac. Disable creation of app shims for hosted apps on Mac.
......
...@@ -1537,10 +1537,11 @@ const Experiment kExperiments[] = { ...@@ -1537,10 +1537,11 @@ const Experiment kExperiments[] = {
#endif #endif
{ {
"disable-new-bookmark-apps", "disable-new-bookmark-apps",
IDS_FLAGS_DISABLE_NEW_BOOKMARK_APPS_NAME, IDS_FLAGS_NEW_BOOKMARK_APPS_NAME,
IDS_FLAGS_DISABLE_NEW_BOOKMARK_APPS_DESCRIPTION, IDS_FLAGS_NEW_BOOKMARK_APPS_DESCRIPTION,
kOsWin | kOsCrOS | kOsLinux | kOsMac, kOsWin | kOsCrOS | kOsLinux | kOsMac,
SINGLE_VALUE_TYPE(switches::kDisableNewBookmarkApps) ENABLE_DISABLE_VALUE_TYPE(switches::kEnableNewBookmarkApps,
switches::kDisableNewBookmarkApps)
}, },
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
{ {
......
...@@ -45,6 +45,11 @@ class AppShimInteractiveTest : public extensions::PlatformAppBrowserTest { ...@@ -45,6 +45,11 @@ class AppShimInteractiveTest : public extensions::PlatformAppBrowserTest {
AppShimInteractiveTest() AppShimInteractiveTest()
: auto_reset_(&g_app_shims_allow_update_and_launch_in_tests, true) {} : auto_reset_(&g_app_shims_allow_update_and_launch_in_tests, true) {}
void SetUpCommandLine(base::CommandLine* command_line) override {
PlatformAppBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableNewBookmarkApps);
}
private: private:
// Temporarily enable app shims. // Temporarily enable app shims.
base::AutoReset<bool> auto_reset_; base::AutoReset<bool> auto_reset_;
......
...@@ -1466,6 +1466,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( ...@@ -1466,6 +1466,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kEnableNaClNonSfiMode, switches::kEnableNaClNonSfiMode,
#endif #endif
switches::kEnableNetBenchmarking, switches::kEnableNetBenchmarking,
switches::kEnableNewBookmarkApps,
switches::kEnableOutOfProcessPdf, switches::kEnableOutOfProcessPdf,
switches::kEnablePluginPlaceholderShadowDom, switches::kEnablePluginPlaceholderShadowDom,
switches::kEnableShowModalDialog, switches::kEnableShowModalDialog,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -310,12 +311,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, MAYBE_LaunchTabApp) { ...@@ -310,12 +311,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, MAYBE_LaunchTabApp) {
// If the ID changed, then the pref will not apply to the app. // If the ID changed, then the pref will not apply to the app.
ASSERT_EQ(app_id, app_id_new); ASSERT_EQ(app_id, app_id_new);
unsigned expected_browser_count = 2;
#if defined(OS_MACOSX)
// Without the new Bookmark Apps, Mac has no way of making standalone browser
// windows for apps, so it will add to the tabstrip instead.
EXPECT_FALSE(extensions::util::IsNewBookmarkAppsEnabled());
expected_browser_count = 1;
ASSERT_EQ(2, browser()->tab_strip_model()->count());
#endif
// Find the app's browser. Opening in a new window will create // Find the app's browser. Opening in a new window will create
// a new browser. // a new browser.
ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), ASSERT_EQ(expected_browser_count,
browser()->host_desktop_type())); chrome::GetBrowserCount(browser()->profile(),
Browser* app_browser = FindOtherBrowser(browser()); browser()->host_desktop_type()));
ASSERT_TRUE(app_browser->is_app()); if (expected_browser_count == 2) {
Browser* app_browser = FindOtherBrowser(browser());
ASSERT_TRUE(app_browser->is_app());
}
} }
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchType) { IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchType) {
......
...@@ -384,8 +384,13 @@ const gfx::ImageSkia& GetDefaultExtensionIcon() { ...@@ -384,8 +384,13 @@ const gfx::ImageSkia& GetDefaultExtensionIcon() {
} }
bool IsNewBookmarkAppsEnabled() { bool IsNewBookmarkAppsEnabled() {
#if defined(OS_CHROMEOS)
return !base::CommandLine::ForCurrentProcess()->HasSwitch( return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableNewBookmarkApps); switches::kDisableNewBookmarkApps);
#else
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNewBookmarkApps);
#endif
} }
} // namespace util } // namespace util
......
...@@ -160,6 +160,8 @@ IN_PROC_BROWSER_TEST_F(AppListServiceImplBrowserTest, ...@@ -160,6 +160,8 @@ IN_PROC_BROWSER_TEST_F(AppListServiceImplBrowserTest,
// Test that all the items in the context menu for a hosted app have valid // Test that all the items in the context menu for a hosted app have valid
// labels. // labels.
IN_PROC_BROWSER_TEST_F(AppListServiceImplBrowserTest, ShowContextMenu) { IN_PROC_BROWSER_TEST_F(AppListServiceImplBrowserTest, ShowContextMenu) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableNewBookmarkApps);
AppListService* service = test::GetAppListService(); AppListService* service = test::GetAppListService();
EXPECT_TRUE(service); EXPECT_TRUE(service);
......
...@@ -40,6 +40,7 @@ class AppShimMenuControllerBrowserTest ...@@ -40,6 +40,7 @@ class AppShimMenuControllerBrowserTest
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
PlatformAppBrowserTest::SetUpCommandLine(command_line); PlatformAppBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableNewBookmarkApps);
} }
// Start testing apps and wait for them to launch. |flags| is a bitmask of // Start testing apps and wait for them to launch. |flags| is a bitmask of
......
...@@ -270,7 +270,7 @@ const char kDisableMinimizeOnSecondLauncherItemClick[] = ...@@ -270,7 +270,7 @@ const char kDisableMinimizeOnSecondLauncherItemClick[] =
"disable-minimize-on-second-launcher-item-click"; "disable-minimize-on-second-launcher-item-click";
// Disables the new bookmark app system. // Disables the new bookmark app system.
const char kDisableNewBookmarkApps[] = "disable-new-bookmark-apps"; const char kDisableNewBookmarkApps[] = "disable-new-bookmark-apps";
// Disables the new offline error page generated by NetErrorHelper for ChromeOS // Disables the new offline error page generated by NetErrorHelper for ChromeOS
// and instead uses the old error page generated by OfflineResourceThrottle. // and instead uses the old error page generated by OfflineResourceThrottle.
...@@ -467,6 +467,9 @@ const char kEnableNaCl[] = "enable-nacl"; ...@@ -467,6 +467,9 @@ const char kEnableNaCl[] = "enable-nacl";
// Enables the network-related benchmarking extensions. // Enables the network-related benchmarking extensions.
const char kEnableNetBenchmarking[] = "enable-net-benchmarking"; const char kEnableNetBenchmarking[] = "enable-net-benchmarking";
// Enables the new bookmark app system.
const char kEnableNewBookmarkApps[] = "enable-new-bookmark-apps";
// Enables NPN with HTTP. It means NPN is enabled but SPDY won't be used. // Enables NPN with HTTP. It means NPN is enabled but SPDY won't be used.
// HTTP is still used for all requests. // HTTP is still used for all requests.
const char kEnableNpnHttpOnly[] = "enable-npn-http"; const char kEnableNpnHttpOnly[] = "enable-npn-http";
......
...@@ -136,6 +136,7 @@ extern const char kEnableLinkableEphemeralApps[]; ...@@ -136,6 +136,7 @@ extern const char kEnableLinkableEphemeralApps[];
extern const char kEnableMaterialDesignSettings[]; extern const char kEnableMaterialDesignSettings[];
extern const char kEnableNaCl[]; extern const char kEnableNaCl[];
extern const char kEnableNetBenchmarking[]; extern const char kEnableNetBenchmarking[];
extern const char kEnableNewBookmarkApps[];
extern const char kEnableNpnHttpOnly[]; extern const char kEnableNpnHttpOnly[];
extern const char kEnableOfflineAutoReload[]; extern const char kEnableOfflineAutoReload[];
extern const char kEnableOfflineAutoReloadVisibleOnly[]; extern const char kEnableOfflineAutoReloadVisibleOnly[];
......
...@@ -145,10 +145,16 @@ void ParseWebAppFromWebDocument(WebFrame* frame, ...@@ -145,10 +145,16 @@ void ParseWebAppFromWebDocument(WebFrame* frame,
// //
// Bookmark apps also support "apple-touch-icon" and // Bookmark apps also support "apple-touch-icon" and
// "apple-touch-icon-precomposed". // "apple-touch-icon-precomposed".
#if defined(OS_CHROMEOS)
bool bookmark_apps_enabled = !base::CommandLine::ForCurrentProcess()->
HasSwitch(switches::kDisableNewBookmarkApps);
#else
bool bookmark_apps_enabled = base::CommandLine::ForCurrentProcess()->
HasSwitch(switches::kEnableNewBookmarkApps);
#endif
if (LowerCaseEqualsASCII(rel, "icon") || if (LowerCaseEqualsASCII(rel, "icon") ||
LowerCaseEqualsASCII(rel, "shortcut icon") || LowerCaseEqualsASCII(rel, "shortcut icon") ||
(!base::CommandLine::ForCurrentProcess()->HasSwitch( (bookmark_apps_enabled &&
switches::kDisableNewBookmarkApps) &&
(LowerCaseEqualsASCII(rel, "apple-touch-icon") || (LowerCaseEqualsASCII(rel, "apple-touch-icon") ||
LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) { LowerCaseEqualsASCII(rel, "apple-touch-icon-precomposed")))) {
AddInstallIcon(elem, &app_info->icons); AddInstallIcon(elem, &app_info->icons);
......
...@@ -32,6 +32,11 @@ function getAvailableLaunchTypes(app) { ...@@ -32,6 +32,11 @@ function getAvailableLaunchTypes(app) {
types.push("OPEN_AS_REGULAR_TAB"); types.push("OPEN_AS_REGULAR_TAB");
types.push("OPEN_AS_WINDOW"); types.push("OPEN_AS_WINDOW");
if (navigator.userAgent.indexOf("CrOS") == -1) {
types.push("OPEN_AS_PINNED_TAB");
types.push("OPEN_FULL_SCREEN");
}
return types; return types;
} }
...@@ -59,6 +64,13 @@ function testSetAllLaunchTypes(app) { ...@@ -59,6 +64,13 @@ function testSetAllLaunchTypes(app) {
} else { } else {
testSetLaunchType(app.id, type, null, function() { testSetLaunchType(app.id, type, null, function() {
chrome.management.get(app.id, function(item) { chrome.management.get(app.id, function(item) {
if (navigator.userAgent.indexOf("Mac") != -1) {
// In the current configuration, with the new bookmark app flow
// disabled, hosted apps set to open in a window on Mac will open
// instead in a tab.
if (item.type != 'packaged_app' && type == 'OPEN_AS_WINDOW')
type = 'OPEN_AS_REGULAR_TAB';
}
assertEq(type, item.launchType); assertEq(type, item.launchType);
setNextLaunchType(); setNextLaunchType();
}); });
......
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