Index: extensions/browser/app_window/app_window.h |
diff --git a/extensions/browser/app_window/app_window.h b/extensions/browser/app_window/app_window.h |
index cf5abc746dd9925476a6ea39ae0787e3968fdbe2..c4584320f9bad411c9f77c686a87b8fad09e8bff 100644 |
--- a/extensions/browser/app_window/app_window.h |
+++ b/extensions/browser/app_window/app_window.h |
@@ -10,6 +10,8 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
+#include "components/native_app_window/app_window_create_params.h" |
+#include "components/native_app_window/native_app_window_delegate.h" |
#include "components/sessions/session_id.h" |
#include "components/web_modal/popup_manager.h" |
#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
@@ -33,6 +35,11 @@ class BrowserContext; |
class WebContents; |
} |
+namespace native_app_window { |
+struct DraggableRegion; |
+class NativeAppWindow; |
+} |
+ |
namespace ui { |
class BaseWindow; |
} |
@@ -43,12 +50,9 @@ class AppDelegate; |
class AppWebContentsHelper; |
class Extension; |
class ExtensionRegistry; |
-class NativeAppWindow; |
class PlatformAppBrowserTest; |
class WindowController; |
-struct DraggableRegion; |
- |
// Manages the web contents for app windows. The implementation for this |
// class should create and maintain the WebContents for the window, and handle |
// any message passing between the web contents and the extension system or |
@@ -66,7 +70,8 @@ class AppWindowContents { |
virtual void LoadContents(int32 creator_process_id) = 0; |
// Called when the native window changes. |
- virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; |
+ virtual void NativeWindowChanged( |
+ native_app_window::NativeAppWindow* native_app_window) = 0; |
// Called when the native window closes. |
virtual void NativeWindowClosed() = 0; |
@@ -86,121 +91,12 @@ class AppWindow : public content::WebContentsDelegate, |
public content::WebContentsObserver, |
public web_modal::WebContentsModalDialogManagerDelegate, |
public IconImage::Observer, |
- public ExtensionRegistryObserver { |
+ public ExtensionRegistryObserver, |
+ public native_app_window::NativeAppWindowDelegate { |
public: |
- enum WindowType { |
- WINDOW_TYPE_DEFAULT = 1 << 0, // Default app window. |
- WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). |
- WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate |
- // with v1 apps. |
- }; |
- |
- enum Frame { |
- FRAME_CHROME, // Chrome-style window frame. |
- FRAME_NONE, // Frameless window. |
- }; |
- |
- enum FullscreenType { |
- // Not fullscreen. |
- FULLSCREEN_TYPE_NONE = 0, |
- |
- // Fullscreen entered by the app.window api. |
- FULLSCREEN_TYPE_WINDOW_API = 1 << 0, |
- |
- // Fullscreen entered by HTML requestFullscreen(). |
- FULLSCREEN_TYPE_HTML_API = 1 << 1, |
- |
- // Fullscreen entered by the OS. ChromeOS uses this type of fullscreen to |
- // enter immersive fullscreen when the user hits the <F4> key. |
- FULLSCREEN_TYPE_OS = 1 << 2, |
- |
- // Fullscreen mode that could not be exited by the user. ChromeOS uses |
- // this type of fullscreen to run an app in kiosk mode. |
- FULLSCREEN_TYPE_FORCED = 1 << 3, |
- }; |
- |
- struct BoundsSpecification { |
- // INT_MIN represents an unspecified position component. |
- static const int kUnspecifiedPosition; |
- |
- BoundsSpecification(); |
- ~BoundsSpecification(); |
- |
- // INT_MIN designates 'unspecified' for the position components, and 0 |
- // designates 'unspecified' for the size components. When unspecified, |
- // they should be replaced with a default value. |
- gfx::Rect bounds; |
- |
- gfx::Size minimum_size; |
- gfx::Size maximum_size; |
- |
- // Reset the bounds fields to their 'unspecified' values. The minimum and |
- // maximum size constraints remain unchanged. |
- void ResetBounds(); |
- }; |
- |
- struct CreateParams { |
- CreateParams(); |
- ~CreateParams(); |
- |
- WindowType window_type; |
- Frame frame; |
- |
- bool has_frame_color; |
- SkColor active_frame_color; |
- SkColor inactive_frame_color; |
- bool alpha_enabled; |
- bool is_ime_window; |
- |
- // The initial content/inner bounds specification (excluding any window |
- // decorations). |
- BoundsSpecification content_spec; |
- |
- // The initial window/outer bounds specification (including window |
- // decorations). |
- BoundsSpecification window_spec; |
- |
- std::string window_key; |
- |
- // The process ID of the process that requested the create. |
- int32 creator_process_id; |
- |
- // Initial state of the window. |
- ui::WindowShowState state; |
- |
- // If true, don't show the window after creation. |
- bool hidden; |
- |
- // If true, the window will be resizable by the user. Defaults to true. |
- bool resizable; |
- |
- // If true, the window will be focused on creation. Defaults to true. |
- bool focused; |
- |
- // If true, the window will stay on top of other windows that are not |
- // configured to be always on top. Defaults to false. |
- bool always_on_top; |
- |
- // If true, the window will be visible on all workspaces. Defaults to false. |
- bool visible_on_all_workspaces; |
- |
- // The API enables developers to specify content or window bounds. This |
- // function combines them into a single, constrained window size. |
- gfx::Rect GetInitialWindowBounds(const gfx::Insets& frame_insets) const; |
- |
- // The API enables developers to specify content or window size constraints. |
- // These functions combine them so that we can work with one set of |
- // constraints. |
- gfx::Size GetContentMinimumSize(const gfx::Insets& frame_insets) const; |
- gfx::Size GetContentMaximumSize(const gfx::Insets& frame_insets) const; |
- gfx::Size GetWindowMinimumSize(const gfx::Insets& frame_insets) const; |
- gfx::Size GetWindowMaximumSize(const gfx::Insets& frame_insets) const; |
- }; |
- |
- // Convert draggable regions in raw format to SkRegion format. Caller is |
- // responsible for deleting the returned SkRegion instance. |
- static SkRegion* RawDraggableRegionsToSkRegion( |
- const std::vector<DraggableRegion>& regions); |
+ // TODO(tapted): Delete these forwarding declarations. |
+ typedef native_app_window::AppWindowCreateParams CreateParams; |
+ typedef native_app_window::BoundsSpecification BoundsSpecification; |
// The constructor and Init methods are public for constructing a AppWindow |
// with a non-standard render interface (e.g. v1 apps using Ash Panels). |
@@ -220,10 +116,10 @@ class AppWindow : public content::WebContentsDelegate, |
const SessionID& session_id() const { return session_id_; } |
const std::string& extension_id() const { return extension_id_; } |
content::WebContents* web_contents() const; |
- WindowType window_type() const { return window_type_; } |
+ native_app_window::WindowType window_type() const { return window_type_; } |
bool window_type_is_panel() const { |
- return (window_type_ == WINDOW_TYPE_PANEL || |
- window_type_ == WINDOW_TYPE_V1_PANEL); |
+ return (window_type_ == native_app_window::WINDOW_TYPE_PANEL || |
+ window_type_ == native_app_window::WINDOW_TYPE_V1_PANEL); |
} |
content::BrowserContext* browser_context() const { return browser_context_; } |
const gfx::Image& app_icon() const { return app_icon_; } |
@@ -233,27 +129,12 @@ class AppWindow : public content::WebContentsDelegate, |
bool is_hidden() const { return is_hidden_; } |
const Extension* GetExtension() const; |
- NativeAppWindow* GetBaseWindow(); |
+ native_app_window::NativeAppWindow* GetBaseWindow(); |
gfx::NativeWindow GetNativeWindow(); |
// Returns the bounds that should be reported to the renderer. |
gfx::Rect GetClientBounds() const; |
- // NativeAppWindows should call this to determine what the window's title |
- // is on startup and from within UpdateWindowTitle(). |
- base::string16 GetTitle() const; |
- |
- // Call to notify ShellRegistry and delete the window. Subclasses should |
- // invoke this method instead of using "delete this". |
- void OnNativeClose(); |
- |
- // Should be called by native implementations when the window size, position, |
- // or minimized/maximized state has changed. |
- void OnNativeWindowChanged(); |
- |
- // Should be called by native implementations when the window is activated. |
- void OnNativeWindowActivated(); |
- |
// Specifies a url for the launcher icon. |
void SetAppIconUrl(const GURL& icon_url); |
@@ -267,7 +148,8 @@ class AppWindow : public content::WebContentsDelegate, |
void UpdateShape(scoped_ptr<SkRegion> region); |
// Called from the render interface to modify the draggable regions. |
- void UpdateDraggableRegions(const std::vector<DraggableRegion>& regions); |
+ void UpdateDraggableRegions( |
+ const std::vector<native_app_window::DraggableRegion>& regions); |
// Updates the app image to |image|. Called internally from the image loader |
// callback. Also called externally for v1 apps using Ash Panels. |
@@ -278,7 +160,7 @@ class AppWindow : public content::WebContentsDelegate, |
// not exit fullscreen mode because a window may have a different type of |
// fullscreen enabled). If |type| is not FORCED, checks that the extension has |
// the required permission. |
- void SetFullscreen(FullscreenType type, bool enable); |
+ void SetFullscreen(native_app_window::FullscreenType type, bool enable); |
// Returns true if the app window is in a fullscreen state. |
bool IsFullscreen() const; |
@@ -351,6 +233,17 @@ class AppWindow : public content::WebContentsDelegate, |
app_window_contents_ = contents.Pass(); |
} |
+ // native_app_window::NativeAppWindowDelegate implementation. |
+ virtual content::WebContents* GetWebContents() OVERRIDE; |
+ virtual content::BrowserContext* GetBrowserContext() OVERRIDE; |
+ virtual void OnNativeClose() OVERRIDE; |
+ virtual void OnNativeWindowChanged() OVERRIDE; |
+ virtual void OnNativeWindowActivated() OVERRIDE; |
+ virtual bool RequestedAlphaEnabled() const OVERRIDE; |
+ virtual base::string16 GetTitle() const OVERRIDE; |
+ virtual native_app_window::WindowType GetWindowType() const OVERRIDE; |
+ virtual bool WindowTypeIsPanel() const OVERRIDE; |
+ |
protected: |
virtual ~AppWindow(); |
@@ -492,7 +385,7 @@ class AppWindow : public content::WebContentsDelegate, |
std::string window_key_; |
const SessionID session_id_; |
- WindowType window_type_; |
+ native_app_window::WindowType window_type_; |
// Icon shown in the task bar. |
gfx::Image app_icon_; |
@@ -513,7 +406,7 @@ class AppWindow : public content::WebContentsDelegate, |
// An object to load the badge as an extension resource. |
scoped_ptr<IconImage> badge_icon_image_; |
- scoped_ptr<NativeAppWindow> native_app_window_; |
+ scoped_ptr<native_app_window::NativeAppWindow> native_app_window_; |
scoped_ptr<AppWindowContents> app_window_contents_; |
scoped_ptr<AppDelegate> app_delegate_; |
scoped_ptr<AppWebContentsHelper> helper_; |