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

Side by Side Diff: chrome/browser/ui/webui/downloads_ui.cc

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 | « chrome/browser/ui/webui/downloads_dom_handler.cc ('k') | chrome/chrome_browser.gypi » ('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 #include "chrome/browser/ui/webui/downloads_ui.h" 5 #include "chrome/browser/ui/webui/downloads_ui.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/defaults.h" 11 #include "chrome/browser/defaults.h"
12 #include "chrome/browser/download/download_service.h"
13 #include "chrome/browser/download/download_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
14 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
15 #include "chrome/browser/ui/webui/downloads_dom_handler.h" 17 #include "chrome/browser/ui/webui/downloads_dom_handler.h"
16 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
17 #include "content/browser/download/download_manager.h" 19 #include "content/browser/download/download_manager.h"
18 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
19 #include "grit/browser_resources.h" 21 #include "grit/browser_resources.h"
20 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 73
72 } // namespace 74 } // namespace
73 75
74 /////////////////////////////////////////////////////////////////////////////// 76 ///////////////////////////////////////////////////////////////////////////////
75 // 77 //
76 // DownloadsUI 78 // DownloadsUI
77 // 79 //
78 /////////////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////////////
79 81
80 DownloadsUI::DownloadsUI(TabContents* contents) : ChromeWebUI(contents) { 82 DownloadsUI::DownloadsUI(TabContents* contents) : ChromeWebUI(contents) {
81 DownloadManager* dlm = GetProfile()->GetDownloadManager(); 83 DownloadManager* dlm =
84 DownloadServiceFactory::GetForProfile(GetProfile())->GetDownloadManager();
82 85
83 DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm); 86 DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm);
84 AddMessageHandler(handler); 87 AddMessageHandler(handler);
85 handler->Attach(this); 88 handler->Attach(this);
86 handler->Init(); 89 handler->Init();
87 90
88 // Set up the chrome://downloads/ source. 91 // Set up the chrome://downloads/ source.
89 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 92 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
90 profile->GetChromeURLDataManager()->AddDataSource( 93 profile->GetChromeURLDataManager()->AddDataSource(
91 CreateDownloadsUIHTMLSource()); 94 CreateDownloadsUIHTMLSource());
92 } 95 }
93 96
94 // static 97 // static
95 RefCountedMemory* DownloadsUI::GetFaviconResourceBytes() { 98 RefCountedMemory* DownloadsUI::GetFaviconResourceBytes() {
96 return ResourceBundle::GetSharedInstance(). 99 return ResourceBundle::GetSharedInstance().
97 LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON); 100 LoadDataResourceBytes(IDR_DOWNLOADS_FAVICON);
98 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698