OLD | NEW |
---|---|
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_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" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 } | 139 } |
140 | 140 |
141 void DownloadsDOMHandler::HandleGetDownloads(const ListValue* args) { | 141 void DownloadsDOMHandler::HandleGetDownloads(const ListValue* args) { |
142 std::wstring new_search = UTF16ToWideHack(ExtractStringValue(args)); | 142 std::wstring new_search = UTF16ToWideHack(ExtractStringValue(args)); |
143 if (search_text_.compare(new_search) != 0) { | 143 if (search_text_.compare(new_search) != 0) { |
144 search_text_ = new_search; | 144 search_text_ = new_search; |
145 ModelChanged(); | 145 ModelChanged(); |
146 } else { | 146 } else { |
147 SendCurrentDownloads(); | 147 SendCurrentDownloads(); |
148 } | 148 } |
149 | |
150 for (OrderedDownloads::iterator it = download_items_.begin(); | |
151 it != download_items_.end(); ++it) { | |
152 if ((*it)->IsComplete() && (*it)->is_path_exists()) | |
153 (*it)->AddObserver(this); | |
Paweł Hajdan Jr.
2011/05/10 07:59:46
This AddObserver logic getting scattered across ev
| |
154 } | |
155 download_manager_->CheckExistingPaths(); | |
149 } | 156 } |
150 | 157 |
151 void DownloadsDOMHandler::HandleOpenFile(const ListValue* args) { | 158 void DownloadsDOMHandler::HandleOpenFile(const ListValue* args) { |
152 DownloadItem* file = GetDownloadByValue(args); | 159 DownloadItem* file = GetDownloadByValue(args); |
153 if (file) | 160 if (file) |
154 file->OpenDownload(); | 161 file->OpenDownload(); |
155 } | 162 } |
156 | 163 |
157 void DownloadsDOMHandler::HandleDrag(const ListValue* args) { | 164 void DownloadsDOMHandler::HandleDrag(const ListValue* args) { |
158 DownloadItem* file = GetDownloadByValue(args); | 165 DownloadItem* file = GetDownloadByValue(args); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 return NULL; | 247 return NULL; |
241 } | 248 } |
242 | 249 |
243 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { | 250 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { |
244 int id; | 251 int id; |
245 if (ExtractIntegerValue(args, &id)) { | 252 if (ExtractIntegerValue(args, &id)) { |
246 return GetDownloadById(id); | 253 return GetDownloadById(id); |
247 } | 254 } |
248 return NULL; | 255 return NULL; |
249 } | 256 } |
OLD | NEW |