Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: chrome/browser/ui/apps/chrome_app_delegate.h

Issue 875273003: Hidden windows should not keep Chrome alive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: If window is hidden without being shown, wait for timeout before releasing keep-alive. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_APPS_CHROME_APP_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
6 #define CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_ 6 #define CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
12 #include "extensions/browser/app_window/app_delegate.h" 13 #include "extensions/browser/app_window/app_delegate.h"
13 #include "ui/base/window_open_disposition.h" 14 #include "ui/base/window_open_disposition.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 16
16 class ScopedKeepAlive; 17 class ScopedKeepAlive;
17 18
18 class ChromeAppDelegate : public extensions::AppDelegate, 19 class ChromeAppDelegate : public extensions::AppDelegate,
19 public content::NotificationObserver { 20 public content::NotificationObserver {
20 public: 21 public:
21 // Pass a ScopedKeepAlive to prevent the browser process from shutting down 22 // Pass a ScopedKeepAlive to prevent the browser process from shutting down
22 // while this object exists. 23 // while this object exists.
23 explicit ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive); 24 explicit ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive);
24 ~ChromeAppDelegate() override; 25 ~ChromeAppDelegate() override;
25 26
26 static void DisableExternalOpenForTesting(); 27 static void DisableExternalOpenForTesting();
27 28
28 private: 29 private:
30 static void RelinquishKeepAliveAfterTimeout(
31 const base::WeakPtr<ChromeAppDelegate>& chrome_app_delegate);
32
29 class NewWindowContentsDelegate; 33 class NewWindowContentsDelegate;
30 34
31 // extensions::AppDelegate: 35 // extensions::AppDelegate:
32 void InitWebContents(content::WebContents* web_contents) override; 36 void InitWebContents(content::WebContents* web_contents) override;
33 void RenderViewCreated(content::RenderViewHost* render_view_host) override; 37 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
34 void ResizeWebContents(content::WebContents* web_contents, 38 void ResizeWebContents(content::WebContents* web_contents,
35 const gfx::Size& size) override; 39 const gfx::Size& size) override;
36 content::WebContents* OpenURLFromTab( 40 content::WebContents* OpenURLFromTab(
37 content::BrowserContext* context, 41 content::BrowserContext* context,
38 content::WebContents* source, 42 content::WebContents* source,
(...skipping 16 matching lines...) Expand all
55 bool CheckMediaAccessPermission( 59 bool CheckMediaAccessPermission(
56 content::WebContents* web_contents, 60 content::WebContents* web_contents,
57 const GURL& security_origin, 61 const GURL& security_origin,
58 content::MediaStreamType type, 62 content::MediaStreamType type,
59 const extensions::Extension* extension) override; 63 const extensions::Extension* extension) override;
60 int PreferredIconSize() override; 64 int PreferredIconSize() override;
61 void SetWebContentsBlocked(content::WebContents* web_contents, 65 void SetWebContentsBlocked(content::WebContents* web_contents,
62 bool blocked) override; 66 bool blocked) override;
63 bool IsWebContentsVisible(content::WebContents* web_contents) override; 67 bool IsWebContentsVisible(content::WebContents* web_contents) override;
64 void SetTerminatingCallback(const base::Closure& callback) override; 68 void SetTerminatingCallback(const base::Closure& callback) override;
69 void OnHide() override;
70 void OnShow() override;
65 71
66 // content::NotificationObserver: 72 // content::NotificationObserver:
67 void Observe(int type, 73 void Observe(int type,
68 const content::NotificationSource& source, 74 const content::NotificationSource& source,
69 const content::NotificationDetails& details) override; 75 const content::NotificationDetails& details) override;
70 76
77 bool has_been_shown_;
78 bool is_hidden_;
71 scoped_ptr<ScopedKeepAlive> keep_alive_; 79 scoped_ptr<ScopedKeepAlive> keep_alive_;
72 scoped_ptr<NewWindowContentsDelegate> new_window_contents_delegate_; 80 scoped_ptr<NewWindowContentsDelegate> new_window_contents_delegate_;
73 base::Closure terminating_callback_; 81 base::Closure terminating_callback_;
74 content::NotificationRegistrar registrar_; 82 content::NotificationRegistrar registrar_;
83 base::WeakPtrFactory<ChromeAppDelegate> weak_factory_;
75 84
76 DISALLOW_COPY_AND_ASSIGN(ChromeAppDelegate); 85 DISALLOW_COPY_AND_ASSIGN(ChromeAppDelegate);
77 }; 86 };
78 87
79 #endif // CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_ 88 #endif // CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698