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 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 4 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
5 | 5 |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 16 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
17 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 17 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
18 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
19 #include "chrome/browser/chromeos/gdata/gdata_files.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_files.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" | |
21 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
22 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 22 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
23 #include "chrome/browser/chromeos/media/media_player.h" | 23 #include "chrome/browser/chromeos/media/media_player.h" |
24 #include "chrome/browser/extensions/crx_installer.h" | 24 #include "chrome/browser/extensions/crx_installer.h" |
25 #include "chrome/browser/extensions/extension_install_prompt.h" | 25 #include "chrome/browser/extensions/extension_install_prompt.h" |
26 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
27 #include "chrome/browser/plugin_prefs.h" | 27 #include "chrome/browser/plugin_prefs.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
(...skipping 19 matching lines...) Expand all Loading... |
52 #include "webkit/fileapi/file_system_util.h" | 52 #include "webkit/fileapi/file_system_util.h" |
53 #include "webkit/plugins/webplugininfo.h" | 53 #include "webkit/plugins/webplugininfo.h" |
54 | 54 |
55 using base::DictionaryValue; | 55 using base::DictionaryValue; |
56 using base::ListValue; | 56 using base::ListValue; |
57 using content::BrowserContext; | 57 using content::BrowserContext; |
58 using content::BrowserThread; | 58 using content::BrowserThread; |
59 using content::PluginService; | 59 using content::PluginService; |
60 using content::UserMetricsAction; | 60 using content::UserMetricsAction; |
61 using file_handler_util::FileTaskExecutor; | 61 using file_handler_util::FileTaskExecutor; |
62 using gdata::GDataOperationRegistry; | 62 using gdata::OperationRegistry; |
63 | 63 |
64 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" | 64 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" |
65 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; | 65 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; |
66 | 66 |
67 const char kFileBrowserGalleryTaskId[] = "gallery"; | 67 const char kFileBrowserGalleryTaskId[] = "gallery"; |
68 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; | 68 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; |
69 const char kFileBrowserWatchTaskId[] = "watch"; | 69 const char kFileBrowserWatchTaskId[] = "watch"; |
70 const char kFileBrowserPlayTaskId[] = "play"; | 70 const char kFileBrowserPlayTaskId[] = "play"; |
71 | 71 |
72 const char kVideoPlayerAppName[] = "videoplayer"; | 72 const char kVideoPlayerAppName[] = "videoplayer"; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 default: | 174 default: |
175 NOTREACHED(); | 175 NOTREACHED(); |
176 } | 176 } |
177 | 177 |
178 return type_str; | 178 return type_str; |
179 } | 179 } |
180 | 180 |
181 DictionaryValue* ProgessStatusToDictionaryValue( | 181 DictionaryValue* ProgessStatusToDictionaryValue( |
182 Profile* profile, | 182 Profile* profile, |
183 const GURL& origin_url, | 183 const GURL& origin_url, |
184 const GDataOperationRegistry::ProgressStatus& status) { | 184 const OperationRegistry::ProgressStatus& status) { |
185 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 185 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
186 GURL file_url; | 186 GURL file_url; |
187 if (file_manager_util::ConvertFileToFileSystemUrl(profile, | 187 if (file_manager_util::ConvertFileToFileSystemUrl(profile, |
188 gdata::util::GetSpecialRemoteRootPath().Append( | 188 gdata::util::GetSpecialRemoteRootPath().Append( |
189 FilePath(status.file_path)), | 189 FilePath(status.file_path)), |
190 origin_url, | 190 origin_url, |
191 &file_url)) { | 191 &file_url)) { |
192 result->SetString("fileUrl", file_url.spec()); | 192 result->SetString("fileUrl", file_url.spec()); |
193 } | 193 } |
194 | 194 |
195 result->SetString("transferState", | 195 result->SetString("transferState", |
196 GDataOperationRegistry::OperationTransferStateToString( | 196 OperationRegistry::OperationTransferStateToString( |
197 status.transfer_state)); | 197 status.transfer_state)); |
198 result->SetString("transferType", | 198 result->SetString("transferType", |
199 GDataOperationRegistry::OperationTypeToString(status.operation_type)); | 199 OperationRegistry::OperationTypeToString(status.operation_type)); |
200 result->SetInteger("processed", static_cast<int>(status.progress_current)); | 200 result->SetInteger("processed", static_cast<int>(status.progress_current)); |
201 result->SetInteger("total", static_cast<int>(status.progress_total)); | 201 result->SetInteger("total", static_cast<int>(status.progress_total)); |
202 return result.release(); | 202 return result.release(); |
203 } | 203 } |
204 | 204 |
205 void OpenNewTab(const GURL& url, Profile* profile) { | 205 void OpenNewTab(const GURL& url, Profile* profile) { |
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
207 Browser* browser = browser::FindOrCreateTabbedBrowser( | 207 Browser* browser = browser::FindOrCreateTabbedBrowser( |
208 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); | 208 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); |
209 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); | 209 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 706 |
707 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 707 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
708 if (!plugin_prefs) | 708 if (!plugin_prefs) |
709 return false; | 709 return false; |
710 | 710 |
711 return plugin_prefs->IsPluginEnabled(plugin); | 711 return plugin_prefs->IsPluginEnabled(plugin); |
712 } | 712 } |
713 | 713 |
714 ListValue* ProgressStatusVectorToListValue( | 714 ListValue* ProgressStatusVectorToListValue( |
715 Profile* profile, const GURL& origin_url, | 715 Profile* profile, const GURL& origin_url, |
716 const std::vector<GDataOperationRegistry::ProgressStatus>& list) { | 716 const std::vector<OperationRegistry::ProgressStatus>& list) { |
717 scoped_ptr<ListValue> result_list(new ListValue()); | 717 scoped_ptr<ListValue> result_list(new ListValue()); |
718 for (std::vector< | 718 for (std::vector< |
719 GDataOperationRegistry::ProgressStatus>::const_iterator iter = | 719 OperationRegistry::ProgressStatus>::const_iterator iter = |
720 list.begin(); | 720 list.begin(); |
721 iter != list.end(); ++iter) { | 721 iter != list.end(); ++iter) { |
722 result_list->Append( | 722 result_list->Append( |
723 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 723 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
724 } | 724 } |
725 return result_list.release(); | 725 return result_list.release(); |
726 } | 726 } |
727 | 727 |
728 } // namespace file_manager_util | 728 } // namespace file_manager_util |
OLD | NEW |