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/drive.pb.h" | 17 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" | 18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
19 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" | 19 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" |
20 #include "chrome/browser/chromeos/gdata/drive_files.h" | 20 #include "chrome/browser/chromeos/gdata/drive_files.h" |
21 #include "chrome/browser/chromeos/gdata/drive_system_service.h" | 21 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
22 #include "chrome/browser/chromeos/media/media_player.h" | 22 #include "chrome/browser/chromeos/media/media_player.h" |
23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
24 #include "chrome/browser/extensions/extension_install_prompt.h" | 24 #include "chrome/browser/extensions/extension_install_prompt.h" |
25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
26 #include "chrome/browser/google_apis/operation_registry.h" | |
27 #include "chrome/browser/plugin_prefs.h" | 26 #include "chrome/browser/plugin_prefs.h" |
28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
30 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
32 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
34 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
35 #include "chrome/browser/ui/extensions/application_launch.h" | 34 #include "chrome/browser/ui/extensions/application_launch.h" |
36 #include "chrome/browser/ui/simple_message_box.h" | 35 #include "chrome/browser/ui/simple_message_box.h" |
(...skipping 16 matching lines...) Expand all Loading... |
53 #include "webkit/fileapi/file_system_util.h" | 52 #include "webkit/fileapi/file_system_util.h" |
54 #include "webkit/plugins/webplugininfo.h" | 53 #include "webkit/plugins/webplugininfo.h" |
55 | 54 |
56 using base::DictionaryValue; | 55 using base::DictionaryValue; |
57 using base::ListValue; | 56 using base::ListValue; |
58 using content::BrowserContext; | 57 using content::BrowserContext; |
59 using content::BrowserThread; | 58 using content::BrowserThread; |
60 using content::PluginService; | 59 using content::PluginService; |
61 using content::UserMetricsAction; | 60 using content::UserMetricsAction; |
62 using file_handler_util::FileTaskExecutor; | 61 using file_handler_util::FileTaskExecutor; |
63 using gdata::OperationRegistry; | |
64 | 62 |
65 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" | 63 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" |
66 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; | 64 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; |
67 | 65 |
68 const char kFileBrowserGalleryTaskId[] = "gallery"; | 66 const char kFileBrowserGalleryTaskId[] = "gallery"; |
69 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; | 67 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; |
70 const char kFileBrowserWatchTaskId[] = "watch"; | 68 const char kFileBrowserWatchTaskId[] = "watch"; |
71 const char kFileBrowserPlayTaskId[] = "play"; | 69 const char kFileBrowserPlayTaskId[] = "play"; |
72 | 70 |
73 const char kVideoPlayerAppName[] = "videoplayer"; | 71 const char kVideoPlayerAppName[] = "videoplayer"; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 default: | 174 default: |
177 NOTREACHED(); | 175 NOTREACHED(); |
178 } | 176 } |
179 | 177 |
180 return type_str; | 178 return type_str; |
181 } | 179 } |
182 | 180 |
183 DictionaryValue* ProgessStatusToDictionaryValue( | 181 DictionaryValue* ProgessStatusToDictionaryValue( |
184 Profile* profile, | 182 Profile* profile, |
185 const GURL& origin_url, | 183 const GURL& origin_url, |
186 const OperationRegistry::ProgressStatus& status) { | 184 const gdata::OperationProgressStatus& status) { |
187 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 185 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
188 GURL file_url; | 186 GURL file_url; |
189 if (file_manager_util::ConvertFileToFileSystemUrl(profile, | 187 if (file_manager_util::ConvertFileToFileSystemUrl(profile, |
190 gdata::util::GetSpecialRemoteRootPath().Append( | 188 gdata::util::GetSpecialRemoteRootPath().Append( |
191 FilePath(status.file_path)), | 189 FilePath(status.file_path)), |
192 origin_url, | 190 origin_url, |
193 &file_url)) { | 191 &file_url)) { |
194 result->SetString("fileUrl", file_url.spec()); | 192 result->SetString("fileUrl", file_url.spec()); |
195 } | 193 } |
196 | 194 |
197 result->SetString("transferState", | 195 result->SetString("transferState", |
198 OperationRegistry::OperationTransferStateToString( | 196 OperationTransferStateToString(status.transfer_state)); |
199 status.transfer_state)); | |
200 result->SetString("transferType", | 197 result->SetString("transferType", |
201 OperationRegistry::OperationTypeToString(status.operation_type)); | 198 OperationTypeToString(status.operation_type)); |
202 result->SetInteger("processed", static_cast<int>(status.progress_current)); | 199 result->SetInteger("processed", static_cast<int>(status.progress_current)); |
203 result->SetInteger("total", static_cast<int>(status.progress_total)); | 200 result->SetInteger("total", static_cast<int>(status.progress_total)); |
204 return result.release(); | 201 return result.release(); |
205 } | 202 } |
206 | 203 |
207 void OpenNewTab(const GURL& url, Profile* profile) { | 204 void OpenNewTab(const GURL& url, Profile* profile) { |
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
209 Browser* browser = browser::FindOrCreateTabbedBrowser( | 206 Browser* browser = browser::FindOrCreateTabbedBrowser( |
210 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); | 207 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); |
211 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); | 208 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 | 786 |
790 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 787 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
791 if (!plugin_prefs) | 788 if (!plugin_prefs) |
792 return false; | 789 return false; |
793 | 790 |
794 return plugin_prefs->IsPluginEnabled(plugin); | 791 return plugin_prefs->IsPluginEnabled(plugin); |
795 } | 792 } |
796 | 793 |
797 ListValue* ProgressStatusVectorToListValue( | 794 ListValue* ProgressStatusVectorToListValue( |
798 Profile* profile, const GURL& origin_url, | 795 Profile* profile, const GURL& origin_url, |
799 const std::vector<OperationRegistry::ProgressStatus>& list) { | 796 const gdata::OperationProgressStatusList& list) { |
800 scoped_ptr<ListValue> result_list(new ListValue()); | 797 scoped_ptr<ListValue> result_list(new ListValue()); |
801 for (std::vector< | 798 for (gdata::OperationProgressStatusList::const_iterator iter = list.begin(); |
802 OperationRegistry::ProgressStatus>::const_iterator iter = | |
803 list.begin(); | |
804 iter != list.end(); ++iter) { | 799 iter != list.end(); ++iter) { |
805 result_list->Append( | 800 result_list->Append( |
806 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 801 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
807 } | 802 } |
808 return result_list.release(); | 803 return result_list.release(); |
809 } | 804 } |
810 | 805 |
811 } // namespace file_manager_util | 806 } // namespace file_manager_util |
OLD | NEW |