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

Side by Side Diff: chrome/browser/download/download_extension_api.cc

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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
OLDNEW
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/download/download_extension_api.h" 5 #include "chrome/browser/download/download_extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 29 matching lines...) Expand all
40 #include "content/public/browser/download_interrupt_reasons.h" 40 #include "content/public/browser/download_interrupt_reasons.h"
41 #include "content/public/browser/download_item.h" 41 #include "content/public/browser/download_item.h"
42 #include "content/public/browser/download_save_info.h" 42 #include "content/public/browser/download_save_info.h"
43 #include "content/public/browser/render_process_host.h" 43 #include "content/public/browser/render_process_host.h"
44 #include "content/public/browser/render_view_host.h" 44 #include "content/public/browser/render_view_host.h"
45 #include "content/public/browser/resource_dispatcher_host.h" 45 #include "content/public/browser/resource_dispatcher_host.h"
46 #include "net/base/load_flags.h" 46 #include "net/base/load_flags.h"
47 #include "net/http/http_util.h" 47 #include "net/http/http_util.h"
48 #include "net/url_request/url_request.h" 48 #include "net/url_request/url_request.h"
49 49
50 using content::BrowserContext;
50 using content::BrowserThread; 51 using content::BrowserThread;
51 using content::DownloadId; 52 using content::DownloadId;
52 using content::DownloadItem; 53 using content::DownloadItem;
53 using content::DownloadManager; 54 using content::DownloadManager;
54 55
55 namespace download_extension_errors { 56 namespace download_extension_errors {
56 57
57 // Error messages 58 // Error messages
58 const char kGenericError[] = "I'm afraid I can't do that."; 59 const char kGenericError[] = "I'm afraid I can't do that.";
59 const char kIconNotFoundError[] = "Icon not found."; 60 const char kIconNotFoundError[] = "Icon not found.";
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 307 }
307 308
308 bool IsNotTemporaryDownloadFilter(const DownloadItem& item) { 309 bool IsNotTemporaryDownloadFilter(const DownloadItem& item) {
309 return !item.IsTemporary(); 310 return !item.IsTemporary();
310 } 311 }
311 312
312 void GetManagers( 313 void GetManagers(
313 Profile* profile, 314 Profile* profile,
314 bool include_incognito, 315 bool include_incognito,
315 DownloadManager** manager, DownloadManager** incognito_manager) { 316 DownloadManager** manager, DownloadManager** incognito_manager) {
316 *manager = DownloadServiceFactory::GetForProfile(profile)-> 317 *manager = BrowserContext::GetDownloadManager(profile);
317 GetDownloadManager();
318 *incognito_manager = NULL; 318 *incognito_manager = NULL;
319 if (include_incognito && profile->HasOffTheRecordProfile()) 319 if (include_incognito && profile->HasOffTheRecordProfile()) {
320 *incognito_manager = DownloadServiceFactory::GetForProfile(profile-> 320 *incognito_manager = BrowserContext::GetDownloadManager(
321 GetOffTheRecordProfile())->GetDownloadManager(); 321 profile->GetOffTheRecordProfile());
322 }
322 } 323 }
323 324
324 DownloadItem* GetActiveItemInternal( 325 DownloadItem* GetActiveItemInternal(
325 Profile* profile, 326 Profile* profile,
326 bool include_incognito, 327 bool include_incognito,
327 int id) { 328 int id) {
328 DownloadManager* manager = NULL; 329 DownloadManager* manager = NULL;
329 DownloadManager* incognito_manager = NULL; 330 DownloadManager* incognito_manager = NULL;
330 GetManagers(profile, include_incognito, &manager, &incognito_manager); 331 GetManagers(profile, include_incognito, &manager, &incognito_manager);
331 DownloadItem* download_item = manager->GetActiveDownloadItem(id); 332 DownloadItem* download_item = manager->GetActiveDownloadItem(id);
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 ListValue args; 1113 ListValue args;
1113 args.Append(arg); 1114 args.Append(arg);
1114 std::string json_args; 1115 std::string json_args;
1115 base::JSONWriter::Write(&args, &json_args); 1116 base::JSONWriter::Write(&args, &json_args);
1116 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 1117 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
1117 event_name, 1118 event_name,
1118 json_args, 1119 json_args,
1119 profile_, 1120 profile_,
1120 GURL()); 1121 GURL());
1121 } 1122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698