OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 APPS_SHELL_WINDOW_H_ | 5 #ifndef APPS_APP_WINDOW_H_ |
6 #define APPS_SHELL_WINDOW_H_ | 6 #define APPS_APP_WINDOW_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/extensions/extension_icon_image.h" | 10 #include "chrome/browser/extensions/extension_icon_image.h" |
11 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 11 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
12 #include "chrome/browser/sessions/session_id.h" | 12 #include "chrome/browser/sessions/session_id.h" |
13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 13 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 24 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 namespace ui { | 43 namespace ui { |
44 class BaseWindow; | 44 class BaseWindow; |
45 } | 45 } |
46 | 46 |
47 namespace apps { | 47 namespace apps { |
48 | 48 |
49 class NativeAppWindow; | 49 class NativeAppWindow; |
50 | 50 |
51 // Manages the web contents for Shell Windows. The implementation for this | 51 // Manages the web contents for app windows. The implementation for this |
52 // class should create and maintain the WebContents for the window, and handle | 52 // class should create and maintain the WebContents for the window, and handle |
53 // any message passing between the web contents and the extension system or | 53 // any message passing between the web contents and the extension system or |
54 // native window. | 54 // native window. |
55 class ShellWindowContents { | 55 class AppWindowContents { |
56 public: | 56 public: |
57 ShellWindowContents() {} | 57 AppWindowContents() {} |
58 virtual ~ShellWindowContents() {} | 58 virtual ~AppWindowContents() {} |
59 | 59 |
60 // Called to initialize the WebContents, before the app window is created. | 60 // Called to initialize the WebContents, before the app window is created. |
61 virtual void Initialize(content::BrowserContext* context, | 61 virtual void Initialize(content::BrowserContext* context, |
62 const GURL& url) = 0; | 62 const GURL& url) = 0; |
63 | 63 |
64 // Called to load the contents, after the app window is created. | 64 // Called to load the contents, after the app window is created. |
65 virtual void LoadContents(int32 creator_process_id) = 0; | 65 virtual void LoadContents(int32 creator_process_id) = 0; |
66 | 66 |
67 // Called when the native window changes. | 67 // Called when the native window changes. |
68 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; | 68 virtual void NativeWindowChanged(NativeAppWindow* native_app_window) = 0; |
69 | 69 |
70 // Called when the native window closes. | 70 // Called when the native window closes. |
71 virtual void NativeWindowClosed() = 0; | 71 virtual void NativeWindowClosed() = 0; |
72 | 72 |
73 virtual content::WebContents* GetWebContents() const = 0; | 73 virtual content::WebContents* GetWebContents() const = 0; |
74 | 74 |
75 private: | 75 private: |
76 DISALLOW_COPY_AND_ASSIGN(ShellWindowContents); | 76 DISALLOW_COPY_AND_ASSIGN(AppWindowContents); |
77 }; | 77 }; |
78 | 78 |
79 // ShellWindow is the type of window used by platform apps. Shell windows | 79 // AppWindow is the type of window used by platform apps. App windows |
80 // have a WebContents but none of the chrome of normal browser windows. | 80 // have a WebContents but none of the chrome of normal browser windows. |
81 class ShellWindow : public content::NotificationObserver, | 81 class AppWindow : public content::NotificationObserver, |
82 public content::WebContentsDelegate, | 82 public content::WebContentsDelegate, |
83 public content::WebContentsObserver, | 83 public content::WebContentsObserver, |
84 public web_modal::WebContentsModalDialogManagerDelegate, | 84 public web_modal::WebContentsModalDialogManagerDelegate, |
85 public extensions::ExtensionKeybindingRegistry::Delegate, | 85 public extensions::ExtensionKeybindingRegistry::Delegate, |
86 public extensions::IconImage::Observer { | 86 public extensions::IconImage::Observer { |
87 public: | 87 public: |
88 enum WindowType { | 88 enum WindowType { |
89 WINDOW_TYPE_DEFAULT = 1 << 0, // Default shell window. | 89 WINDOW_TYPE_DEFAULT = 1 << 0, // Default app window. |
90 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). | 90 WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). |
91 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate | 91 WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate |
92 // with v1 apps. | 92 // with v1 apps. |
93 }; | 93 }; |
94 | 94 |
95 enum Frame { | 95 enum Frame { |
96 FRAME_CHROME, // Chrome-style window frame. | 96 FRAME_CHROME, // Chrome-style window frame. |
97 FRAME_NONE, // Frameless window. | 97 FRAME_NONE, // Frameless window. |
98 }; | 98 }; |
99 | 99 |
100 enum FullscreenType { | 100 enum FullscreenType { |
101 // Not fullscreen. | 101 // Not fullscreen. |
102 FULLSCREEN_TYPE_NONE = 0, | 102 FULLSCREEN_TYPE_NONE = 0, |
103 | 103 |
104 // Fullscreen entered by the app.window api. | 104 // Fullscreen entered by the app.window api. |
105 FULLSCREEN_TYPE_WINDOW_API = 1 << 0, | 105 FULLSCREEN_TYPE_WINDOW_API = 1 << 0, |
106 | 106 |
107 // Fullscreen entered by HTML requestFullscreen(). | 107 // Fullscreen entered by HTML requestFullscreen(). |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool always_on_top; | 190 bool always_on_top; |
191 }; | 191 }; |
192 | 192 |
193 class Delegate { | 193 class Delegate { |
194 public: | 194 public: |
195 virtual ~Delegate(); | 195 virtual ~Delegate(); |
196 | 196 |
197 // General initialization. | 197 // General initialization. |
198 virtual void InitWebContents(content::WebContents* web_contents) = 0; | 198 virtual void InitWebContents(content::WebContents* web_contents) = 0; |
199 virtual NativeAppWindow* CreateNativeAppWindow( | 199 virtual NativeAppWindow* CreateNativeAppWindow( |
200 ShellWindow* window, | 200 AppWindow* window, |
201 const CreateParams& params) = 0; | 201 const CreateParams& params) = 0; |
202 | 202 |
203 // Link handling. | 203 // Link handling. |
204 virtual content::WebContents* OpenURLFromTab( | 204 virtual content::WebContents* OpenURLFromTab( |
205 content::BrowserContext* context, | 205 content::BrowserContext* context, |
206 content::WebContents* source, | 206 content::WebContents* source, |
207 const content::OpenURLParams& params) = 0; | 207 const content::OpenURLParams& params) = 0; |
208 virtual void AddNewContents(content::BrowserContext* context, | 208 virtual void AddNewContents(content::BrowserContext* context, |
209 content::WebContents* new_contents, | 209 content::WebContents* new_contents, |
210 WindowOpenDisposition disposition, | 210 WindowOpenDisposition disposition, |
211 const gfx::Rect& initial_pos, | 211 const gfx::Rect& initial_pos, |
212 bool user_gesture, | 212 bool user_gesture, |
213 bool* was_blocked) = 0; | 213 bool* was_blocked) = 0; |
214 | 214 |
215 // Feature support. | 215 // Feature support. |
216 virtual content::ColorChooser* ShowColorChooser( | 216 virtual content::ColorChooser* ShowColorChooser( |
217 content::WebContents* web_contents, | 217 content::WebContents* web_contents, |
218 SkColor initial_color) = 0; | 218 SkColor initial_color) = 0; |
219 virtual void RunFileChooser(content::WebContents* tab, | 219 virtual void RunFileChooser(content::WebContents* tab, |
220 const content::FileChooserParams& params) = 0; | 220 const content::FileChooserParams& params) = 0; |
221 virtual void RequestMediaAccessPermission( | 221 virtual void RequestMediaAccessPermission( |
222 content::WebContents* web_contents, | 222 content::WebContents* web_contents, |
223 const content::MediaStreamRequest& request, | 223 const content::MediaStreamRequest& request, |
224 const content::MediaResponseCallback& callback, | 224 const content::MediaResponseCallback& callback, |
225 const extensions::Extension* extension) = 0; | 225 const extensions::Extension* extension) = 0; |
226 virtual int PreferredIconSize() = 0; | 226 virtual int PreferredIconSize() = 0; |
227 | 227 |
228 // Web contents modal dialog support. | 228 // Web contents modal dialog support. |
229 virtual void SetWebContentsBlocked(content::WebContents* web_contents, | 229 virtual void SetWebContentsBlocked(content::WebContents* web_contents, |
230 bool blocked) = 0; | 230 bool blocked) = 0; |
231 virtual bool IsWebContentsVisible(content::WebContents* web_contents) = 0; | 231 virtual bool IsWebContentsVisible(content::WebContents* web_contents) = 0; |
232 }; | 232 }; |
233 | 233 |
234 // Convert draggable regions in raw format to SkRegion format. Caller is | 234 // Convert draggable regions in raw format to SkRegion format. Caller is |
235 // responsible for deleting the returned SkRegion instance. | 235 // responsible for deleting the returned SkRegion instance. |
236 static SkRegion* RawDraggableRegionsToSkRegion( | 236 static SkRegion* RawDraggableRegionsToSkRegion( |
237 const std::vector<extensions::DraggableRegion>& regions); | 237 const std::vector<extensions::DraggableRegion>& regions); |
238 | 238 |
239 // The constructor and Init methods are public for constructing a ShellWindow | 239 // The constructor and Init methods are public for constructing a AppWindow |
240 // with a non-standard render interface (e.g. v1 apps using Ash Panels). | 240 // with a non-standard render interface (e.g. v1 apps using Ash Panels). |
241 // Normally ShellWindow::Create should be used. | 241 // Normally AppWindow::Create should be used. |
242 // The constructed shell window takes ownership of |delegate|. | 242 // The constructed app window takes ownership of |delegate|. |
243 ShellWindow(content::BrowserContext* context, | 243 AppWindow(content::BrowserContext* context, |
244 Delegate* delegate, | 244 Delegate* delegate, |
245 const extensions::Extension* extension); | 245 const extensions::Extension* extension); |
246 | 246 |
247 // Initializes the render interface, web contents, and native window. | 247 // Initializes the render interface, web contents, and native window. |
248 // |shell_window_contents| will become owned by ShellWindow. | 248 // |app_window_contents| will become owned by AppWindow. |
249 void Init(const GURL& url, | 249 void Init(const GURL& url, |
250 ShellWindowContents* shell_window_contents, | 250 AppWindowContents* app_window_contents, |
251 const CreateParams& params); | 251 const CreateParams& params); |
252 | 252 |
253 | |
254 const std::string& window_key() const { return window_key_; } | 253 const std::string& window_key() const { return window_key_; } |
255 const SessionID& session_id() const { return session_id_; } | 254 const SessionID& session_id() const { return session_id_; } |
256 const extensions::Extension* extension() const { return extension_; } | 255 const extensions::Extension* extension() const { return extension_; } |
257 const std::string& extension_id() const { return extension_id_; } | 256 const std::string& extension_id() const { return extension_id_; } |
258 content::WebContents* web_contents() const; | 257 content::WebContents* web_contents() const; |
259 WindowType window_type() const { return window_type_; } | 258 WindowType window_type() const { return window_type_; } |
260 bool window_type_is_panel() const { | 259 bool window_type_is_panel() const { |
261 return (window_type_ == WINDOW_TYPE_PANEL || | 260 return (window_type_ == WINDOW_TYPE_PANEL || |
262 window_type_ == WINDOW_TYPE_V1_PANEL); | 261 window_type_ == WINDOW_TYPE_V1_PANEL); |
263 } | 262 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 void OSFullscreen(); | 318 void OSFullscreen(); |
320 | 319 |
321 // Transitions to forced fullscreen. See FULLSCREEN_TYPE_FORCED for more | 320 // Transitions to forced fullscreen. See FULLSCREEN_TYPE_FORCED for more |
322 // details. | 321 // details. |
323 void ForcedFullscreen(); | 322 void ForcedFullscreen(); |
324 | 323 |
325 // Set the minimum and maximum size that this window is allowed to be. | 324 // Set the minimum and maximum size that this window is allowed to be. |
326 void SetMinimumSize(const gfx::Size& min_size); | 325 void SetMinimumSize(const gfx::Size& min_size); |
327 void SetMaximumSize(const gfx::Size& max_size); | 326 void SetMaximumSize(const gfx::Size& max_size); |
328 | 327 |
329 enum ShowType { | 328 enum ShowType { SHOW_ACTIVE, SHOW_INACTIVE }; |
330 SHOW_ACTIVE, | |
331 SHOW_INACTIVE | |
332 }; | |
333 | 329 |
334 // Shows the window if its contents have been painted; otherwise flags the | 330 // Shows the window if its contents have been painted; otherwise flags the |
335 // window to be shown as soon as its contents are painted for the first time. | 331 // window to be shown as soon as its contents are painted for the first time. |
336 void Show(ShowType show_type); | 332 void Show(ShowType show_type); |
337 | 333 |
338 // Hides the window. If the window was previously flagged to be shown on | 334 // Hides the window. If the window was previously flagged to be shown on |
339 // first paint, it will be unflagged. | 335 // first paint, it will be unflagged. |
340 void Hide(); | 336 void Hide(); |
341 | 337 |
342 ShellWindowContents* shell_window_contents_for_test() { | 338 AppWindowContents* app_window_contents_for_test() { |
343 return shell_window_contents_.get(); | 339 return app_window_contents_.get(); |
344 } | 340 } |
345 | 341 |
346 // Get the size constraints. | 342 // Get the size constraints. |
347 const SizeConstraints& size_constraints() const { | 343 const SizeConstraints& size_constraints() const { return size_constraints_; } |
348 return size_constraints_; | |
349 } | |
350 | 344 |
351 // Set whether the window should stay above other windows which are not | 345 // Set whether the window should stay above other windows which are not |
352 // configured to be always-on-top. | 346 // configured to be always-on-top. |
353 void SetAlwaysOnTop(bool always_on_top); | 347 void SetAlwaysOnTop(bool always_on_top); |
354 | 348 |
355 // Whether the always-on-top property has been set by the chrome.app.window | 349 // Whether the always-on-top property has been set by the chrome.app.window |
356 // API. Note that the actual value of this property in the native app window | 350 // API. Note that the actual value of this property in the native app window |
357 // may be false if the bit is silently switched off for security reasons. | 351 // may be false if the bit is silently switched off for security reasons. |
358 bool IsAlwaysOnTop() const; | 352 bool IsAlwaysOnTop() const; |
359 | 353 |
360 // Retrieve the current state of the app window as a dictionary, to pass to | 354 // Retrieve the current state of the app window as a dictionary, to pass to |
361 // the renderer. | 355 // the renderer. |
362 void GetSerializedState(base::DictionaryValue* properties) const; | 356 void GetSerializedState(base::DictionaryValue* properties) const; |
363 | 357 |
364 protected: | 358 protected: |
365 virtual ~ShellWindow(); | 359 virtual ~AppWindow(); |
366 | 360 |
367 private: | 361 private: |
368 // PlatformAppBrowserTest needs access to web_contents() | 362 // PlatformAppBrowserTest needs access to web_contents() |
369 friend class extensions::PlatformAppBrowserTest; | 363 friend class extensions::PlatformAppBrowserTest; |
370 | 364 |
371 // content::WebContentsDelegate implementation. | 365 // content::WebContentsDelegate implementation. |
372 virtual void CloseContents(content::WebContents* contents) OVERRIDE; | 366 virtual void CloseContents(content::WebContents* contents) OVERRIDE; |
373 virtual bool ShouldSuppressDialogs() OVERRIDE; | 367 virtual bool ShouldSuppressDialogs() OVERRIDE; |
374 virtual content::ColorChooser* OpenColorChooser( | 368 virtual content::ColorChooser* OpenColorChooser( |
375 content::WebContents* web_contents, | 369 content::WebContents* web_contents, |
376 SkColor color, | 370 SkColor color, |
377 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE; | 371 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE; |
378 virtual void RunFileChooser( | 372 virtual void RunFileChooser(content::WebContents* tab, |
379 content::WebContents* tab, | 373 const content::FileChooserParams& params) |
380 const content::FileChooserParams& params) OVERRIDE; | 374 OVERRIDE; |
381 virtual bool IsPopupOrPanel( | 375 virtual bool IsPopupOrPanel(const content::WebContents* source) |
382 const content::WebContents* source) const OVERRIDE; | 376 const OVERRIDE; |
383 virtual void MoveContents( | 377 virtual void MoveContents(content::WebContents* source, |
384 content::WebContents* source, const gfx::Rect& pos) OVERRIDE; | 378 const gfx::Rect& pos) OVERRIDE; |
385 virtual void NavigationStateChanged(const content::WebContents* source, | 379 virtual void NavigationStateChanged(const content::WebContents* source, |
386 unsigned changed_flags) OVERRIDE; | 380 unsigned changed_flags) OVERRIDE; |
387 virtual void ToggleFullscreenModeForTab(content::WebContents* source, | 381 virtual void ToggleFullscreenModeForTab(content::WebContents* source, |
388 bool enter_fullscreen) OVERRIDE; | 382 bool enter_fullscreen) OVERRIDE; |
389 virtual bool IsFullscreenForTabOrPending( | 383 virtual bool IsFullscreenForTabOrPending(const content::WebContents* source) |
390 const content::WebContents* source) const OVERRIDE; | 384 const OVERRIDE; |
391 virtual void RequestMediaAccessPermission( | 385 virtual void RequestMediaAccessPermission( |
392 content::WebContents* web_contents, | 386 content::WebContents* web_contents, |
393 const content::MediaStreamRequest& request, | 387 const content::MediaStreamRequest& request, |
394 const content::MediaResponseCallback& callback) OVERRIDE; | 388 const content::MediaResponseCallback& callback) OVERRIDE; |
395 virtual content::WebContents* OpenURLFromTab( | 389 virtual content::WebContents* OpenURLFromTab( |
396 content::WebContents* source, | 390 content::WebContents* source, |
397 const content::OpenURLParams& params) OVERRIDE; | 391 const content::OpenURLParams& params) OVERRIDE; |
398 virtual void AddNewContents(content::WebContents* source, | 392 virtual void AddNewContents(content::WebContents* source, |
399 content::WebContents* new_contents, | 393 content::WebContents* new_contents, |
400 WindowOpenDisposition disposition, | 394 WindowOpenDisposition disposition, |
401 const gfx::Rect& initial_pos, | 395 const gfx::Rect& initial_pos, |
402 bool user_gesture, | 396 bool user_gesture, |
403 bool* was_blocked) OVERRIDE; | 397 bool* was_blocked) OVERRIDE; |
404 virtual bool PreHandleKeyboardEvent( | 398 virtual bool PreHandleKeyboardEvent( |
405 content::WebContents* source, | 399 content::WebContents* source, |
406 const content::NativeWebKeyboardEvent& event, | 400 const content::NativeWebKeyboardEvent& event, |
407 bool* is_keyboard_shortcut) OVERRIDE; | 401 bool* is_keyboard_shortcut) OVERRIDE; |
408 virtual void HandleKeyboardEvent( | 402 virtual void HandleKeyboardEvent(content::WebContents* source, |
409 content::WebContents* source, | 403 const content::NativeWebKeyboardEvent& event) |
410 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 404 OVERRIDE; |
411 virtual void RequestToLockMouse(content::WebContents* web_contents, | 405 virtual void RequestToLockMouse(content::WebContents* web_contents, |
412 bool user_gesture, | 406 bool user_gesture, |
413 bool last_unlocked_by_target) OVERRIDE; | 407 bool last_unlocked_by_target) OVERRIDE; |
414 virtual bool PreHandleGestureEvent( | 408 virtual bool PreHandleGestureEvent(content::WebContents* source, |
415 content::WebContents* source, | 409 const blink::WebGestureEvent& event) |
416 const blink::WebGestureEvent& event) OVERRIDE; | 410 OVERRIDE; |
417 | 411 |
418 // content::WebContentsObserver implementation. | 412 // content::WebContentsObserver implementation. |
419 virtual void DidFirstVisuallyNonEmptyPaint(int32 page_id) OVERRIDE; | 413 virtual void DidFirstVisuallyNonEmptyPaint(int32 page_id) OVERRIDE; |
420 | 414 |
421 // content::NotificationObserver implementation. | 415 // content::NotificationObserver implementation. |
422 virtual void Observe(int type, | 416 virtual void Observe(int type, |
423 const content::NotificationSource& source, | 417 const content::NotificationSource& source, |
424 const content::NotificationDetails& details) OVERRIDE; | 418 const content::NotificationDetails& details) OVERRIDE; |
425 | 419 |
426 // web_modal::WebContentsModalDialogManagerDelegate implementation. | 420 // web_modal::WebContentsModalDialogManagerDelegate implementation. |
427 virtual void SetWebContentsBlocked(content::WebContents* web_contents, | 421 virtual void SetWebContentsBlocked(content::WebContents* web_contents, |
428 bool blocked) OVERRIDE; | 422 bool blocked) OVERRIDE; |
429 virtual bool IsWebContentsVisible( | 423 virtual bool IsWebContentsVisible(content::WebContents* web_contents) |
430 content::WebContents* web_contents) OVERRIDE; | 424 OVERRIDE; |
431 | 425 |
432 // Helper method to add a message to the renderer's DevTools console. | 426 // Helper method to add a message to the renderer's DevTools console. |
433 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, | 427 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, |
434 const std::string& message); | 428 const std::string& message); |
435 | 429 |
436 // Saves the window geometry/position/screen bounds. | 430 // Saves the window geometry/position/screen bounds. |
437 void SaveWindowPosition(); | 431 void SaveWindowPosition(); |
438 | 432 |
439 // Helper method to adjust the cached bounds so that we can make sure it can | 433 // Helper method to adjust the cached bounds so that we can make sure it can |
440 // be visible on the screen. See http://crbug.com/145752 . | 434 // be visible on the screen. See http://crbug.com/145752 . |
441 void AdjustBoundsToBeVisibleOnScreen( | 435 void AdjustBoundsToBeVisibleOnScreen(const gfx::Rect& cached_bounds, |
442 const gfx::Rect& cached_bounds, | 436 const gfx::Rect& cached_screen_bounds, |
443 const gfx::Rect& cached_screen_bounds, | 437 const gfx::Rect& current_screen_bounds, |
444 const gfx::Rect& current_screen_bounds, | 438 const gfx::Size& minimum_size, |
445 const gfx::Size& minimum_size, | 439 gfx::Rect* bounds) const; |
446 gfx::Rect* bounds) const; | |
447 | 440 |
448 // Loads the appropriate default or cached window bounds and constrains them | 441 // Loads the appropriate default or cached window bounds and constrains them |
449 // based on screen size and minimum/maximum size. Returns a new CreateParams | 442 // based on screen size and minimum/maximum size. Returns a new CreateParams |
450 // that should be used to create the window. | 443 // that should be used to create the window. |
451 CreateParams LoadDefaultsAndConstrain(CreateParams params) const; | 444 CreateParams LoadDefaultsAndConstrain(CreateParams params) const; |
452 | 445 |
453 // Load the app's image, firing a load state change when loaded. | 446 // Load the app's image, firing a load state change when loaded. |
454 void UpdateExtensionAppIcon(); | 447 void UpdateExtensionAppIcon(); |
455 | 448 |
456 // Called when size_constraints is changed. | 449 // Called when size_constraints is changed. |
457 void OnSizeConstraintsChanged(); | 450 void OnSizeConstraintsChanged(); |
458 | 451 |
459 // Set the fullscreen state in the native app window. | 452 // Set the fullscreen state in the native app window. |
460 void SetNativeWindowFullscreen(); | 453 void SetNativeWindowFullscreen(); |
461 | 454 |
462 // Returns true if there is any overlap between the window and the taskbar | 455 // Returns true if there is any overlap between the window and the taskbar |
463 // (Windows only). | 456 // (Windows only). |
464 bool IntersectsWithTaskbar() const; | 457 bool IntersectsWithTaskbar() const; |
465 | 458 |
466 // Update the always-on-top bit in the native app window. | 459 // Update the always-on-top bit in the native app window. |
467 void UpdateNativeAlwaysOnTop(); | 460 void UpdateNativeAlwaysOnTop(); |
468 | 461 |
469 // extensions::ExtensionKeybindingRegistry::Delegate implementation. | 462 // extensions::ExtensionKeybindingRegistry::Delegate implementation. |
470 virtual extensions::ActiveTabPermissionGranter* | 463 virtual extensions::ActiveTabPermissionGranter* |
471 GetActiveTabPermissionGranter() OVERRIDE; | 464 GetActiveTabPermissionGranter() OVERRIDE; |
472 | 465 |
473 // web_modal::WebContentsModalDialogManagerDelegate implementation. | 466 // web_modal::WebContentsModalDialogManagerDelegate implementation. |
474 virtual web_modal::WebContentsModalDialogHost* | 467 virtual web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() |
475 GetWebContentsModalDialogHost() OVERRIDE; | 468 OVERRIDE; |
476 | 469 |
477 // Updates the badge to |image|. Called internally from the image loader | 470 // Updates the badge to |image|. Called internally from the image loader |
478 // callback. | 471 // callback. |
479 void UpdateBadgeIcon(const gfx::Image& image); | 472 void UpdateBadgeIcon(const gfx::Image& image); |
480 | 473 |
481 // Callback from web_contents()->DownloadFavicon. | 474 // Callback from web_contents()->DownloadFavicon. |
482 void DidDownloadFavicon(int id, | 475 void DidDownloadFavicon(int id, |
483 int http_status_code, | 476 int http_status_code, |
484 const GURL& image_url, | 477 const GURL& image_url, |
485 const std::vector<SkBitmap>& bitmaps, | 478 const std::vector<SkBitmap>& bitmaps, |
486 const std::vector<gfx::Size>& original_bitmap_sizes); | 479 const std::vector<gfx::Size>& original_bitmap_sizes); |
487 | 480 |
488 // extensions::IconImage::Observer implementation. | 481 // extensions::IconImage::Observer implementation. |
489 virtual void OnExtensionIconImageChanged( | 482 virtual void OnExtensionIconImageChanged(extensions::IconImage* image) |
490 extensions::IconImage* image) OVERRIDE; | 483 OVERRIDE; |
491 | 484 |
492 // The browser context with which this window is associated. ShellWindow does | 485 // The browser context with which this window is associated. AppWindow does |
493 // not own this object. | 486 // not own this object. |
494 content::BrowserContext* browser_context_; | 487 content::BrowserContext* browser_context_; |
495 | 488 |
496 // weak pointer - owned by ExtensionService. | 489 // weak pointer - owned by ExtensionService. |
497 const extensions::Extension* extension_; | 490 const extensions::Extension* extension_; |
498 const std::string extension_id_; | 491 const std::string extension_id_; |
499 | 492 |
500 // Identifier that is used when saving and restoring geometry for this | 493 // Identifier that is used when saving and restoring geometry for this |
501 // window. | 494 // window. |
502 std::string window_key_; | 495 std::string window_key_; |
(...skipping 15 matching lines...) Expand all Loading... |
518 // Badge for icon shown in the task bar. | 511 // Badge for icon shown in the task bar. |
519 gfx::Image badge_icon_; | 512 gfx::Image badge_icon_; |
520 | 513 |
521 // URL to be used for setting the badge on the app icon. | 514 // URL to be used for setting the badge on the app icon. |
522 GURL badge_icon_url_; | 515 GURL badge_icon_url_; |
523 | 516 |
524 // An object to load the badge as an extension resource. | 517 // An object to load the badge as an extension resource. |
525 scoped_ptr<extensions::IconImage> badge_icon_image_; | 518 scoped_ptr<extensions::IconImage> badge_icon_image_; |
526 | 519 |
527 scoped_ptr<NativeAppWindow> native_app_window_; | 520 scoped_ptr<NativeAppWindow> native_app_window_; |
528 scoped_ptr<ShellWindowContents> shell_window_contents_; | 521 scoped_ptr<AppWindowContents> app_window_contents_; |
529 scoped_ptr<Delegate> delegate_; | 522 scoped_ptr<Delegate> delegate_; |
530 | 523 |
531 base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; | 524 base::WeakPtrFactory<AppWindow> image_loader_ptr_factory_; |
532 | 525 |
533 // Bit field of FullscreenType. | 526 // Bit field of FullscreenType. |
534 int fullscreen_types_; | 527 int fullscreen_types_; |
535 | 528 |
536 // Size constraints on the window. | 529 // Size constraints on the window. |
537 SizeConstraints size_constraints_; | 530 SizeConstraints size_constraints_; |
538 | 531 |
539 // Show has been called, so the window should be shown once the first visually | 532 // Show has been called, so the window should be shown once the first visually |
540 // non-empty paint occurs. | 533 // non-empty paint occurs. |
541 bool show_on_first_paint_; | 534 bool show_on_first_paint_; |
542 | 535 |
543 // The first visually non-empty paint has completed. | 536 // The first visually non-empty paint has completed. |
544 bool first_paint_complete_; | 537 bool first_paint_complete_; |
545 | 538 |
546 // Whether the delayed Show() call was for an active or inactive window. | 539 // Whether the delayed Show() call was for an active or inactive window. |
547 ShowType delayed_show_type_; | 540 ShowType delayed_show_type_; |
548 | 541 |
549 // Cache the desired value of the always-on-top property. When windows enter | 542 // Cache the desired value of the always-on-top property. When windows enter |
550 // fullscreen or overlap the Windows taskbar, this property will be | 543 // fullscreen or overlap the Windows taskbar, this property will be |
551 // automatically and silently switched off for security reasons. It is | 544 // automatically and silently switched off for security reasons. It is |
552 // reinstated when the window exits fullscreen and moves away from the | 545 // reinstated when the window exits fullscreen and moves away from the |
553 // taskbar. | 546 // taskbar. |
554 bool cached_always_on_top_; | 547 bool cached_always_on_top_; |
555 | 548 |
556 DISALLOW_COPY_AND_ASSIGN(ShellWindow); | 549 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
557 }; | 550 }; |
558 | 551 |
559 } // namespace apps | 552 } // namespace apps |
560 | 553 |
561 #endif // APPS_SHELL_WINDOW_H_ | 554 #endif // APPS_APP_WINDOW_H_ |
OLD | NEW |