summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash_switches.cc5
-rw-r--r--ash/ash_switches.h1
-rw-r--r--ash/shell.cc6
-rw-r--r--ash/shell.h4
-rw-r--r--ash/wm/workspace/frame_maximize_button.cc11
-rw-r--r--ash/wm/workspace/frame_maximize_button.h3
-rw-r--r--ash/wm/workspace/workspace_event_handler.cc3
-rw-r--r--chrome/app/generated_resources.grd7
-rw-r--r--chrome/browser/about_flags.cc7
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_api.cc35
-rw-r--r--chrome/browser/extensions/extension_prefs.cc12
-rw-r--r--chrome/browser/ui/app_list/extension_app_item.cc26
-rw-r--r--chrome/browser/ui/ash/launcher/launcher_context_menu.cc18
-rw-r--r--chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc18
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer_ash.cc11
15 files changed, 145 insertions, 22 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index 1b18492..516fa60 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -141,8 +141,11 @@ const char kAuraLegacyPowerButton[] = "aura-legacy-power-button";
// Force Ash to open its root window on the desktop, even on Windows 8 where
// it would normally end up in metro.
const char kForceAshToDesktop[] = "ash-force-desktop";
-;
#endif
+// Enables a mode which enforces all browser & application windows to be created
+// in maximized mode.
+const char kForcedMaximizeMode[] = "forced-maximize-mode";
+
} // namespace switches
} // namespace ash
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index f25647a..003cd35 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -55,6 +55,7 @@ ASH_EXPORT extern const char kAuraLegacyPowerButton[];
#if defined(OS_WIN)
ASH_EXPORT extern const char kForceAshToDesktop[];
#endif
+ASH_EXPORT extern const char kForcedMaximizeMode[];
} // namespace switches
} // namespace ash
diff --git a/ash/shell.cc b/ash/shell.cc
index 589caed..203145b 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -419,6 +419,12 @@ bool Shell::IsLauncherPerDisplayEnabled() {
return !command_line->HasSwitch(switches::kAshDisableLauncherPerDisplay);
}
+// static
+bool Shell::IsForcedMaximizeMode() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ return command_line->HasSwitch(switches::kForcedMaximizeMode);
+}
+
void Shell::Init() {
delegate_->PreInit();
#if defined(OS_CHROMEOS) && defined(USE_X11)
diff --git a/ash/shell.h b/ash/shell.h
index 92ef58c..43ee1c6 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -200,6 +200,10 @@ class ASH_EXPORT Shell
// True if "launcher per display" feature is enabled.
static bool IsLauncherPerDisplayEnabled();
+ // True if an experimental maximize mode is enabled which forces browser and
+ // application windows to be maximized only.
+ static bool IsForcedMaximizeMode();
+
void set_active_root_window(aura::RootWindow* active_root_window) {
active_root_window_ = active_root_window;
}
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index d258b378..0329e3f 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -91,6 +91,9 @@ FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
bubble_appearance_delay_ms_(kBubbleAppearanceDelayMS) {
// TODO(sky): nuke this. It's temporary while we don't have good images.
SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
+
+ if (ash::Shell::IsForcedMaximizeMode())
+ views::View::SetVisible(false);
}
FrameMaximizeButton::~FrameMaximizeButton() {
@@ -306,6 +309,14 @@ void FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) {
ImageButton::OnGestureEvent(event);
}
+void FrameMaximizeButton::SetVisible(bool visible) {
+ // In the enforced maximized mode we do not allow to be made visible.
+ if (ash::Shell::IsForcedMaximizeMode())
+ return;
+
+ views::View::SetVisible(visible);
+}
+
void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) {
DCHECK(is_snap_enabled_);
// Prepare the help menu.
diff --git a/ash/wm/workspace/frame_maximize_button.h b/ash/wm/workspace/frame_maximize_button.h
index b6aa1fa..6429aed 100644
--- a/ash/wm/workspace/frame_maximize_button.h
+++ b/ash/wm/workspace/frame_maximize_button.h
@@ -74,6 +74,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton,
// ui::EventHandler overrides:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+ // views::View overwrite:
+ virtual void SetVisible(bool visible) OVERRIDE;
+
// Unit test overwrite: Change the UI delay used for the bubble show up.
void set_bubble_appearance_delay_ms(int bubble_appearance_delay_ms) {
bubble_appearance_delay_ms_ = bubble_appearance_delay_ms;
diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc
index 5839e21..16d86ca 100644
--- a/ash/wm/workspace/workspace_event_handler.cc
+++ b/ash/wm/workspace/workspace_event_handler.cc
@@ -91,7 +91,8 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
target->delegate()->GetNonClientComponent(event->location()) ==
- HTCAPTION) {
+ HTCAPTION &&
+ !ash::Shell::IsForcedMaximizeMode()) {
bool destroyed = false;
destroyed_ = &destroyed;
ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 331d270..87637e42 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6934,6 +6934,13 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION" desc="Description for the flag to show a menu that lets you change the alignment of the launcher.">
Enables a menu that allows changing the side the launcher is aligned to.
</message>
+ <message name="IDS_FLAGS_FORCE_MAXIMIZE_MODE_NAME" desc="Name for the flag which forces the window manager to use maximized mode wherever possible.">
+ Always maximized mode
+ </message>
+ <message name="IDS_FLAGS_FORCE_MAXIMIZE_MODE_DESCRIPTION" desc="Description for the flag which forces the window manager to use maximized mode wherever possible.">
+ Forces the window manager to use maximize mode wherever possible.
+ </message>
+
<message name="IDS_FLAGS_DISABLE_MINIMIZE_ON_SECOND_LAUNCHER_ITEM_CLICK_NAME" desc="Name for the flag which allows to minimize a window upon launcher item click under certain conditions.">
Disallow launcher to minimize-on-click
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 90454c9..8fec269 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1028,6 +1028,13 @@ const Experiment kExperiments[] = {
kOsAll,
SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
},
+ {
+ "forced-maximize-mode",
+ IDS_FLAGS_FORCE_MAXIMIZE_MODE_NAME,
+ IDS_FLAGS_FORCE_MAXIMIZE_MODE_DESCRIPTION,
+ kOsLinux | kOsWin | kOsCrOS,
+ SINGLE_VALUE_TYPE(ash::switches::kForcedMaximizeMode),
+ },
#endif // defined(USE_ASH)
#if defined(OS_CHROMEOS)
{
diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc
index 1f726db..a421b95 100644
--- a/chrome/browser/extensions/api/app_window/app_window_api.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_api.cc
@@ -24,6 +24,13 @@
#include "googleurl/src/gurl.h"
#include "ui/gfx/rect.h"
+#if defined(USE_ASH)
+#include "ash/shell.h"
+#include "ash/wm/property_util.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#endif
+
namespace app_window = extensions::api::app_window;
namespace Create = app_window::Create;
@@ -101,6 +108,11 @@ bool AppWindowCreateFunction::RunImpl() {
// with a hack in AppWindowCustomBindings::GetView().
ShellWindow::CreateParams create_params;
app_window::CreateWindowOptions* options = params->options.get();
+#if defined(USE_ASH)
+ bool force_maximize = ash::Shell::IsForcedMaximizeMode();
+#else
+ bool force_maximize = false;
+#endif
if (options) {
if (options->id.get()) {
// TODO(mek): use URL if no id specified?
@@ -227,12 +239,35 @@ bool AppWindowCreateFunction::RunImpl() {
create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED;
break;
}
+ } else {
+ force_maximize = false;
}
}
create_params.creator_process_id =
render_view_host_->GetProcess()->GetID();
+ // Rather then maximizing the window after it was created, we maximize it
+ // immediately - that way the initial presentation is much smoother (no odd
+ // rectangles are shown temporarily in the added space). Note that suppressing
+ // animations does not help to remove the shown artifacts.
+#if USE_ASH
+ if (force_maximize && !create_params.maximum_size.IsEmpty()) {
+ // Check that the application is able to fill the monitor - if not don't
+ // maximize.
+ // TODO(skuhne): In case of multi monitor usage we should find out in
+ // advance on which monitor the window will be displayed (or be happy with
+ // a temporary bad frame upon creation).
+ gfx::Size size = ash::Shell::GetPrimaryRootWindow()->bounds().size();
+ if (size.width() > create_params.maximum_size.width() ||
+ size.height() > create_params.maximum_size.height())
+ force_maximize = false;
+ }
+ #endif
+
+ if (force_maximize)
+ create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED;
+
ShellWindow* shell_window =
ShellWindow::Create(profile(), GetExtension(), url, create_params);
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index b81c2bf..5748c7b 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -32,6 +32,9 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(USE_ASH)
+#include "ash/shell.h"
+#endif
#if defined(OS_WIN)
#include "win8/util/win8_util.h"
#endif // OS_WIN
@@ -1257,13 +1260,18 @@ ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType(
} else {
result = default_pref_value;
}
- #if defined(OS_MACOSX)
+#if (USE_ASH)
+ if (ash::Shell::IsForcedMaximizeMode() &&
+ (result == LAUNCH_FULLSCREEN || result == LAUNCH_WINDOW))
+ result = LAUNCH_REGULAR;
+#endif
+#if defined(OS_MACOSX)
// App windows are not yet supported on mac. Pref sync could make
// the launch type LAUNCH_WINDOW, even if there is no UI to set it
// on mac.
if (!extension->is_platform_app() && result == LAUNCH_WINDOW)
result = LAUNCH_REGULAR;
- #endif
+#endif
#if defined(OS_WIN)
// We don't support app windows in Windows 8 single window Metro mode.
diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc
index 4cd4ff4..a8b0856 100644
--- a/chrome/browser/ui/app_list/extension_app_item.cc
+++ b/chrome/browser/ui/app_list/extension_app_item.cc
@@ -37,6 +37,10 @@
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia_operations.h"
+#if defined(USE_ASH)
+#include "ash/shell.h"
+#endif
+
using extensions::Extension;
namespace {
@@ -559,15 +563,19 @@ ui::MenuModel* ExtensionAppItem::GetContextMenuModel() {
context_menu_model_->AddCheckItemWithStringId(
LAUNCH_TYPE_PINNED_TAB,
IDS_APP_CONTEXT_MENU_OPEN_PINNED);
- context_menu_model_->AddCheckItemWithStringId(
- LAUNCH_TYPE_WINDOW,
- IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
- // Even though the launch type is Full Screen it is more accurately
- // described as Maximized in Ash.
- context_menu_model_->AddCheckItemWithStringId(
- LAUNCH_TYPE_FULLSCREEN,
- IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
-
+#if defined(USE_ASH)
+ if (!ash::Shell::IsForcedMaximizeMode())
+#endif
+ {
+ context_menu_model_->AddCheckItemWithStringId(
+ LAUNCH_TYPE_WINDOW,
+ IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
+ // Even though the launch type is Full Screen it is more accurately
+ // described as Maximized in Ash.
+ context_menu_model_->AddCheckItemWithStringId(
+ LAUNCH_TYPE_FULLSCREEN,
+ IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
+ }
context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
context_menu_model_->AddItemWithStringId(OPTIONS,
IDS_NEW_TAB_APP_OPTIONS);
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
index 884a635..af4856f 100644
--- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
+++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
@@ -95,14 +95,16 @@ void LauncherContextMenu::Init() {
AddCheckItemWithStringId(
LAUNCH_TYPE_PINNED_TAB,
IDS_APP_CONTEXT_MENU_OPEN_PINNED);
- AddCheckItemWithStringId(
- LAUNCH_TYPE_WINDOW,
- IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
- // Even though the launch type is Full Screen it is more accurately
- // described as Maximized in Ash.
- AddCheckItemWithStringId(
- LAUNCH_TYPE_FULLSCREEN,
- IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
+ if (!ash::Shell::IsForcedMaximizeMode()) {
+ AddCheckItemWithStringId(
+ LAUNCH_TYPE_WINDOW,
+ IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
+ // Even though the launch type is Full Screen it is more accurately
+ // described as Maximized in Ash.
+ AddCheckItemWithStringId(
+ LAUNCH_TYPE_FULLSCREEN,
+ IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
+ }
}
} else if (item_.type == ash::TYPE_BROWSER_SHORTCUT) {
AddItem(MENU_NEW_WINDOW,
diff --git a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
index 6810709..5fd7b93 100644
--- a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
@@ -42,6 +42,8 @@ const int kShadowHeightStretch = -1;
class AppNonClientFrameViewAsh::ControlView
: public views::View, public views::ButtonListener {
public:
+ // TODO(skuhne): If we keep the "always maximized" experiment we might want to
+ // make this function be able to work with a |restore_button_| which is NULL.
explicit ControlView(AppNonClientFrameViewAsh* owner) :
owner_(owner),
close_button_(new views::ImageButton(this)),
@@ -69,6 +71,17 @@ class AppNonClientFrameViewAsh::ControlView
virtual ~ControlView() {}
virtual void Layout() OVERRIDE {
+ if (ash::Shell::IsForcedMaximizeMode()) {
+ // TODO(skuhne): If this experiment would get persued, it would be better
+ // to check here the |restore_button_|'s visibility. Furthermore we
+ // should change |shadow_| to a new bitmap which can host only a single
+ // button.
+ gfx::Size size = restore_button_->bounds().size();
+ if (size.width()) {
+ size.set_width(0);
+ restore_button_->SetSize(size);
+ }
+ }
restore_button_->SetPosition(gfx::Point(kShadowStart, 0));
close_button_->SetPosition(gfx::Point(kShadowStart +
restore_button_->width() - kButtonOverlap, 0));
@@ -92,7 +105,10 @@ class AppNonClientFrameViewAsh::ControlView
}
virtual gfx::Size GetPreferredSize() OVERRIDE {
- return gfx::Size(shadow_->width(),
+ int maximize_button_deduction = ash::Shell::IsForcedMaximizeMode() ?
+ restore_button_->GetPreferredSize().width() : 0;
+
+ return gfx::Size(shadow_->width() - maximize_button_deduction,
shadow_->height() + kShadowHeightStretch);
}
diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash.cc b/chrome/browser/ui/window_sizer/window_sizer_ash.cc
index e4ed374..b6184bd 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_ash.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer_ash.cc
@@ -159,6 +159,17 @@ bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen,
}
bounds_in_screen->SetRect(0, 0, 0, 0);
+ // Experiment: Force the maximize mode for all windows.
+ if (ash::Shell::IsForcedMaximizeMode()) {
+ // Exceptions: Do not maximize popups and do not maximize windowed V1 apps
+ // which explicitly specify a |show_state| (they might be tuned for a
+ // particular resolution / type).
+ bool is_tabbed = browser_ && browser_->is_type_tabbed();
+ bool is_popup = browser_ && browser_->is_type_popup();
+ if (!is_popup && (is_tabbed || *show_state == ui::SHOW_STATE_DEFAULT))
+ *show_state = ui::SHOW_STATE_MAXIMIZED;
+ }
+
ui::WindowShowState passed_show_state = *show_state;
if (!GetSavedWindowBounds(bounds_in_screen, show_state))
GetDefaultWindowBounds(bounds_in_screen);