| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 service->GetExtensionEventRouter()->SetShelfEnabled(extension(), | 1422 service->GetExtensionEventRouter()->SetShelfEnabled(extension(), |
| 1423 params->enabled); | 1423 params->enabled); |
| 1424 } | 1424 } |
| 1425 if (incognito_manager) { | 1425 if (incognito_manager) { |
| 1426 incognito_service = DownloadServiceFactory::GetForBrowserContext( | 1426 incognito_service = DownloadServiceFactory::GetForBrowserContext( |
| 1427 incognito_manager->GetBrowserContext()); | 1427 incognito_manager->GetBrowserContext()); |
| 1428 incognito_service->GetExtensionEventRouter()->SetShelfEnabled( | 1428 incognito_service->GetExtensionEventRouter()->SetShelfEnabled( |
| 1429 extension(), params->enabled); | 1429 extension(), params->enabled); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 #if !defined(OS_CHROMEOS) |
| 1432 BrowserList* browsers = BrowserList::GetInstance(); | 1433 BrowserList* browsers = BrowserList::GetInstance(); |
| 1433 if (browsers) { | 1434 if (browsers) { |
| 1434 for (BrowserList::const_iterator iter = browsers->begin(); | 1435 for (BrowserList::const_iterator iter = browsers->begin(); |
| 1435 iter != browsers->end(); ++iter) { | 1436 iter != browsers->end(); ++iter) { |
| 1436 const Browser* browser = *iter; | 1437 const Browser* browser = *iter; |
| 1437 DownloadService* current_service = | 1438 DownloadService* current_service = |
| 1438 DownloadServiceFactory::GetForBrowserContext(browser->profile()); | 1439 DownloadServiceFactory::GetForBrowserContext(browser->profile()); |
| 1439 if (((current_service == service) || | 1440 if (((current_service == service) || |
| 1440 (current_service == incognito_service)) && | 1441 (current_service == incognito_service)) && |
| 1441 browser->window()->IsDownloadShelfVisible() && | 1442 browser->window()->IsDownloadShelfVisible() && |
| 1442 !current_service->IsShelfEnabled()) | 1443 !current_service->IsShelfEnabled()) |
| 1443 browser->window()->GetDownloadShelf()->Close(DownloadShelf::AUTOMATIC); | 1444 browser->window()->GetDownloadShelf()->Close(DownloadShelf::AUTOMATIC); |
| 1444 } | 1445 } |
| 1445 } | 1446 } |
| 1447 #endif |
| 1446 | 1448 |
| 1447 if (params->enabled && | 1449 if (params->enabled && |
| 1448 ((manager && !service->IsShelfEnabled()) || | 1450 ((manager && !service->IsShelfEnabled()) || |
| 1449 (incognito_manager && !incognito_service->IsShelfEnabled()))) { | 1451 (incognito_manager && !incognito_service->IsShelfEnabled()))) { |
| 1450 error_ = download_extension_errors::kShelfDisabled; | 1452 error_ = download_extension_errors::kShelfDisabled; |
| 1451 return false; | 1453 return false; |
| 1452 } | 1454 } |
| 1453 | 1455 |
| 1454 return true; | 1456 return true; |
| 1455 } | 1457 } |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 return; | 1905 return; |
| 1904 base::Time now(base::Time::Now()); | 1906 base::Time now(base::Time::Now()); |
| 1905 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1907 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
| 1906 if (delta <= kFileExistenceRateLimitSeconds) | 1908 if (delta <= kFileExistenceRateLimitSeconds) |
| 1907 return; | 1909 return; |
| 1908 last_checked_removal_ = now; | 1910 last_checked_removal_ = now; |
| 1909 manager->CheckForHistoryFilesRemoval(); | 1911 manager->CheckForHistoryFilesRemoval(); |
| 1910 } | 1912 } |
| 1911 | 1913 |
| 1912 } // namespace extensions | 1914 } // namespace extensions |
| OLD | NEW |