diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-25 15:56:26 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-25 15:56:26 +0000 |
commit | 596c6aa19c34c9c912aa095078231a02ffbd8812 (patch) | |
tree | 7164ddc5ef8a06181225867b27754e10a21444be /chrome | |
parent | 1cf7ff9b69d4b80fe42182e018d26df3e49fe775 (diff) | |
download | chromium_src-596c6aa19c34c9c912aa095078231a02ffbd8812.zip chromium_src-596c6aa19c34c9c912aa095078231a02ffbd8812.tar.gz chromium_src-596c6aa19c34c9c912aa095078231a02ffbd8812.tar.bz2 |
Relanding 48042.
I reverted http://codereview.chromium.org/1986006 as part of that change, after talking with Ben and Aaron. (it breaks the UI tests on ChromeOS now that apps are enabled).
Disabling app launcher and enabling apps by default on ChromeOS .
BUG=3218
TEST=Open the new tab, the new new tab should be shown. Any installed
app should be showing in there.
Review URL: http://codereview.chromium.org/2149003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 27 | ||||
-rw-r--r-- | chrome/browser/defaults.cc | 2 | ||||
-rw-r--r-- | chrome/browser/defaults.h | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 7 | ||||
-rw-r--r-- | chrome/browser/dom_ui/shown_sections_handler.cc | 5 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.cc | 9 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 7 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 8 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 14 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 4 | ||||
-rw-r--r-- | chrome/common/extensions/extension_manifests_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 5 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 8 |
15 files changed, 39 insertions, 69 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index b723a85c..68d14ca 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1052,15 +1052,11 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { bool Browser::OpenAppsPanelAsNewTab() { #if defined(OS_CHROMEOS) || defined(OS_WIN) CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kDisableAppsPanel) || - (!browser_defaults::kShowAppsPanelForNewTab && - !command_line->HasSwitch(switches::kAppsPanel))) { - return false; + if (command_line->HasSwitch(switches::kAppsPanel)) { + AppLauncher::ShowForNewTab(this, std::string()); + return true; } - AppLauncher::ShowForNewTab(this, std::string()); - return true; -#endif // OS_CHROMEOS || OS_WIN - +#endif return false; } @@ -2082,21 +2078,6 @@ void Browser::ExecuteCommand(int id) { // Browser, TabStripModelDelegate implementation: TabContents* Browser::AddBlankTab(bool foreground) { - // To make a more "launchy" experience, try to reuse an existing NTP if there - // is one. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { - for (int i = tabstrip_model_.count() - 1; i >= 0; --i) { - TabContents* contents = tabstrip_model_.GetTabContentsAt(i); - if (StartsWithASCII(contents->GetURL().spec(), - chrome::kChromeUINewTabURL, true)) { - if (foreground) - SelectTabContentsAt(i, true); - - return contents; - } - } - } - return AddBlankTabAt(-1, foreground); } diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index ca50e70..a669305 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -25,7 +25,6 @@ const bool kDownloadPageHasShowInFolder = false; const bool kSizeTabButtonToTopOfTabStrip = true; const bool kBootstrapSyncAuthentication = true; const bool kShowOtherBrowsersInAboutMemory = false; -const bool kShowAppsPanelForNewTab = true; #elif defined(TOOLKIT_USES_GTK) @@ -66,7 +65,6 @@ const bool kOSSupportsOtherBrowsers = true; const bool kSizeTabButtonToTopOfTabStrip = false; const bool kBootstrapSyncAuthentication = false; const bool kShowOtherBrowsersInAboutMemory = true; -const bool kShowAppsPanelForNewTab = false; #endif #if defined(OS_MACOSX) diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h index 8a2b543..11dee1f 100644 --- a/chrome/browser/defaults.h +++ b/chrome/browser/defaults.h @@ -67,9 +67,6 @@ extern const bool kBootstrapSyncAuthentication; // Should other browsers be shown in about:memory page? extern const bool kShowOtherBrowsersInAboutMemory; -// Should we show the app panel when a new tab is created? -extern const bool kShowAppsPanelForNewTab; - } // namespace browser_defaults #endif // CHROME_BROWSER_DEFAULTS_H_ diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 693618e..b605522 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -505,9 +505,12 @@ NewTabUI::NewTabUI(TabContents* contents) if (ProfileSyncService::IsSyncEnabled()) { AddMessageHandler((new NewTabPageSyncHandler())->Attach(this)); } - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { + if (Extension::AppsAreEnabled()) { ExtensionsService* service = GetProfile()->GetExtensionsService(); - AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); + // We might not have an ExtensionsService (on ChromeOS when not logged in + // for example). + if (service) + AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); } AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this)); diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc index 501c1d8..ecc8f1b 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.cc +++ b/chrome/browser/dom_ui/shown_sections_handler.cc @@ -12,6 +12,7 @@ #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" namespace { @@ -87,7 +88,7 @@ void ShownSectionsHandler::SetFirstAppLauncherRunPref( // If we have turned on Apps we want to hide most visited and recent to give // more focus to the Apps section. We do not do this in MigrateUserPrefs // because the pref version should not depend on command line switches. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps) && + if (Extension::AppsAreEnabled() && !pref_service->GetBoolean(prefs::kNTPAppLauncherFirstRun)) { int sections = pref_service->GetInteger(prefs::kNTPShownSections); sections &= ~THUMB; @@ -101,7 +102,7 @@ void ShownSectionsHandler::SetFirstAppLauncherRunPref( void ShownSectionsHandler::RegisterUserPrefs(PrefService* pref_service) { pref_service->RegisterIntegerPref(prefs::kNTPShownSections, THUMB | RECENT | TIPS | SYNC); - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { + if (Extension::AppsAreEnabled()) { pref_service->RegisterBooleanPref(prefs::kNTPAppLauncherFirstRun, false); } } diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index c85b254..552e231 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -273,13 +273,8 @@ void ExtensionInstallUI::OnImageLoaded( switch (prompt_type_) { case INSTALL_PROMPT: { - if (extension_->GetFullLaunchURL().is_valid()) { - // Special case extension apps to not show the install dialog. - // TODO(finnur): http://crbug.com/42443: Don't do this for all apps. - delegate_->InstallUIProceed(false); // |create_app_shortcut|. - return; - } - + // TODO(jcivelli): http://crbug.com/44771 We should not show an install + // dialog when installing an app from the gallery. NotificationService* service = NotificationService::current(); service->Notify(NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, Source<ExtensionInstallUI>(this), diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 505a528..eeeee11 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -766,7 +766,7 @@ void ProfileImpl::InitExtensions() { // Some sample apps to make our lives easier while we are developing extension // apps. This way we don't have to constantly install these over and over. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { + if (Extension::AppsAreEnabled()) { #if defined(OS_WIN) std::string user_domain; if (base::EnvVarGetter::Create()->GetEnv("USERDOMAIN", &user_domain) && diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 8ff3c42..56f2f79 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -33,7 +33,6 @@ #include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/location_bar/location_bar_view.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/pref_names.h" @@ -461,10 +460,8 @@ void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { gfx::Size BookmarkBarView::GetPreferredSize() { // We don't want the bookmark bar view in the app launcher new tab page. - static bool extension_apps = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableApps); - bool hide_bookmark_bar = (extension_apps && OnNewTabPage()) || - OnAppsPage(); + bool hide_bookmark_bar = + (Extension::AppsAreEnabled() && OnNewTabPage()) || OnAppsPage(); if (!hide_bookmark_bar) return LayoutItems(true); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 64da0bd..fece52f 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -103,14 +103,6 @@ const char kDisableAltWinstation[] = "disable-winsta"; // Disable the ApplicationCache. const char kDisableApplicationCache[] = "disable-application-cache"; -// Disables the app launcher popup when a new tab is created, directly creates -// a tab instead. Takes precedence over kAppLauncherForNewTab. -// TODO(jcivelli): http://crbug.com/44089 this flag is required for some tests -// to work, as showing the app launcher is the default on -// ChromeOS but not on other platforms. Tests should be fixed -// once it becomes the default behavior on all platforms. -const char kDisableAppsPanel[] = "disable-apps-panel"; - // Replaces the audio IPC layer for <audio> and <video> with a mock audio // device, useful when using remote desktop or machines without sound cards. // This is temporary until we fix the underlying problem. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 26a94f9..71b6afb 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -45,7 +45,6 @@ extern const char kDebugPrint[]; extern const char kDiagnostics[]; extern const char kDisableAltWinstation[]; extern const char kDisableApplicationCache[]; -extern const char kDisableAppsPanel[]; extern const char kDisableAudio[]; extern const char kDisableAuthNegotiateCnameLookup[]; extern const char kDisableBackingStoreLimit[]; diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 956017c..89d7095 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -724,8 +724,7 @@ Extension::Extension(const FilePath& path) being_upgraded_(false) { DCHECK(path.IsAbsolute()); - apps_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableApps); + apps_enabled_ = AppsAreEnabled(); location_ = INVALID; #if defined(OS_WIN) @@ -930,6 +929,17 @@ GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { chrome::kStandardSchemeSeparator + extension_id + "/"); } +// static +bool Extension::AppsAreEnabled() { +#if defined(OS_CHROMEOS) + return true; +#else + static bool apps_enabled_mode = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps); + return apps_enabled_mode; +#endif +} + bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, std::string* error) { if (source.HasKey(keys::kPublicKey)) { diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 9063b12..a135df5 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -209,6 +209,10 @@ class Extension { // Returns the base extension url for a given |extension_id|. static GURL GetBaseURLFromExtensionId(const std::string& extension_id); + // Returns whether the browser has apps enabled (either as the default or if + // it was explictly turned on via a command line switch). + static bool AppsAreEnabled(); + // Initialize the extension from a parsed manifest. // Usually, the id of an extension is generated by the "key" property of // its manifest, but if |require_key| is |false|, a temporary ID will be diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index 36e0266..a92bdf5 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -76,6 +76,12 @@ class ManifestTest : public testing::Test { }; TEST_F(ManifestTest, AppsDisabledByDefault) { +#if defined(OS_CHROMEOS) + // On ChromeOS, apps are enabled by default. + if (Extension::AppsAreEnabled()) + return; +#endif + enable_apps_ = false; LoadAndExpectError("web_content_disabled.json", errors::kAppsNotEnabled); LoadAndExpectError("launch_local_path.json", errors::kAppsNotEnabled); diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 8a71b9d..9939108 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -138,11 +138,6 @@ void InProcessBrowserTest::SetUp() { // Don't show the first run ui. command_line->AppendSwitch(switches::kNoFirstRun); - // TODO(jcivelli): http://crbug.com/44089 We disable the app launcher on new - // tab behavior for now until it is the default behavior on - // all platforms. - command_line->AppendSwitch(switches::kDisableAppsPanel); - // This is a Browser test. command_line->AppendSwitchWithValue(switches::kTestType, ASCIIToWide(kBrowserTestType)); diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 6b8c2a5..7312b8c 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -130,10 +130,6 @@ UITestBase::UITestBase() terminate_timeout_ms_(kWaitForTerminateMsec) { PathService::Get(chrome::DIR_APP, &browser_directory_); PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); - // TODO(jcivelli): http://crbug.com/44089 We disable the app launcher on new - // tab behavior for now until it is the default behavior on - // all platforms. - launch_arguments_.AppendSwitch(switches::kDisableAppsPanel); } UITestBase::UITestBase(MessageLoop::Type msg_loop_type) @@ -160,10 +156,6 @@ UITestBase::UITestBase(MessageLoop::Type msg_loop_type) terminate_timeout_ms_(kWaitForTerminateMsec) { PathService::Get(chrome::DIR_APP, &browser_directory_); PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); - // TODO(jcivelli): http://crbug.com/44089 We disable the app launcher on new - // tab behavior for now until it is the default behavior on - // all platforms. - launch_arguments_.AppendSwitch(switches::kDisableAppsPanel); } UITestBase::~UITestBase() { |