#include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h"
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h"
#include "chrome/browser/ui/views/frame/taskbar_decorator.h"
+#include "chrome/browser/ui/zoom/zoom_controller.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
#include "extensions/common/extension.h"
#include "ui/aura/window_observer.h"
#endif
-using apps::AppWindow;
+using extensions::AppWindow;
namespace {
public aura::WindowObserver {
public:
NativeAppWindowStateDelegate(AppWindow* app_window,
- apps::NativeAppWindow* native_app_window)
+ extensions::NativeAppWindow* native_app_window)
: app_window_(app_window),
window_state_(
ash::wm::GetWindowState(native_app_window->GetNativeWindow())) {
window_state_->AddObserver(this);
window_state_->window()->AddObserver(this);
}
- virtual ~NativeAppWindowStateDelegate(){
+ virtual ~NativeAppWindowStateDelegate() {
if (window_state_) {
window_state_->RemoveObserver(this);
window_state_->window()->RemoveObserver(this);
init_params.delegate = this;
init_params.remove_standard_frame = IsFrameless() || has_frame_color_;
init_params.use_system_default_icon = true;
- // TODO(erg): Conceptually, these are toplevel windows, but we theoretically
- // could plumb context through to here in some cases.
- init_params.top_level = true;
- if (create_params.transparent_background)
+ if (create_params.alpha_enabled)
init_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
init_params.keep_on_top = create_params.always_on_top;
+ init_params.visible_on_all_workspaces =
+ create_params.visible_on_all_workspaces;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Set up a custom WM_CLASS for app windows. This allows task switchers in
// X11 environments to distinguish them from main browser windows.
init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name);
- init_params.wm_class_class = ShellIntegrationLinux::GetProgramClassName();
+ init_params.wm_class_class = shell_integration_linux::GetProgramClassName();
const char kX11WindowRoleApp[] = "app";
init_params.wm_role_name = std::string(kX11WindowRoleApp);
#endif
SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets),
create_params.GetContentMaximumSize(frame_insets));
if (!window_bounds.IsEmpty()) {
- typedef apps::AppWindow::BoundsSpecification BoundsSpecification;
+ typedef AppWindow::BoundsSpecification BoundsSpecification;
bool position_specified =
window_bounds.x() != BoundsSpecification::kUnspecifiedPosition &&
window_bounds.y() != BoundsSpecification::kUnspecifiedPosition;
}
if (IsFrameless() &&
- init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW &&
- !create_params.resizable) {
+ init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) {
// The given window is most likely not rectangular since it uses
- // transparency, has no standard frame and the user cannot resize it using
- // the OS supplied methods. Therefore we do not use a shadow for it.
+ // transparency and has no standard frame, don't show a shadow for it.
// TODO(skuhne): If we run into an application which should have a shadow
// but does not have, a new attribute has to be added.
wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE);
arraysize(kAppWindowAcceleratorMap) +
arraysize(kAppWindowKioskAppModeAcceleratorMap));
+ // Ensure there is a ZoomController in kiosk mode, otherwise the processing
+ // of the accelerators will cause a crash.
+ DCHECK(!is_kiosk_app_mode ||
+ ZoomController::FromWebContents(web_view()->GetWebContents()));
+
for (std::map<ui::Accelerator, int>::const_iterator iter =
accelerator_table.begin();
iter != accelerator_table.end(); ++iter) {
#else
params.bounds = gfx::Rect(preferred_size_);
#endif
- // TODO(erg): Conceptually, these are toplevel windows, but we theoretically
- // could plumb context through to here in some cases.
- params.top_level = true;
widget()->Init(params);
widget()->set_focus_on_creation(create_params.focused);
-
-#if defined(USE_ASH)
- if (create_params.state == ui::SHOW_STATE_DETACHED) {
- gfx::Rect window_bounds(initial_window_bounds.x(),
- initial_window_bounds.y(),
- preferred_size_.width(),
- preferred_size_.height());
- aura::Window* native_window = GetNativeWindow();
- ash::wm::GetWindowState(native_window)->set_panel_attached(false);
- aura::client::ParentWindowWithContext(native_window,
- native_window->GetRootWindow(),
- native_window->GetBoundsInScreen());
- widget()->SetBounds(window_bounds);
- }
-#else
- // TODO(stevenjb): NativeAppWindow panels need to be implemented for other
- // platforms.
-#endif
}
views::NonClientFrameView*
case ui::SHOW_STATE_NORMAL:
case ui::SHOW_STATE_MAXIMIZED:
case ui::SHOW_STATE_FULLSCREEN:
- case ui::SHOW_STATE_DETACHED:
return restore_state;
case ui::SHOW_STATE_DEFAULT:
int hit_test =
widget()->non_client_view()->NonClientHitTest(point_in_view_coords);
if (hit_test == HTCAPTION) {
- menu_runner_.reset(new views::MenuRunner(model.get()));
+ menu_runner_.reset(new views::MenuRunner(
+ model.get(),
+ views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
if (menu_runner_->RunMenuAt(source->GetWidget(),
NULL,
gfx::Rect(p, gfx::Size(0, 0)),
views::MENU_ANCHOR_TOPLEFT,
- source_type,
- views::MenuRunner::HAS_MNEMONICS |
- views::MenuRunner::CONTEXT_MENU) ==
+ source_type) ==
views::MenuRunner::MENU_DELETED) {
return;
}
ash::CustomFrameViewAsh* custom_frame_view =
new ash::CustomFrameViewAsh(widget);
-#if defined(OS_CHROMEOS)
// Non-frameless app windows can be put into immersive fullscreen.
- // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for
- // Windows Ash.
immersive_fullscreen_controller_.reset(
new ash::ImmersiveFullscreenController());
custom_frame_view->InitImmersiveFullscreenControllerForView(
immersive_fullscreen_controller_.get());
-#endif
custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
return custom_frame_view;
}
#endif
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // Linux always uses the non standard frame view because the OS draws the
- // frame (if a frame is needed).
- return CreateNonStandardAppFrame();
-#else
- if (IsFrameless() || has_frame_color_)
- return CreateNonStandardAppFrame();
-#endif
- return CreateStandardDesktopAppFrame();
+ return (IsFrameless() || has_frame_color_) ?
+ CreateNonStandardAppFrame() : CreateStandardDesktopAppFrame();
}
bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const {
// views::View implementation.
-gfx::Size ChromeNativeAppWindowViews::GetPreferredSize() {
+gfx::Size ChromeNativeAppWindowViews::GetPreferredSize() const {
if (!preferred_size_.IsEmpty())
return preferred_size_;
return NativeAppWindowViews::GetPreferredSize();
is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE);
widget()->SetFullscreen(is_fullscreen_);
-#if defined(USE_ASH)
+ // TODO(oshima): Remove USE_ATHENA once athena has its own NativeAppWindow.
+#if defined(USE_ASH) && !defined(USE_ATHENA)
if (immersive_fullscreen_controller_.get()) {
// |immersive_fullscreen_controller_| should only be set if immersive
// fullscreen is the fullscreen type used by the OS.
return is_fullscreen_;
}
-bool ChromeNativeAppWindowViews::IsDetached() const {
- if (!app_window()->window_type_is_panel())
- return false;
-#if defined(USE_ASH)
- return !ash::wm::GetWindowState(widget()->GetNativeWindow())
- ->panel_attached();
-#else
- return false;
-#endif
-}
-
void ChromeNativeAppWindowViews::UpdateBadgeIcon() {
const gfx::Image* icon = NULL;
if (!app_window()->badge_icon().IsEmpty()) {
aura::Window* native_window = widget()->GetNativeWindow();
if (shape_) {
- native_window->layer()->SetAlphaShape(
- make_scoped_ptr(new SkRegion(*shape_)));
+ widget()->SetShape(new SkRegion(*shape_));
if (!had_shape) {
native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
new ShapedAppWindowTargeter(native_window, this)));
if (had_shape)
native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>());
}
+ widget()->OnSizeConstraintsChanged();
}
bool ChromeNativeAppWindowViews::HasFrameColor() const {