| 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_operation_registry.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" |
| 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 20 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 21 #include "chrome/browser/extensions/crx_installer.h" | 21 #include "chrome/browser/extensions/crx_installer.h" |
| 22 #include "chrome/browser/extensions/extension_install_ui.h" | 22 #include "chrome/browser/extensions/extension_install_ui.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/plugin_prefs.h" | 24 #include "chrome/browser/plugin_prefs.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/simple_message_box.h" | 31 #include "chrome/browser/ui/simple_message_box.h" |
| 31 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 33 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/extensions/file_browser_handler.h" | 35 #include "chrome/common/extensions/file_browser_handler.h" |
| 35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| 36 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/plugin_service.h" | 38 #include "content/public/browser/plugin_service.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 status.transfer_state)); | 212 status.transfer_state)); |
| 212 result->SetString("transferType", | 213 result->SetString("transferType", |
| 213 GDataOperationRegistry::OperationTypeToString(status.operation_type)); | 214 GDataOperationRegistry::OperationTypeToString(status.operation_type)); |
| 214 result->SetInteger("processed", static_cast<int>(status.progress_current)); | 215 result->SetInteger("processed", static_cast<int>(status.progress_current)); |
| 215 result->SetInteger("total", static_cast<int>(status.progress_total)); | 216 result->SetInteger("total", static_cast<int>(status.progress_total)); |
| 216 return result.release(); | 217 return result.release(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void OpenNewTab(const GURL& url, Profile* profile) { | 220 void OpenNewTab(const GURL& url, Profile* profile) { |
| 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 221 Browser* browser = Browser::GetOrCreateTabbedBrowser( | 222 Browser* browser = browser::FindOrCreateTabbedBrowser( |
| 222 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); | 223 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 223 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK); | 224 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK); |
| 224 // If the current browser is not tabbed then the new tab will be created | 225 // If the current browser is not tabbed then the new tab will be created |
| 225 // in a different browser. Make sure it is visible. | 226 // in a different browser. Make sure it is visible. |
| 226 browser->window()->Show(); | 227 browser->window()->Show(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 // Shows a warning message box saying that the file could not be opened. | 230 // Shows a warning message box saying that the file could not be opened. |
| 230 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { | 231 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { |
| 231 Browser* browser = Browser::GetOrCreateTabbedBrowser(profile); | 232 // TODO: if FindOrCreateTabbedBrowser creates a new browser the returned |
| 233 // browser is leaked. |
| 234 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 232 browser::ShowMessageBox( | 235 browser::ShowMessageBox( |
| 233 browser->window()->GetNativeHandle(), | 236 browser->window()->GetNativeHandle(), |
| 234 l10n_util::GetStringFUTF16( | 237 l10n_util::GetStringFUTF16( |
| 235 IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE, | 238 IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE, |
| 236 UTF8ToUTF16(path.BaseName().value())), | 239 UTF8ToUTF16(path.BaseName().value())), |
| 237 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE), | 240 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE), |
| 238 browser::MESSAGE_BOX_TYPE_WARNING); | 241 browser::MESSAGE_BOX_TYPE_WARNING); |
| 239 } | 242 } |
| 240 | 243 |
| 241 // Called when a file on GData was found. Opens the file found at |file_path| | 244 // Called when a file on GData was found. Opens the file found at |file_path| |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 StandaloneExecutor(Profile * profile, | 499 StandaloneExecutor(Profile * profile, |
| 497 const GURL& source_url, | 500 const GURL& source_url, |
| 498 const std::string& extension_id, | 501 const std::string& extension_id, |
| 499 const std::string& action_id) | 502 const std::string& action_id) |
| 500 : FileTaskExecutor(profile, source_url, extension_id, action_id) | 503 : FileTaskExecutor(profile, source_url, extension_id, action_id) |
| 501 {} | 504 {} |
| 502 | 505 |
| 503 protected : | 506 protected : |
| 504 // FileTaskExecutor overrides. | 507 // FileTaskExecutor overrides. |
| 505 virtual Browser* browser() { | 508 virtual Browser* browser() { |
| 506 return Browser::GetOrCreateTabbedBrowser(profile()); | 509 return browser::FindOrCreateTabbedBrowser(profile()); |
| 507 } | 510 } |
| 508 virtual void Done(bool) {} | 511 virtual void Done(bool) {} |
| 509 }; | 512 }; |
| 510 | 513 |
| 511 bool TryOpeningFileBrowser(Profile* profile, const FilePath& path) { | 514 bool TryOpeningFileBrowser(Profile* profile, const FilePath& path) { |
| 512 GURL url; | 515 GURL url; |
| 513 if (!ConvertFileToFileSystemUrl(profile, path, | 516 if (!ConvertFileToFileSystemUrl(profile, path, |
| 514 GetFileBrowserExtensionUrl().GetOrigin(), &url)) | 517 GetFileBrowserExtensionUrl().GetOrigin(), &url)) |
| 515 return false; | 518 return false; |
| 516 | 519 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 GDataOperationRegistry::ProgressStatus>::const_iterator iter = | 726 GDataOperationRegistry::ProgressStatus>::const_iterator iter = |
| 724 list.begin(); | 727 list.begin(); |
| 725 iter != list.end(); ++iter) { | 728 iter != list.end(); ++iter) { |
| 726 result_list->Append( | 729 result_list->Append( |
| 727 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 730 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
| 728 } | 731 } |
| 729 return result_list.release(); | 732 return result_list.release(); |
| 730 } | 733 } |
| 731 | 734 |
| 732 } // namespace file_manager_util | 735 } // namespace file_manager_util |
| OLD | NEW |