OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/indexed_db/indexed_db_internals_ui.h" | 5 #include "content/browser/indexed_db/indexed_db_internals_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 15 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/download_manager.h" | 18 #include "content/public/browser/download_manager.h" |
19 #include "content/public/browser/download_url_parameters.h" | 19 #include "content/public/browser/download_url_parameters.h" |
20 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_ui.h" | 22 #include "content/public/browser/web_ui.h" |
23 #include "content/public/browser/web_ui_data_source.h" | 23 #include "content/public/browser/web_ui_data_source.h" |
24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
25 #include "grit/content_resources.h" | 25 #include "grit/content_resources.h" |
26 #include "third_party/WebKit/public/platform/WebString.h" | 26 #include "third_party/WebKit/public/platform/WebString.h" |
27 #include "third_party/zlib/google/zip.h" | 27 #include "third_party/zlib/google/zip.h" |
28 #include "webkit/base/file_path_string_conversions.h" | 28 #include "webkit/base/file_path_string_conversions.h" |
29 #include "webkit/base/origin_url_conversions.h" | 29 #include "webkit/common/database/database_identifier.h" |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 IndexedDBInternalsUI::IndexedDBInternalsUI(WebUI* web_ui) | 33 IndexedDBInternalsUI::IndexedDBInternalsUI(WebUI* web_ui) |
34 : WebUIController(web_ui) { | 34 : WebUIController(web_ui) { |
35 web_ui->RegisterMessageCallback( | 35 web_ui->RegisterMessageCallback( |
36 "getAllOrigins", | 36 "getAllOrigins", |
37 base::Bind(&IndexedDBInternalsUI::GetAllOrigins, base::Unretained(this))); | 37 base::Bind(&IndexedDBInternalsUI::GetAllOrigins, base::Unretained(this))); |
38 | 38 |
39 web_ui->RegisterMessageCallback( | 39 web_ui->RegisterMessageCallback( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 base::ScopedTempDir temp_dir; | 200 base::ScopedTempDir temp_dir; |
201 if (!temp_dir.CreateUniqueTempDir()) | 201 if (!temp_dir.CreateUniqueTempDir()) |
202 return; | 202 return; |
203 | 203 |
204 // This will get cleaned up on the File thread after the download | 204 // This will get cleaned up on the File thread after the download |
205 // has completed. | 205 // has completed. |
206 base::FilePath temp_path = temp_dir.Take(); | 206 base::FilePath temp_path = temp_dir.Take(); |
207 | 207 |
208 std::string origin_id = | 208 std::string origin_id = |
209 webkit_base::GetOriginIdentifierFromURL(origin_url); | 209 webkit_database::GetIdentifierFromOrigin(origin_url); |
210 base::FilePath zip_path = | 210 base::FilePath zip_path = |
211 temp_path.AppendASCII(origin_id).AddExtension(FILE_PATH_LITERAL("zip")); | 211 temp_path.AppendASCII(origin_id).AddExtension(FILE_PATH_LITERAL("zip")); |
212 | 212 |
213 // This happens on the "webkit" thread (which is really just the IndexedDB | 213 // This happens on the "webkit" thread (which is really just the IndexedDB |
214 // thread) as a simple way to avoid another script reopening the origin | 214 // thread) as a simple way to avoid another script reopening the origin |
215 // while we are zipping. | 215 // while we are zipping. |
216 zip::Zip(context->GetFilePath(origin_url), zip_path, true); | 216 zip::Zip(context->GetFilePath(origin_url), zip_path, true); |
217 | 217 |
218 BrowserThread::PostTask(BrowserThread::UI, | 218 BrowserThread::PostTask(BrowserThread::UI, |
219 FROM_HERE, | 219 FROM_HERE, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return; | 304 return; |
305 } | 305 } |
306 | 306 |
307 item->AddObserver(new FileDeleter(temp_path)); | 307 item->AddObserver(new FileDeleter(temp_path)); |
308 web_ui()->CallJavascriptFunction("indexeddb.onOriginDownloadReady", | 308 web_ui()->CallJavascriptFunction("indexeddb.onOriginDownloadReady", |
309 base::StringValue(partition_path.value()), | 309 base::StringValue(partition_path.value()), |
310 base::StringValue(origin_url.spec())); | 310 base::StringValue(origin_url.spec())); |
311 } | 311 } |
312 | 312 |
313 } // namespace content | 313 } // namespace content |
OLD | NEW |