| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 return NULL; | 168 return NULL; |
| 169 } | 169 } |
| 170 | 170 |
| 171 ChromeAppDelegate::ChromeAppDelegate(bool keep_alive) | 171 ChromeAppDelegate::ChromeAppDelegate(bool keep_alive) |
| 172 : has_been_shown_(false), | 172 : has_been_shown_(false), |
| 173 is_hidden_(true), | 173 is_hidden_(true), |
| 174 new_window_contents_delegate_(new NewWindowContentsDelegate()), | 174 new_window_contents_delegate_(new NewWindowContentsDelegate()), |
| 175 weak_factory_(this) { | 175 weak_factory_(this) { |
| 176 if (keep_alive) { | 176 if (keep_alive) { |
| 177 keep_alive_.reset( | 177 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE, |
| 178 new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE)); | 178 KeepAliveRestartOption::DISABLED)); |
| 179 } | 179 } |
| 180 registrar_.Add(this, | 180 registrar_.Add(this, |
| 181 chrome::NOTIFICATION_APP_TERMINATING, | 181 chrome::NOTIFICATION_APP_TERMINATING, |
| 182 content::NotificationService::AllSources()); | 182 content::NotificationService::AllSources()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 ChromeAppDelegate::~ChromeAppDelegate() { | 185 ChromeAppDelegate::~ChromeAppDelegate() { |
| 186 // Unregister now to prevent getting notified if |keep_alive_| is the last. | 186 // Unregister now to prevent getting notified if |keep_alive_| is the last. |
| 187 terminating_callback_.Reset(); | 187 terminating_callback_.Reset(); |
| 188 } | 188 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 content::BrowserThread::PostDelayedTask( | 342 content::BrowserThread::PostDelayedTask( |
| 343 content::BrowserThread::UI, FROM_HERE, | 343 content::BrowserThread::UI, FROM_HERE, |
| 344 base::Bind(&ChromeAppDelegate::RelinquishKeepAliveAfterTimeout, | 344 base::Bind(&ChromeAppDelegate::RelinquishKeepAliveAfterTimeout, |
| 345 weak_factory_.GetWeakPtr()), | 345 weak_factory_.GetWeakPtr()), |
| 346 base::TimeDelta::FromSeconds(kAppWindowFirstShowTimeoutSeconds)); | 346 base::TimeDelta::FromSeconds(kAppWindowFirstShowTimeoutSeconds)); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void ChromeAppDelegate::OnShow() { | 349 void ChromeAppDelegate::OnShow() { |
| 350 has_been_shown_ = true; | 350 has_been_shown_ = true; |
| 351 is_hidden_ = false; | 351 is_hidden_ = false; |
| 352 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE)); | 352 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE, |
| 353 KeepAliveRestartOption::DISABLED)); |
| 353 } | 354 } |
| 354 | 355 |
| 355 void ChromeAppDelegate::Observe(int type, | 356 void ChromeAppDelegate::Observe(int type, |
| 356 const content::NotificationSource& source, | 357 const content::NotificationSource& source, |
| 357 const content::NotificationDetails& details) { | 358 const content::NotificationDetails& details) { |
| 358 switch (type) { | 359 switch (type) { |
| 359 case chrome::NOTIFICATION_APP_TERMINATING: | 360 case chrome::NOTIFICATION_APP_TERMINATING: |
| 360 if (!terminating_callback_.is_null()) | 361 if (!terminating_callback_.is_null()) |
| 361 terminating_callback_.Run(); | 362 terminating_callback_.Run(); |
| 362 break; | 363 break; |
| 363 default: | 364 default: |
| 364 NOTREACHED() << "Received unexpected notification"; | 365 NOTREACHED() << "Received unexpected notification"; |
| 365 } | 366 } |
| 366 } | 367 } |
| OLD | NEW |