| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 return NULL; | 146 return NULL; |
| 147 } | 147 } |
| 148 | 148 |
| 149 ChromeAppDelegate::ChromeAppDelegate(bool keep_alive) | 149 ChromeAppDelegate::ChromeAppDelegate(bool keep_alive) |
| 150 : has_been_shown_(false), | 150 : has_been_shown_(false), |
| 151 is_hidden_(true), | 151 is_hidden_(true), |
| 152 new_window_contents_delegate_(new NewWindowContentsDelegate()), | 152 new_window_contents_delegate_(new NewWindowContentsDelegate()), |
| 153 weak_factory_(this) { | 153 weak_factory_(this) { |
| 154 if (keep_alive) { | 154 if (keep_alive) { |
| 155 keep_alive_.reset( | 155 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE, |
| 156 new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE)); | 156 KeepAliveRestartOption::DISABLED)); |
| 157 } | 157 } |
| 158 registrar_.Add(this, | 158 registrar_.Add(this, |
| 159 chrome::NOTIFICATION_APP_TERMINATING, | 159 chrome::NOTIFICATION_APP_TERMINATING, |
| 160 content::NotificationService::AllSources()); | 160 content::NotificationService::AllSources()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 ChromeAppDelegate::~ChromeAppDelegate() { | 163 ChromeAppDelegate::~ChromeAppDelegate() { |
| 164 // Unregister now to prevent getting notified if |keep_alive_| is the last. | 164 // Unregister now to prevent getting notified if |keep_alive_| is the last. |
| 165 terminating_callback_.Reset(); | 165 terminating_callback_.Reset(); |
| 166 } | 166 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 content::BrowserThread::PostDelayedTask( | 320 content::BrowserThread::PostDelayedTask( |
| 321 content::BrowserThread::UI, FROM_HERE, | 321 content::BrowserThread::UI, FROM_HERE, |
| 322 base::Bind(&ChromeAppDelegate::RelinquishKeepAliveAfterTimeout, | 322 base::Bind(&ChromeAppDelegate::RelinquishKeepAliveAfterTimeout, |
| 323 weak_factory_.GetWeakPtr()), | 323 weak_factory_.GetWeakPtr()), |
| 324 base::TimeDelta::FromSeconds(kAppWindowFirstShowTimeoutSeconds)); | 324 base::TimeDelta::FromSeconds(kAppWindowFirstShowTimeoutSeconds)); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void ChromeAppDelegate::OnShow() { | 327 void ChromeAppDelegate::OnShow() { |
| 328 has_been_shown_ = true; | 328 has_been_shown_ = true; |
| 329 is_hidden_ = false; | 329 is_hidden_ = false; |
| 330 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE)); | 330 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE, |
| 331 KeepAliveRestartOption::DISABLED)); |
| 331 } | 332 } |
| 332 | 333 |
| 333 void ChromeAppDelegate::Observe(int type, | 334 void ChromeAppDelegate::Observe(int type, |
| 334 const content::NotificationSource& source, | 335 const content::NotificationSource& source, |
| 335 const content::NotificationDetails& details) { | 336 const content::NotificationDetails& details) { |
| 336 switch (type) { | 337 switch (type) { |
| 337 case chrome::NOTIFICATION_APP_TERMINATING: | 338 case chrome::NOTIFICATION_APP_TERMINATING: |
| 338 if (!terminating_callback_.is_null()) | 339 if (!terminating_callback_.is_null()) |
| 339 terminating_callback_.Run(); | 340 terminating_callback_.Run(); |
| 340 break; | 341 break; |
| 341 default: | 342 default: |
| 342 NOTREACHED() << "Received unexpected notification"; | 343 NOTREACHED() << "Received unexpected notification"; |
| 343 } | 344 } |
| 344 } | 345 } |
| OLD | NEW |