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/ui/webui/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/string_piece.h" | 15 #include "base/string_piece.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 20 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
21 #include "chrome/browser/download/download_danger_prompt.h" | 21 #include "chrome/browser/download/download_danger_prompt.h" |
22 #include "chrome/browser/download/download_history.h" | 22 #include "chrome/browser/download/download_history.h" |
23 #include "chrome/browser/download/download_prefs.h" | 23 #include "chrome/browser/download/download_prefs.h" |
24 #include "chrome/browser/download/download_service.h" | 24 #include "chrome/browser/download/download_service.h" |
25 #include "chrome/browser/download/download_service_factory.h" | 25 #include "chrome/browser/download/download_service_factory.h" |
26 #include "chrome/browser/download/download_util.h" | 26 #include "chrome/browser/download/download_util.h" |
27 #include "chrome/browser/platform_util.h" | 27 #include "chrome/browser/platform_util.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
30 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 30 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" |
31 #include "chrome/browser/ui/webui/fileicon_source.h" | 31 #include "chrome/browser/ui/webui/fileicon_source.h" |
32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
33 #include "content/public/browser/download_item.h" | 33 #include "content/public/browser/download_item.h" |
34 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "content/public/browser/web_ui.h" | 36 #include "content/public/browser/web_ui.h" |
37 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
38 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
39 | 39 |
40 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 DownloadsDOMHandler::DownloadsDOMHandler(content::DownloadManager* dlm) | 91 DownloadsDOMHandler::DownloadsDOMHandler(content::DownloadManager* dlm) |
92 : search_text_(), | 92 : search_text_(), |
93 download_manager_(dlm), | 93 download_manager_(dlm), |
94 original_profile_download_manager_(NULL), | 94 original_profile_download_manager_(NULL), |
95 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 95 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
96 // Create our fileicon data source. | 96 // Create our fileicon data source. |
97 Profile::FromBrowserContext(dlm->GetBrowserContext())-> | 97 Profile* profile = Profile::FromBrowserContext(dlm->GetBrowserContext()); |
98 GetChromeURLDataManager()->AddDataSource(new FileIconSource()); | 98 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
| 99 AddDataSource(new FileIconSource()); |
99 | 100 |
100 // Figure out our parent DownloadManager, if any. | 101 // Figure out our parent DownloadManager, if any. |
101 Profile* profile = | |
102 Profile::FromBrowserContext(download_manager_->GetBrowserContext()); | |
103 Profile* original_profile = profile->GetOriginalProfile(); | 102 Profile* original_profile = profile->GetOriginalProfile(); |
104 if (original_profile != profile) { | 103 if (original_profile != profile) { |
105 original_profile_download_manager_ = DownloadServiceFactory::GetForProfile( | 104 original_profile_download_manager_ = DownloadServiceFactory::GetForProfile( |
106 original_profile)->GetDownloadManager(); | 105 original_profile)->GetDownloadManager(); |
107 } | 106 } |
108 } | 107 } |
109 | 108 |
110 DownloadsDOMHandler::~DownloadsDOMHandler() { | 109 DownloadsDOMHandler::~DownloadsDOMHandler() { |
111 ClearDownloadItems(); | 110 ClearDownloadItems(); |
112 download_manager_->RemoveObserver(this); | 111 download_manager_->RemoveObserver(this); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 403 } |
405 | 404 |
406 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( | 405 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( |
407 const ListValue* args) { | 406 const ListValue* args) { |
408 int id; | 407 int id; |
409 if (ExtractIntegerValue(args, &id)) { | 408 if (ExtractIntegerValue(args, &id)) { |
410 return GetDownloadById(id); | 409 return GetDownloadById(id); |
411 } | 410 } |
412 return NULL; | 411 return NULL; |
413 } | 412 } |
OLD | NEW |