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

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

Issue 557833007: Remove Increment/DecrementKeepAliveCount from AppsClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass ScopedKeepAlive Created 6 years, 3 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 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 5 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/app_mode/app_mode_utils.h" 9 #include "chrome/browser/app_mode/app_mode_utils.h"
10 #include "chrome/browser/apps/scoped_keep_alive.h"
10 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
12 #include "chrome/browser/favicon/favicon_tab_helper.h" 13 #include "chrome/browser/favicon/favicon_tab_helper.h"
13 #include "chrome/browser/file_select_helper.h" 14 #include "chrome/browser/file_select_helper.h"
15 #include "chrome/browser/lifetime/application_lifetime.h"
tapted 2014/09/24 07:12:41 nit: this include no longer needed
hashimoto 2014/09/24 09:03:46 Done.
14 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 16 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
15 #include "chrome/browser/platform_util.h" 17 #include "chrome/browser/platform_util.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/shell_integration.h" 19 #include "chrome/browser/shell_integration.h"
18 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_dialogs.h" 21 #include "chrome/browser/ui/browser_dialogs.h"
20 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
21 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
23 #include "chrome/browser/ui/web_contents_sizer.h" 25 #include "chrome/browser/ui/web_contents_sizer.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 params)); 143 params));
142 // Object lifetime notes: The OpenURLFromTabBasedOnBrowserDefault is owned 144 // Object lifetime notes: The OpenURLFromTabBasedOnBrowserDefault is owned
143 // by check_if_default_browser_worker. StartCheckIsDefault() takes lifetime 145 // by check_if_default_browser_worker. StartCheckIsDefault() takes lifetime
144 // ownership of check_if_default_browser_worker and will clean up after 146 // ownership of check_if_default_browser_worker and will clean up after
145 // the asynchronous tasks. 147 // the asynchronous tasks.
146 check_if_default_browser_worker->StartCheckIsDefault(); 148 check_if_default_browser_worker->StartCheckIsDefault();
147 } 149 }
148 return NULL; 150 return NULL;
149 } 151 }
150 152
151 ChromeAppDelegate::ChromeAppDelegate() 153 ChromeAppDelegate::ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive)
152 : new_window_contents_delegate_(new NewWindowContentsDelegate()) { 154 : keep_alive_(keep_alive.Pass()),
155 new_window_contents_delegate_(new NewWindowContentsDelegate()) {
153 registrar_.Add(this, 156 registrar_.Add(this,
154 chrome::NOTIFICATION_APP_TERMINATING, 157 chrome::NOTIFICATION_APP_TERMINATING,
155 content::NotificationService::AllSources()); 158 content::NotificationService::AllSources());
156 } 159 }
157 160
158 ChromeAppDelegate::~ChromeAppDelegate() { 161 ChromeAppDelegate::~ChromeAppDelegate() {
162 // Unregister now to prevent getting notified if |keep_alive_| is the last.
163 terminating_callback_.Reset();
159 } 164 }
160 165
161 void ChromeAppDelegate::DisableExternalOpenForTesting() { 166 void ChromeAppDelegate::DisableExternalOpenForTesting() {
162 disable_external_open_for_testing_ = true; 167 disable_external_open_for_testing_ = true;
163 } 168 }
164 169
165 void ChromeAppDelegate::InitWebContents(content::WebContents* web_contents) { 170 void ChromeAppDelegate::InitWebContents(content::WebContents* web_contents) {
166 FaviconTabHelper::CreateForWebContents(web_contents); 171 FaviconTabHelper::CreateForWebContents(web_contents);
167 172
168 #if defined(ENABLE_PRINTING) 173 #if defined(ENABLE_PRINTING)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 const content::NotificationDetails& details) { 291 const content::NotificationDetails& details) {
287 switch (type) { 292 switch (type) {
288 case chrome::NOTIFICATION_APP_TERMINATING: 293 case chrome::NOTIFICATION_APP_TERMINATING:
289 if (!terminating_callback_.is_null()) 294 if (!terminating_callback_.is_null())
290 terminating_callback_.Run(); 295 terminating_callback_.Run();
291 break; 296 break;
292 default: 297 default:
293 NOTREACHED() << "Received unexpected notification"; 298 NOTREACHED() << "Received unexpected notification";
294 } 299 }
295 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698