| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 10 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 public content::WebContentsObserver, | 40 public content::WebContentsObserver, |
| 41 public ExtensionFunctionDispatcher::Delegate { | 41 public ExtensionFunctionDispatcher::Delegate { |
| 42 public: | 42 public: |
| 43 struct CreateParams { | 43 struct CreateParams { |
| 44 enum Frame { | 44 enum Frame { |
| 45 FRAME_CHROME, // Chrome-style window frame. | 45 FRAME_CHROME, // Chrome-style window frame. |
| 46 FRAME_NONE, // Frameless window. | 46 FRAME_NONE, // Frameless window. |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 CreateParams(); | 49 CreateParams(); |
| 50 ~CreateParams(); |
| 50 | 51 |
| 51 Frame frame; | 52 Frame frame; |
| 52 // Specify the initial bounds of the window. If empty, the window will be a | 53 // Specify the initial bounds of the window. If empty, the window will be a |
| 53 // default size. | 54 // default size. |
| 54 gfx::Rect bounds; | 55 gfx::Rect bounds; |
| 56 // Specify if bounds should be restored from a previous time. |
| 57 bool restore_position; |
| 58 bool restore_size; |
| 59 |
| 55 gfx::Size minimum_size; | 60 gfx::Size minimum_size; |
| 56 gfx::Size maximum_size; | 61 gfx::Size maximum_size; |
| 62 |
| 63 std::string window_key; |
| 57 }; | 64 }; |
| 58 | 65 |
| 59 static ShellWindow* Create(Profile* profile, | 66 static ShellWindow* Create(Profile* profile, |
| 60 const extensions::Extension* extension, | 67 const extensions::Extension* extension, |
| 61 const GURL& url, | 68 const GURL& url, |
| 62 const CreateParams& params); | 69 const CreateParams& params); |
| 63 | 70 |
| 64 const SessionID& session_id() const { return session_id_; } | 71 const SessionID& session_id() const { return session_id_; } |
| 65 const extensions::Extension* extension() const { return extension_; } | 72 const extensions::Extension* extension() const { return extension_; } |
| 66 TabContents* tab_contents() const { return contents_.get(); } | 73 TabContents* tab_contents() const { return contents_.get(); } |
| 67 content::WebContents* web_contents() const { return web_contents_; } | 74 content::WebContents* web_contents() const { return web_contents_; } |
| 68 Profile* profile() const { return profile_; } | 75 Profile* profile() const { return profile_; } |
| 69 | 76 |
| 70 BaseWindow* GetBaseWindow(); | 77 BaseWindow* GetBaseWindow(); |
| 71 gfx::NativeWindow GetNativeWindow() { | 78 gfx::NativeWindow GetNativeWindow() { |
| 72 return GetBaseWindow()->GetNativeWindow(); | 79 return GetBaseWindow()->GetNativeWindow(); |
| 73 } | 80 } |
| 74 | 81 |
| 75 // NativeShellWindows should call this to determine what the window's title | 82 // NativeShellWindows should call this to determine what the window's title |
| 76 // is on startup and from within UpdateWindowTitle(). | 83 // is on startup and from within UpdateWindowTitle(). |
| 77 virtual string16 GetTitle() const; | 84 virtual string16 GetTitle() const; |
| 78 | 85 |
| 79 // Call to notify ShellRegistry and delete the window. Subclasses should | 86 // Call to notify ShellRegistry and delete the window. Subclasses should |
| 80 // invoke this method instead of using "delete this". | 87 // invoke this method instead of using "delete this". |
| 81 void OnNativeClose(); | 88 void OnNativeClose(); |
| 82 | 89 |
| 90 // Save the window position in the prefs. |
| 91 virtual void SaveWindowPosition(); |
| 92 |
| 83 protected: | 93 protected: |
| 84 ShellWindow(Profile* profile, | 94 ShellWindow(Profile* profile, |
| 85 const extensions::Extension* extension); | 95 const extensions::Extension* extension); |
| 86 virtual ~ShellWindow(); | 96 virtual ~ShellWindow(); |
| 87 | 97 |
| 88 private: | 98 private: |
| 89 // PlatformAppBrowserTest needs access to web_contents() | 99 // PlatformAppBrowserTest needs access to web_contents() |
| 90 friend class extensions::PlatformAppBrowserTest; | 100 friend class extensions::PlatformAppBrowserTest; |
| 91 | 101 |
| 92 // Instantiates a platform-specific ShellWindow subclass (one implementation | 102 // Instantiates a platform-specific ShellWindow subclass (one implementation |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, | 157 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, |
| 148 const std::string& message); | 158 const std::string& message); |
| 149 | 159 |
| 150 virtual void UpdateDraggableRegions( | 160 virtual void UpdateDraggableRegions( |
| 151 const std::vector<extensions::DraggableRegion>& regions); | 161 const std::vector<extensions::DraggableRegion>& regions); |
| 152 | 162 |
| 153 Profile* profile_; // weak pointer - owned by ProfileManager. | 163 Profile* profile_; // weak pointer - owned by ProfileManager. |
| 154 // weak pointer - owned by ExtensionService. | 164 // weak pointer - owned by ExtensionService. |
| 155 const extensions::Extension* extension_; | 165 const extensions::Extension* extension_; |
| 156 | 166 |
| 167 // Identifier that is used when saving and restoring geometry for this |
| 168 // window. |
| 169 std::string window_key_; |
| 170 |
| 157 const SessionID session_id_; | 171 const SessionID session_id_; |
| 158 scoped_ptr<TabContents> contents_; | 172 scoped_ptr<TabContents> contents_; |
| 159 // web_contents_ is owned by contents_. | 173 // web_contents_ is owned by contents_. |
| 160 content::WebContents* web_contents_; | 174 content::WebContents* web_contents_; |
| 161 content::NotificationRegistrar registrar_; | 175 content::NotificationRegistrar registrar_; |
| 162 ExtensionFunctionDispatcher extension_function_dispatcher_; | 176 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 163 | 177 |
| 164 scoped_ptr<NativeShellWindow> native_window_; | 178 scoped_ptr<NativeShellWindow> native_window_; |
| 165 | 179 |
| 166 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 180 DISALLOW_COPY_AND_ASSIGN(ShellWindow); |
| 167 }; | 181 }; |
| 168 | 182 |
| 169 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ | 183 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ |
| OLD | NEW |