| Index: apps/shell/browser/shell_native_app_window.h
|
| diff --git a/apps/shell/browser/shell_native_app_window.h b/apps/shell/browser/shell_native_app_window.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e6e6d8074d6718b13aac29f08f87ef297f656167
|
| --- /dev/null
|
| +++ b/apps/shell/browser/shell_native_app_window.h
|
| @@ -0,0 +1,148 @@
|
| +// Copyright 2014 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 APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_
|
| +#define APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_
|
| +
|
| +#include "apps/ui/native_app_window.h"
|
| +#include "base/observer_list.h"
|
| +#include "ui/views/widget/widget_delegate.h"
|
| +#include "ui/views/widget/widget_observer.h"
|
| +
|
| +namespace views {
|
| +class WebView;
|
| +class Widget;
|
| +}
|
| +
|
| +namespace apps {
|
| +
|
| +class ShellWindowFrameView;
|
| +
|
| +// A simple views-based native app window implementation for app_shell. It is
|
| +// frameless and is permanently in the "restored" state (not maximized or
|
| +// fullscreen).
|
| +class ShellNativeAppWindow : public NativeAppWindow,
|
| + public views::WidgetDelegateView,
|
| + public views::WidgetObserver {
|
| + public:
|
| + ShellNativeAppWindow();
|
| + virtual ~ShellNativeAppWindow();
|
| +
|
| + void Init(ShellWindow* shell_window, const gfx::Rect& window_bounds);
|
| +
|
| + private:
|
| + // Initializes |window_| to center it on the screen.
|
| + void InitializeWindow(const gfx::Rect& window_bounds);
|
| +
|
| + // Informs observers of the size of the view (initially and on update).
|
| + void OnViewWasResized();
|
| +
|
| + // Returns this app's extension.
|
| + const extensions::Extension* GetExtension();
|
| +
|
| + // Returns the WebContents for the app.
|
| + content::WebContents* GetWebContents();
|
| +
|
| + // ui::BaseWindow implementation.
|
| + virtual bool IsActive() const OVERRIDE;
|
| + virtual bool IsMaximized() const OVERRIDE;
|
| + virtual bool IsMinimized() const OVERRIDE;
|
| + virtual bool IsFullscreen() const OVERRIDE;
|
| + virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
| + virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
|
| + virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
|
| + virtual gfx::Rect GetBounds() const OVERRIDE;
|
| + virtual void Show() OVERRIDE;
|
| + virtual void ShowInactive() OVERRIDE;
|
| + virtual void Hide() OVERRIDE;
|
| + virtual void Close() OVERRIDE;
|
| + virtual void Activate() OVERRIDE;
|
| + virtual void Deactivate() OVERRIDE;
|
| + virtual void Maximize() OVERRIDE;
|
| + virtual void Minimize() OVERRIDE;
|
| + virtual void Restore() OVERRIDE;
|
| + virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
|
| + virtual void FlashFrame(bool flash) OVERRIDE;
|
| + virtual bool IsAlwaysOnTop() const OVERRIDE;
|
| + virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
|
| +
|
| + // WidgetDelegate implementation.
|
| + virtual void OnWidgetMove() OVERRIDE;
|
| + virtual views::View* GetInitiallyFocusedView() OVERRIDE;
|
| + virtual bool CanResize() const OVERRIDE;
|
| + virtual bool CanMaximize() const OVERRIDE;
|
| + virtual base::string16 GetWindowTitle() const OVERRIDE;
|
| + virtual bool ShouldShowWindowTitle() const OVERRIDE;
|
| + virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
|
| + virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
|
| + virtual bool ShouldShowWindowIcon() const OVERRIDE;
|
| + virtual void SaveWindowPlacement(const gfx::Rect& bounds,
|
| + ui::WindowShowState show_state) OVERRIDE;
|
| + virtual void DeleteDelegate() OVERRIDE;
|
| + virtual views::Widget* GetWidget() OVERRIDE;
|
| + virtual const views::Widget* GetWidget() const OVERRIDE;
|
| + virtual views::View* GetContentsView() OVERRIDE;
|
| + virtual views::NonClientFrameView* CreateNonClientFrameView(
|
| + views::Widget* widget) OVERRIDE;
|
| + virtual bool WidgetHasHitTestMask() const OVERRIDE;
|
| + virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
|
| + virtual bool ShouldDescendIntoChildForEventHandling(
|
| + gfx::NativeView child,
|
| + const gfx::Point& location) OVERRIDE;
|
| +
|
| + // WidgetObserver implementation.
|
| + virtual void OnWidgetVisibilityChanged(views::Widget* widget,
|
| + bool visible) OVERRIDE;
|
| + virtual void OnWidgetActivationChanged(views::Widget* widget,
|
| + bool active) OVERRIDE;
|
| +
|
| + // views::View implementation.
|
| + virtual void Layout() OVERRIDE;
|
| + virtual void ViewHierarchyChanged(
|
| + const ViewHierarchyChangedDetails& details) OVERRIDE;
|
| + virtual gfx::Size GetMinimumSize() OVERRIDE;
|
| + virtual gfx::Size GetMaximumSize() OVERRIDE;
|
| + virtual void OnFocus() OVERRIDE;
|
| + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
|
| +
|
| + // NativeAppWindow implementation.
|
| + virtual void SetFullscreen(int fullscreen_types) OVERRIDE;
|
| + virtual bool IsFullscreenOrPending() const OVERRIDE;
|
| + virtual bool IsDetached() const OVERRIDE;
|
| + virtual void UpdateWindowIcon() OVERRIDE;
|
| + virtual void UpdateWindowTitle() OVERRIDE;
|
| + virtual void UpdateBadgeIcon() OVERRIDE;
|
| + virtual void UpdateDraggableRegions(
|
| + const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
|
| + virtual SkRegion* GetDraggableRegion() OVERRIDE;
|
| + virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE;
|
| + virtual void HandleKeyboardEvent(
|
| + const content::NativeWebKeyboardEvent& event) OVERRIDE;
|
| + virtual bool IsFrameless() const OVERRIDE;
|
| + virtual gfx::Insets GetFrameInsets() const OVERRIDE;
|
| + virtual void HideWithApp() OVERRIDE;
|
| + virtual void ShowWithApp() OVERRIDE;
|
| + virtual void UpdateWindowMinMaxSize() OVERRIDE;
|
| +
|
| + // web_modal::WebContentsModalDialogHost implementation.
|
| + virtual gfx::NativeView GetHostView() const OVERRIDE;
|
| + virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE;
|
| + virtual gfx::Size GetMaximumDialogSize() OVERRIDE;
|
| + virtual void AddObserver(
|
| + web_modal::ModalDialogHostObserver* observer) OVERRIDE;
|
| + virtual void RemoveObserver(
|
| + web_modal::ModalDialogHostObserver* observer) OVERRIDE;
|
| +
|
| + ShellWindow* shell_window_; // Not owned.
|
| + views::WebView* web_view_;
|
| + views::Widget* window_;
|
| +
|
| + ObserverList<web_modal::ModalDialogHostObserver> observer_list_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ShellNativeAppWindow);
|
| +};
|
| +
|
| +} // namespace apps
|
| +
|
| +#endif // APPS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_H_
|
|
|