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/download/save_package_file_picker.h" | 5 #include "chrome/browser/download/save_package_file_picker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 using content::RenderProcessHost; | 34 using content::RenderProcessHost; |
35 using content::SavePageType; | 35 using content::SavePageType; |
36 using content::WebContents; | 36 using content::WebContents; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // If false, we don't prompt the user as to where to save the file. This | 40 // If false, we don't prompt the user as to where to save the file. This |
41 // exists only for testing. | 41 // exists only for testing. |
42 bool g_should_prompt_for_filename = true; | 42 bool g_should_prompt_for_filename = true; |
43 | 43 |
| 44 #if !defined(OS_CHROMEOS) |
44 // Used for mapping between SavePageType constants and the indexes above. | 45 // Used for mapping between SavePageType constants and the indexes above. |
45 const SavePageType kIndexToSaveType[] = { | 46 const SavePageType kIndexToSaveType[] = { |
46 content::SAVE_PAGE_TYPE_UNKNOWN, | 47 content::SAVE_PAGE_TYPE_UNKNOWN, |
47 content::SAVE_PAGE_TYPE_AS_ONLY_HTML, | 48 content::SAVE_PAGE_TYPE_AS_ONLY_HTML, |
48 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 49 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
49 }; | 50 }; |
50 | 51 |
51 int SavePackageTypeToIndex(SavePageType type) { | 52 int SavePackageTypeToIndex(SavePageType type) { |
52 for (size_t i = 0; i < arraysize(kIndexToSaveType); ++i) { | 53 for (size_t i = 0; i < arraysize(kIndexToSaveType); ++i) { |
53 if (kIndexToSaveType[i] == type) | 54 if (kIndexToSaveType[i] == type) |
54 return i; | 55 return i; |
55 } | 56 } |
56 NOTREACHED(); | 57 NOTREACHED(); |
57 return -1; | 58 return -1; |
58 } | 59 } |
| 60 #endif |
59 | 61 |
60 // Indexes used for specifying which element in the extensions dropdown | 62 // Indexes used for specifying which element in the extensions dropdown |
61 // the user chooses when picking a save type. | 63 // the user chooses when picking a save type. |
62 const int kSelectFileHtmlOnlyIndex = 1; | 64 const int kSelectFileHtmlOnlyIndex = 1; |
63 const int kSelectFileCompleteIndex = 2; | 65 const int kSelectFileCompleteIndex = 2; |
64 | 66 |
65 // Used for mapping between the IDS_ string identifiers and the indexes above. | 67 // Used for mapping between the IDS_ string identifiers and the indexes above. |
66 const int kIndexToIDS[] = { | 68 const int kIndexToIDS[] = { |
67 0, IDS_SAVE_PAGE_DESC_HTML_ONLY, IDS_SAVE_PAGE_DESC_COMPLETE, | 69 0, IDS_SAVE_PAGE_DESC_HTML_ONLY, IDS_SAVE_PAGE_DESC_COMPLETE, |
68 }; | 70 }; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 280 } |
279 #endif | 281 #endif |
280 | 282 |
281 callback_.Run(path_copy, save_type, | 283 callback_.Run(path_copy, save_type, |
282 base::Bind(&OnSavePackageDownloadCreated)); | 284 base::Bind(&OnSavePackageDownloadCreated)); |
283 } | 285 } |
284 | 286 |
285 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { | 287 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { |
286 delete this; | 288 delete this; |
287 } | 289 } |
OLD | NEW |