diff options
-rw-r--r-- | ash/root_window_controller.cc | 2 | ||||
-rw-r--r-- | ash/shelf_types.h | 3 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.cc | 35 | ||||
-rw-r--r-- | ash/wm/shelf_layout_manager.h | 8 | ||||
-rw-r--r-- | chrome/browser/app_mode/app_mode_utils.cc | 19 | ||||
-rw-r--r-- | chrome/browser/app_mode/app_mode_utils.h | 15 | ||||
-rw-r--r-- | chrome/browser/lifetime/application_lifetime_aura.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/ash/ash_init.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/chrome_shell_delegate.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/fullscreen/fullscreen_controller.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 5 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 6 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
17 files changed, 134 insertions, 22 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index 67ab213..bbd611e 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -487,6 +487,8 @@ void RootWindowController::ShowContextMenu( DCHECK(Shell::GetInstance()->delegate()); scoped_ptr<ui::MenuModel> menu_model( Shell::GetInstance()->delegate()->CreateContextMenu(target)); + if (!menu_model.get()) + return; views::MenuModelAdapter menu_model_adapter(menu_model.get()); views::MenuRunner menu_runner(menu_model_adapter.CreateMenu()); diff --git a/ash/shelf_types.h b/ash/shelf_types.h index d1d6cb5..ac35c58 100644 --- a/ash/shelf_types.h +++ b/ash/shelf_types.h @@ -20,6 +20,9 @@ enum ShelfAutoHideBehavior { // Never auto-hide. SHELF_AUTO_HIDE_BEHAVIOR_NEVER, + + // Always hide. + SHELF_AUTO_HIDE_ALWAYS_HIDDEN, }; enum ShelfVisibilityState { diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 52f6b03..ec62865 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -247,15 +247,42 @@ void ShelfLayoutManager::LayoutShelf() { UpdateHitTestBounds(); } +ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { + switch(auto_hide_behavior_) { + case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: + return SHELF_AUTO_HIDE; + case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: + return SHELF_VISIBLE; + case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: + return SHELF_HIDDEN; + } + return SHELF_VISIBLE; +} + +ShelfVisibilityState +ShelfLayoutManager::CalculateShelfVisibilityWhileDragging() { + switch(auto_hide_behavior_) { + case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: + case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: + return SHELF_AUTO_HIDE; + case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: + return SHELF_HIDDEN; + } + return SHELF_VISIBLE; +} + void ShelfLayoutManager::UpdateVisibilityState() { ShellDelegate* delegate = Shell::GetInstance()->delegate(); if (delegate && delegate->IsScreenLocked()) { SetState(SHELF_VISIBLE); } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { - SetState(SHELF_AUTO_HIDE); + // TODO(zelidrag): Verify shelf drag animation still shows on the device + // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. + SetState(CalculateShelfVisibilityWhileDragging()); } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { // The user choosing immersive mode indicates he or she wants to maximize // screen real-estate for content, so always auto-hide the shelf. + DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN); SetState(SHELF_AUTO_HIDE); } else { WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); @@ -265,14 +292,12 @@ void ShelfLayoutManager::UpdateVisibilityState() { break; case WORKSPACE_WINDOW_STATE_MAXIMIZED: - SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? - SHELF_AUTO_HIDE : SHELF_VISIBLE); + SetState(CalculateShelfVisibility()); break; case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: case WORKSPACE_WINDOW_STATE_DEFAULT: - SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? - SHELF_AUTO_HIDE : SHELF_VISIBLE); + SetState(CalculateShelfVisibility()); SetWindowOverlapsShelf(window_state == WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); break; diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h index de4425a..01775bb 100644 --- a/ash/wm/shelf_layout_manager.h +++ b/ash/wm/shelf_layout_manager.h @@ -108,6 +108,14 @@ class ASH_EXPORT ShelfLayoutManager : // widgets. void LayoutShelf(); + // Returns shelf visibility state based on current value of auto hide + // behavior setting. + ShelfVisibilityState CalculateShelfVisibility(); + + // Returns shelf visibility state based on current value of auto hide + // behavior setting. + ShelfVisibilityState CalculateShelfVisibilityWhileDragging(); + // Updates the visibility state. void UpdateVisibilityState(); diff --git a/chrome/browser/app_mode/app_mode_utils.cc b/chrome/browser/app_mode/app_mode_utils.cc new file mode 100644 index 0000000..ca3baa5 --- /dev/null +++ b/chrome/browser/app_mode/app_mode_utils.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2013 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. + +#include "chrome/browser/app_mode/app_mode_utils.h" + +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" + +namespace chrome { + +bool IsRunningInAppMode() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + return command_line->HasSwitch(switches::kKioskMode) || + (command_line->HasSwitch(switches::kForceAppMode) && + command_line->HasSwitch(switches::kAppId)); +} + +} // namespace switches diff --git a/chrome/browser/app_mode/app_mode_utils.h b/chrome/browser/app_mode/app_mode_utils.h new file mode 100644 index 0000000..1fe9605 --- /dev/null +++ b/chrome/browser/app_mode/app_mode_utils.h @@ -0,0 +1,15 @@ +// Copyright (c) 2013 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. + +#ifndef CHROME_BROWSER_APP_MODE_APP_MODE_UTILS_H_ +#define CHROME_BROWSER_APP_MODE_APP_MODE_UTILS_H_ + +namespace chrome { + +// Return true if browser process is run in kiosk or forces app mode. +bool IsRunningInAppMode(); + +} // namespace switches + +#endif // CHROME_BROWSER_APP_MODE_APP_MODE_UTILS_H_ diff --git a/chrome/browser/lifetime/application_lifetime_aura.cc b/chrome/browser/lifetime/application_lifetime_aura.cc index b5d47d3..4883cae 100644 --- a/chrome/browser/lifetime/application_lifetime_aura.cc +++ b/chrome/browser/lifetime/application_lifetime_aura.cc @@ -5,9 +5,11 @@ #include "chrome/browser/lifetime/application_lifetime.h" #include "base/command_line.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/notifications/notification_ui_manager.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/switch_utils.h" #include "ui/views/widget/widget.h" #if defined(USE_ASH) @@ -38,7 +40,8 @@ void HandleAppExitingForPlatform() { #if defined(OS_CHROMEOS) if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableZeroBrowsersOpenForTests)) { + switches::kDisableZeroBrowsersOpenForTests) && + !chrome::IsRunningInAppMode()) { // App is exiting, call EndKeepAlive() on behalf of Aura Shell. EndKeepAlive(); // Make sure we have notified the session manager that we are exiting. diff --git a/chrome/browser/ui/ash/ash_init.cc b/chrome/browser/ui/ash/ash_init.cc index 17e9237..d6484a9 100644 --- a/chrome/browser/ui/ash/ash_init.cc +++ b/chrome/browser/ui/ash/ash_init.cc @@ -13,6 +13,7 @@ #include "ash/wm/event_rewriter_event_filter.h" #include "ash/wm/property_util.h" #include "base/command_line.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "chrome/browser/chromeos/accessibility/magnification_manager.h" #include "chrome/browser/lifetime/application_lifetime.h" @@ -106,7 +107,8 @@ void OpenAsh() { SetEnabled(magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL); if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableZeroBrowsersOpenForTests)) { + switches::kDisableZeroBrowsersOpenForTests) && + !chrome::IsRunningInAppMode()) { chrome::StartKeepAlive(); } #endif diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index b6ee520..d2e3d25 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -12,6 +12,7 @@ #include "ash/wm/window_util.h" #include "base/bind.h" #include "base/command_line.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/chromeos/accessibility/magnification_manager.h" #include "chrome/browser/chromeos/login/screen_locker.h" #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" @@ -584,6 +585,10 @@ double ChromeShellDelegate::GetSavedScreenMagnifierScale() { ui::MenuModel* ChromeShellDelegate::CreateContextMenu(aura::RootWindow* root) { DCHECK(launcher_delegate_); + // Don't show context menu for exclusive app runtime mode. + if (chrome::IsRunningInAppMode()) + return NULL; + return new LauncherContextMenu(launcher_delegate_, root); } diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc index 207f51b..4967525 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc @@ -13,6 +13,7 @@ #include "base/command_line.h" #include "base/string_number_conversions.h" #include "base/values.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" @@ -45,6 +46,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/pref_names.h" @@ -631,6 +633,10 @@ Profile* ChromeLauncherControllerPerApp::profile() { ash::ShelfAutoHideBehavior ChromeLauncherControllerPerApp::GetShelfAutoHideBehavior( aura::RootWindow* root_window) const { + // Don't show the shelf in app mode. + if (chrome::IsRunningInAppMode()) + return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; + // See comment in |kShelfAlignment| as to why we consider two prefs. const std::string behavior_value( GetPrefForRootWindow(profile_->GetPrefs(), @@ -1202,6 +1208,11 @@ void ChromeLauncherControllerPerApp::SetShelfAutoHideBehaviorPrefs( case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: value = ash::kShelfAutoHideBehaviorNever; break; + case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: + // This one should not be a valid preference option for now. We only want + // to completely hide it when we run app mode. + NOTREACHED(); + return; } UpdatePerDisplayPref( diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc index 4001dd6..9a9464a 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser.cc @@ -12,6 +12,7 @@ #include "base/command_line.h" #include "base/string_number_conversions.h" #include "base/values.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" @@ -38,6 +39,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/pref_names.h" @@ -658,6 +660,10 @@ bool ChromeLauncherControllerPerBrowser::CanPin() const { ash::ShelfAutoHideBehavior ChromeLauncherControllerPerBrowser::GetShelfAutoHideBehavior( aura::RootWindow* root_window) const { + // Don't show the shelf in the app mode. + if (chrome::IsRunningInAppMode()) + return ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN; + // See comment in |kShelfAlignment| as to why we consider two prefs. const std::string behavior_value( GetPrefForRootWindow(profile_->GetPrefs(), @@ -1130,6 +1136,11 @@ void ChromeLauncherControllerPerBrowser::SetShelfAutoHideBehaviorPrefs( case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER: value = ash::kShelfAutoHideBehaviorNever; break; + case ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN: + // This one should not be a valid preference option for now. We only want + // to completely hide it when we run app mode. + NOTREACHED(); + return; } UpdatePerDisplayPref( diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 99af8b8..a25e4b8 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -29,6 +29,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/api/infobars/infobar_service.h" #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/background/background_contents_service.h" #include "chrome/browser/background/background_contents_service_factory.h" @@ -2071,9 +2072,10 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) { // Browser, Getters for UI (private): StatusBubble* Browser::GetStatusBubble() { - // In kiosk mode, we want to always hide the status bubble. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) + // In kiosk and exclusive app mode, we want to always hide the status bubble. + if (chrome::IsRunningInAppMode()) return NULL; + return window_ ? window_->GetStatusBubble() : NULL; } diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.cc b/chrome/browser/ui/fullscreen/fullscreen_controller.cc index 6a6cf44..8b703a9 100644 --- a/chrome/browser/ui/fullscreen/fullscreen_controller.cc +++ b/chrome/browser/ui/fullscreen/fullscreen_controller.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/profiles/profile.h" @@ -377,11 +378,11 @@ GURL FullscreenController::GetFullscreenExitBubbleURL() const { FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() const { - // In kiosk mode we always want to be fullscreen and do not want to show - // exit instructions for browser mode fullscreen. - bool kiosk = false; -#if !defined(OS_MACOSX) // Kiosk mode not available on Mac. - kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); + // In kiosk and exclusive app mode we always want to be fullscreen and do not + // want to show exit instructions for browser mode fullscreen. + bool app_mode = false; +#if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet. + app_mode = chrome::IsRunningInAppMode(); #endif if (mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY) { @@ -412,7 +413,7 @@ FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() } else { if (!extension_caused_fullscreen_.is_empty()) { return FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION; - } else if (toggled_into_fullscreen_ && !kiosk) { + } else if (toggled_into_fullscreen_ && !app_mode) { return FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; } else { return FEB_TYPE_NONE; @@ -506,8 +507,7 @@ void FullscreenController::ToggleFullscreenModeInternal( // In kiosk mode, we always want to be fullscreen. When the browser first // starts we're not yet fullscreen, so let the initial toggle go through. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && - window_->IsFullscreen()) + if (chrome::IsRunningInAppMode() && window_->IsFullscreen()) return; if (enter_fullscreen) diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 46cc290..ff6ee23 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -15,6 +15,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/api/infobars/infobar_service.h" +#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/tab_helper.h" @@ -2279,9 +2280,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen, browser_->WindowFullscreenStateChanged(); if (fullscreen) { - bool is_kiosk = - CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); - if (!is_kiosk && type != FOR_METRO) { + if (!chrome::IsRunningInAppMode() && type != FOR_METRO) { fullscreen_bubble_.reset(new FullscreenExitBubbleViews( GetWidget(), browser_.get(), url, bubble_type)); } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 7170176..eee497d 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -125,6 +125,8 @@ 'browser/app_controller_mac.mm', 'browser/app_icon_win.cc', 'browser/app_icon_win.h', + 'browser/app_mode/app_mode_utils.cc', + 'browser/app_mode/app_mode_utils.h', 'browser/autocomplete/autocomplete_classifier.cc', 'browser/autocomplete/autocomplete_classifier.h', 'browser/autocomplete/autocomplete_classifier_factory.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 596fd41..cd2bd3e 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -690,9 +690,13 @@ const char kFeedbackServer[] = "feedback-server"; // handled gracefully. const char kFileDescriptorLimit[] = "file-descriptor-limit"; +// Forces application mode. This hides certain system UI elements and forces +// the app to be installed if it hasn't been already. +const char kForceAppMode[] = "force-app-mode"; + // Displays the First Run experience when the browser is started, regardless of // whether or not it's actually the First Run (this overrides kNoFirstRun). -const char kForceFirstRun[] = "force-first-run"; +const char kForceFirstRun[] = "force-first-run"; // Enables using GAIA information to populate profile name and icon. const char kGaiaProfileInfo[] = "gaia-profile-info"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index f45626f..2df75b3 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -193,6 +193,7 @@ extern const char kFlagSwitchesBegin[]; extern const char kFlagSwitchesEnd[]; extern const char kFeedbackServer[]; extern const char kFileDescriptorLimit[]; +extern const char kForceAppMode[]; extern const char kForceFirstRun[]; extern const char kGaiaProfileInfo[]; extern const char kGoogleSearchDomainCheckURL[]; |