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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void reset_download_updated() { download_updated_.reset(); } | 84 void reset_download_updated() { download_updated_.reset(); } |
85 | 85 |
86 using DownloadsDOMHandler::FinalizeRemovals; | 86 using DownloadsDOMHandler::FinalizeRemovals; |
87 | 87 |
88 protected: | 88 protected: |
89 content::WebContents* GetWebUIWebContents() override { return NULL; } | 89 content::WebContents* GetWebUIWebContents() override { return NULL; } |
90 | 90 |
91 void CallUpdateAll(const base::ListValue& list) override { | 91 void CallUpdateAll(const base::ListValue& list) override { |
92 downloads_list_.reset(list.DeepCopy()); | 92 downloads_list_.reset(list.DeepCopy()); |
93 if (waiting_list_) { | 93 if (waiting_list_) { |
94 content::BrowserThread::PostTask(content::BrowserThread::UI, | 94 content::BrowserThread::PostTask( |
95 FROM_HERE, | 95 content::BrowserThread::UI, FROM_HERE, |
96 base::MessageLoop::QuitClosure()); | 96 base::MessageLoop::QuitWhenIdleClosure()); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void CallUpdateItem(const base::DictionaryValue& item) override { | 100 void CallUpdateItem(const base::DictionaryValue& item) override { |
101 download_updated_.reset(item.DeepCopy()); | 101 download_updated_.reset(item.DeepCopy()); |
102 if (waiting_updated_) { | 102 if (waiting_updated_) { |
103 content::BrowserThread::PostTask(content::BrowserThread::UI, | 103 content::BrowserThread::PostTask( |
104 FROM_HERE, | 104 content::BrowserThread::UI, FROM_HERE, |
105 base::MessageLoop::QuitClosure()); | 105 base::MessageLoop::QuitWhenIdleClosure()); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 private: | 109 private: |
110 scoped_ptr<base::ListValue> downloads_list_; | 110 scoped_ptr<base::ListValue> downloads_list_; |
111 scoped_ptr<base::DictionaryValue> download_updated_; | 111 scoped_ptr<base::DictionaryValue> download_updated_; |
112 bool waiting_list_; | 112 bool waiting_list_; |
113 bool waiting_updated_; | 113 bool waiting_updated_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(MockDownloadsDOMHandler); | 115 DISALLOW_COPY_AND_ASSIGN(MockDownloadsDOMHandler); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record | 317 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record |
318 // calls can't access off-record items. | 318 // calls can't access off-record items. |
319 | 319 |
320 // TODO(benjhayden): Test that bad download ids incoming from the javascript are | 320 // TODO(benjhayden): Test that bad download ids incoming from the javascript are |
321 // dropped on the floor. | 321 // dropped on the floor. |
322 | 322 |
323 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. | 323 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. |
324 | 324 |
325 // TODO(benjhayden): Test that RemoveObserver is called on all download items, | 325 // TODO(benjhayden): Test that RemoveObserver is called on all download items, |
326 // including items that crossed IsTemporary() and back. | 326 // including items that crossed IsTemporary() and back. |
OLD | NEW |