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