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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 8135017: Refactor downloads into a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated latest rounds of comments from John. Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/background/background_application_list_model.h" 17 #include "chrome/browser/background/background_application_list_model.h"
18 #include "chrome/browser/background/background_mode_manager.h" 18 #include "chrome/browser/background/background_mode_manager.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/browser_shutdown.h" 20 #include "chrome/browser/browser_shutdown.h"
21 #include "chrome/browser/command_updater.h" 21 #include "chrome/browser/command_updater.h"
22 #include "chrome/browser/download/download_service.h"
23 #include "chrome/browser/download/download_service_factory.h"
22 #include "chrome/browser/first_run/first_run.h" 24 #include "chrome/browser/first_run/first_run.h"
23 #include "chrome/browser/instant/instant_confirm_dialog.h" 25 #include "chrome/browser/instant/instant_confirm_dialog.h"
24 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
25 #include "chrome/browser/printing/cloud_print/virtual_driver_install_helper.h" 27 #include "chrome/browser/printing/cloud_print/virtual_driver_install_helper.h"
26 #include "chrome/browser/printing/print_dialog_cloud.h" 28 #include "chrome/browser/printing/print_dialog_cloud.h"
27 #include "chrome/browser/printing/print_job_manager.h" 29 #include "chrome/browser/printing/print_job_manager.h"
28 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/service/service_process_control.h" 31 #include "chrome/browser/service/service_process_control.h"
30 #include "chrome/browser/sessions/session_service.h" 32 #include "chrome/browser/sessions/session_service.h"
31 #include "chrome/browser/sessions/session_service_factory.h" 33 #include "chrome/browser/sessions/session_service_factory.h"
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // Check all profiles for in progress downloads, and if we find any, prompt the 640 // Check all profiles for in progress downloads, and if we find any, prompt the
639 // user to see if we should continue to exit (and thus cancel the downloads), or 641 // user to see if we should continue to exit (and thus cancel the downloads), or
640 // if we should wait. 642 // if we should wait.
641 - (BOOL)shouldQuitWithInProgressDownloads { 643 - (BOOL)shouldQuitWithInProgressDownloads {
642 ProfileManager* profile_manager = g_browser_process->profile_manager(); 644 ProfileManager* profile_manager = g_browser_process->profile_manager();
643 if (!profile_manager) 645 if (!profile_manager)
644 return YES; 646 return YES;
645 647
646 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); 648 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
647 for (size_t i = 0; i < profiles.size(); ++i) { 649 for (size_t i = 0; i < profiles.size(); ++i) {
648 DownloadManager* download_manager = profiles[i]->GetDownloadManager(); 650 DownloadService* download_service =
651 DownloadServiceFactory::GetForProfile(profiles[i]);
652 DownloadManager* download_manager =
653 (download_service->HasCreatedDownloadManager() ?
654 download_service->GetDownloadManager() : NULL);
649 if (download_manager && download_manager->in_progress_count() > 0) { 655 if (download_manager && download_manager->in_progress_count() > 0) {
650 int downloadCount = download_manager->in_progress_count(); 656 int downloadCount = download_manager->in_progress_count();
651 if ([self userWillWaitForInProgressDownloads:downloadCount]) { 657 if ([self userWillWaitForInProgressDownloads:downloadCount]) {
652 // Create a new browser window (if necessary) and navigate to the 658 // Create a new browser window (if necessary) and navigate to the
653 // downloads page if the user chooses to wait. 659 // downloads page if the user chooses to wait.
654 Browser* browser = BrowserList::FindBrowserWithProfile(profiles[i]); 660 Browser* browser = BrowserList::FindBrowserWithProfile(profiles[i]);
655 if (!browser) { 661 if (!browser) {
656 browser = Browser::Create(profiles[i]); 662 browser = Browser::Create(profiles[i]);
657 browser->window()->Show(); 663 browser->window()->Show();
658 } 664 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 1284
1279 } // namespace browser 1285 } // namespace browser
1280 1286
1281 namespace app_controller_mac { 1287 namespace app_controller_mac {
1282 1288
1283 bool IsOpeningNewWindow() { 1289 bool IsOpeningNewWindow() {
1284 return g_is_opening_new_window; 1290 return g_is_opening_new_window;
1285 } 1291 }
1286 1292
1287 } // namespace app_controller_mac 1293 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698