diff options
27 files changed, 158 insertions, 978 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4ba45ff..2992e43 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -12349,13 +12349,7 @@ Some features may be unavailable. Please check that the profile exists and you Chrome cannot set wallpaper. </message> - <!-- File Browser --> - <message name="IDS_FLAGS_FILE_MANAGER_LEGACY_NAME" desc="Name of about:flag option to launch the Files app in the legacy mode."> - Legacy mode Files app - </message> - <message name="IDS_FLAGS_FILE_MANAGER_LEGACY_DESCRIPTION" desc="Description of about:flag option to launch the Files app in the legacy mode."> - Run Files app as an extension instead of a platform app. - </message> + <!-- File Manager --> <message name="IDS_FLAGS_FILE_MANAGER_LEGACY_UI_NAME" desc="Name of about:flag option to launch the Files app with the old ui."> Files.app's legacy UI </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index ac6ff17..98f78ae 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1045,13 +1045,6 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(ash::switches::kAshDisableNewLockAnimations), }, { - "file-manager-legacy", - IDS_FLAGS_FILE_MANAGER_LEGACY_NAME, - IDS_FLAGS_FILE_MANAGER_LEGACY_DESCRIPTION, - kOsCrOS, - SINGLE_VALUE_TYPE(chromeos::switches::kFileManagerLegacy), - }, - { "file-manager-legacy-ui", IDS_FLAGS_FILE_MANAGER_LEGACY_UI_NAME, IDS_FLAGS_FILE_MANAGER_LEGACY_UI_DESCRIPTION, diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 606a346..a0f750e 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -321,7 +321,6 @@ </if> <if expr="pp_ifdef('file_manager_extension')"> <include name="IDR_FILEMANAGER_MANIFEST" file="resources\file_manager\manifest.json" type="BINDATA" /> - <include name="IDR_FILEMANAGER_MANIFEST_V1" file="resources\file_manager\manifest_v1.json" type="BINDATA" /> <include name="IDR_FILEMANAGER_MANIFEST_NEW_UI" file="resources\file_manager\manifest_new_ui.json" type="BINDATA" /> </if> <if expr="pp_ifdef('image_loader_extension')"> diff --git a/chrome/browser/chromeos/extensions/file_manager/external_filesystem_apitest.cc b/chrome/browser/chromeos/extensions/file_manager/external_filesystem_apitest.cc index faeabf9..86f18ea 100644 --- a/chrome/browser/chromeos/extensions/file_manager/external_filesystem_apitest.cc +++ b/chrome/browser/chromeos/extensions/file_manager/external_filesystem_apitest.cc @@ -358,19 +358,11 @@ class DriveFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase { // // LocalFileSystemExtensionApiTests. // -IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v1.json"), - "", - FLAGS_NONE)) << message_; -} -IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, - FileSystemOperations_Packaged) { +IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "", FLAGS_NONE)) << message_; } @@ -383,20 +375,10 @@ IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileWatch) { FLAGS_NONE)) << message_; } -IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, - FileBrowserHandlers) { +IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileBrowserHandlers) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v1.json"), - "file_browser/file_browser_handler", - FLAGS_USE_FILE_HANDLER)) << message_; -} - -IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, - FileBrowserHandlers_Packaged) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "file_browser/file_browser_handler", FLAGS_USE_FILE_HANDLER)) << message_; } @@ -405,16 +387,7 @@ IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileBrowserHandlersLazy) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v1.json"), - "file_browser/file_browser_handler_lazy", - FLAGS_USE_FILE_HANDLER | FLAGS_LAZY_FILE_HANDLER)) << message_; -} - -IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, - FileBrowserHandlersLazy_Packaged) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "file_browser/file_browser_handler_lazy", FLAGS_USE_FILE_HANDLER | FLAGS_LAZY_FILE_HANDLER)) << message_; } @@ -422,7 +395,7 @@ IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, AppFileHandler) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "file_browser/app_file_handler", FLAGS_USE_FILE_HANDLER)) << message_; } @@ -434,16 +407,7 @@ IN_PROC_BROWSER_TEST_F(RestrictedFileSystemExtensionApiTest, FileSystemOperations) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v1.json"), - "", - FLAGS_NONE)) << message_; -} - -IN_PROC_BROWSER_TEST_F(RestrictedFileSystemExtensionApiTest, - FileSystemOperations_Packaged) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "", FLAGS_NONE)) << message_; } @@ -454,16 +418,7 @@ IN_PROC_BROWSER_TEST_F(RestrictedFileSystemExtensionApiTest, IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileSystemOperations) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v1.json"), - "", - FLAGS_NONE)) << message_; -} - -IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, - FileSystemOperations_Packaged) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/filesystem_operations_test", - FILE_PATH_LITERAL("manifests_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "", FLAGS_NONE)) << message_; } @@ -476,33 +431,14 @@ IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileWatch) { FLAGS_NONE)) << message_; } -IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, - FileBrowserHandlers) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v1.json"), - "file_browser/file_browser_handler", - FLAGS_USE_FILE_HANDLER)) << message_; -} - -IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, - FileBrowserHandlers_Packaged) { +IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileBrowserHandlers) { EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "file_browser/file_browser_handler", FLAGS_USE_FILE_HANDLER)) << message_; } -IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, - FileBrowserHandlersLazy) { - EXPECT_TRUE(RunFileSystemExtensionApiTest( - "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v1.json"), - "file_browser/file_browser_handler_lazy", - FLAGS_USE_FILE_HANDLER | FLAGS_LAZY_FILE_HANDLER)) << message_; -} - IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, Search) { // Configure the drive service to return only one search result at a time // to simulate paginated searches. @@ -518,7 +454,7 @@ IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, AppFileHandler) { fake_drive_service_->set_default_max_results(1); EXPECT_TRUE(RunFileSystemExtensionApiTest( "file_browser/handler_test_runner", - FILE_PATH_LITERAL("manifest_v2.json"), + FILE_PATH_LITERAL("manifest.json"), "file_browser/app_file_handler", FLAGS_USE_FILE_HANDLER)) << message_; } diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc index f75b313..6c42761 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc @@ -251,50 +251,6 @@ void OnCRXDownloadCallback(Browser* browser, InstallCRX(browser, file); } -// TODO(mtomasz): Remove this when dropping support for the legacy Files.app. -enum TAB_REUSE_MODE { - REUSE_ANY_FILE_MANAGER, - REUSE_SAME_PATH, - REUSE_NEVER -}; - -// TODO(mtomasz): Remove this when dropping support for the legacy Files.app. -bool FileManagerTabExists(const base::FilePath& path, TAB_REUSE_MODE mode) { - if (mode == REUSE_NEVER) - return false; - - // We always open full-tab File Manager via chrome://files URL, never - // chrome-extension://, so we only check against chrome://files - const GURL origin(chrome::kChromeUIFileManagerURL); - const std::string ref = std::string("/") + path.value(); - - // Check browser windows. - for (chrome::BrowserIterator it; !it.done(); it.Next()) { - Browser* browser = *it; - TabStripModel* tab_strip = browser->tab_strip_model(); - for (int idx = 0; idx < tab_strip->count(); idx++) { - content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); - const GURL& url = web_contents->GetURL(); - if (origin == url.GetOrigin()) { - if (mode == REUSE_ANY_FILE_MANAGER || ref == url.ref()) { - if (mode == REUSE_SAME_PATH && tab_strip->active_index() != idx) { - browser->window()->Show(); - tab_strip->ActivateTabAt(idx, false); - } - return true; - } - } - } - } - - return false; -} - -bool IsFileManagerPackaged() { - const CommandLine* command_line = CommandLine::ForCurrentProcess(); - return !command_line->HasSwitch(chromeos::switches::kFileManagerLegacy); -} - bool IsFileManagerNewUI() { const CommandLine* command_line = CommandLine::ForCurrentProcess(); return !command_line->HasSwitch(chromeos::switches::kFileManagerLegacyUI); @@ -342,64 +298,19 @@ void ExecuteHandler(Profile* profile, executor->Execute(urls); } -// The |mode| argument is only for legacy Files.app. Files.app V2 has the -// reusing logic in background.js. void OpenFileBrowserImpl(const base::FilePath& path, - TAB_REUSE_MODE mode, const std::string& action_id) { content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - if (IsFileManagerPackaged() && !path.value().empty()) { - GURL url; - if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) - return; - - // Some values of |action_id| are not listed in the manifest and are used - // to parametrize the behavior when opening the Files app window. - ExecuteHandler(profile, kFileBrowserDomain, action_id, url, - file_handler_util::kTaskFile); - return; - } - - if (FileManagerTabExists(path, mode)) - return; - - std::string url = chrome::kChromeUIFileManagerURL; - if (action_id.size()) { - DictionaryValue arg_value; - arg_value.SetString("action", action_id); - std::string query; - base::JSONWriter::Write(&arg_value, &query); - url += "?" + - net::EscapeUrlEncodedData(query, - false); // Space to %20 instead of +. - } - if (!path.empty()) { - base::FilePath virtual_path; - if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path, - &virtual_path)) - return; - url += "#/" + - net::EscapeUrlEncodedData(virtual_path.value(), - false); // Space to %20 instead of +. - } - - ExtensionService* service = - extensions::ExtensionSystem::Get(profile)->extension_service(); - if (!service) - return; - - const extensions::Extension* extension = - service->GetExtensionById(kFileBrowserDomain, false); - if (!extension) + GURL url; + if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) return; - chrome::AppLaunchParams params(profile, extension, - extension_misc::LAUNCH_WINDOW, - NEW_FOREGROUND_TAB); - params.override_url = GURL(url); - chrome::OpenApplication(params); + // Some values of |action_id| are not listed in the manifest and are used + // to parametrize the behavior when opening the Files app window. + ExecuteHandler(profile, kFileBrowserDomain, action_id, url, + file_handler_util::kTaskFile); } Browser* GetBrowserForUrl(GURL target_url) { @@ -489,27 +400,12 @@ bool ExecuteExtensionHandler(Profile* profile, return true; if (extension_id == kFileBrowserDomain) { - if (IsFileManagerPackaged()) { - if (action_id == kFileBrowserGalleryTaskId || - action_id == kFileBrowserMountArchiveTaskId || - action_id == kFileBrowserPlayTaskId || - action_id == kFileBrowserWatchTaskId) { - ExecuteHandler(profile, extension_id, action_id, url, - file_handler_util::kTaskFile); - return true; - } - return ExecuteBuiltinHandler(browser, path, action_id); - } - - // Only two of the built-in File Browser tasks require opening the File - // Browser tab. if (action_id == kFileBrowserGalleryTaskId || - action_id == kFileBrowserMountArchiveTaskId) { - // Tab reuse currently does not work for these two tasks. - // |gallery| tries to put the file url into the tab url but it does not - // work on Chrome OS. - // |mount-archive| does not even try. - OpenFileBrowserImpl(path, REUSE_SAME_PATH, ""); + action_id == kFileBrowserMountArchiveTaskId || + action_id == kFileBrowserPlayTaskId || + action_id == kFileBrowserWatchTaskId) { + ExecuteHandler(profile, extension_id, action_id, url, + file_handler_util::kTaskFile); return true; } return ExecuteBuiltinHandler(browser, path, action_id); @@ -572,7 +468,7 @@ void ContinueViewItem(Profile* profile, if (error == base::PLATFORM_FILE_OK) { // A directory exists at |path|. Open it with FileBrowser. - OpenFileBrowserImpl(path, REUSE_SAME_PATH, "open"); + OpenFileBrowserImpl(path, "open"); } else { if (!ExecuteDefaultHandler(profile, path)) ShowWarningMessageBox(profile, path); @@ -779,7 +675,7 @@ string16 GetTitleFromType(ui::SelectFileDialog::Type dialog_type) { } void ViewRemovableDrive(const base::FilePath& path) { - OpenFileBrowserImpl(path, REUSE_ANY_FILE_MANAGER, "auto-open"); + OpenFileBrowserImpl(path, "auto-open"); } void OpenNewWindow(Profile* profile, const GURL& url) { @@ -870,7 +766,7 @@ void ViewItem(const base::FilePath& path) { void ShowFileInFolder(const base::FilePath& path) { // This action changes the selection so we do not reuse existing tabs. - OpenFileBrowserImpl(path, REUSE_NEVER, "select"); + OpenFileBrowserImpl(path, "select"); } bool ExecuteBuiltinHandler(Browser* browser, const base::FilePath& path, @@ -911,40 +807,6 @@ bool ExecuteBuiltinHandler(Browser* browser, const base::FilePath& path, return true; } - if (!IsFileManagerPackaged()) { - if (internal_task_id == kFileBrowserPlayTaskId) { - GURL url; - if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) - return false; - MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); - mediaplayer->PopupMediaPlayer(); - mediaplayer->ForcePlayMediaURL(url); - return true; - } - if (internal_task_id == kFileBrowserWatchTaskId) { - GURL url; - if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) - return false; - - ExtensionService* service = - extensions::ExtensionSystem::Get(profile)->extension_service(); - if (!service) - return false; - - const extensions::Extension* extension = - service->GetExtensionById(kFileBrowserDomain, false); - if (!extension) - return false; - - chrome::AppLaunchParams params(profile, extension, - extension_misc::LAUNCH_WINDOW, - NEW_FOREGROUND_TAB); - params.override_url = GetVideoPlayerUrl(url); - chrome::OpenApplication(params); - return true; - } - } - if (IsCRXFile(file_extension.data())) { if (drive::util::IsUnderDriveMountPoint(path)) { drive::DriveIntegrationService* integration_service = diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index e180ad1..381b579 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -240,9 +240,7 @@ void ComponentLoader::AddFileManagerExtension() { #if defined(FILE_MANAGER_EXTENSION) const CommandLine* command_line = CommandLine::ForCurrentProcess(); int manifest_id; - if (command_line->HasSwitch(chromeos::switches::kFileManagerLegacy)) - manifest_id = IDR_FILEMANAGER_MANIFEST_V1; - else if (command_line->HasSwitch(chromeos::switches::kFileManagerLegacyUI)) + if (command_line->HasSwitch(chromeos::switches::kFileManagerLegacyUI)) manifest_id = IDR_FILEMANAGER_MANIFEST; else manifest_id = IDR_FILEMANAGER_MANIFEST_NEW_UI; diff --git a/chrome/browser/resources/file_manager/css/file_manager.css b/chrome/browser/resources/file_manager/css/file_manager.css index b43afcd..f6aee27 100644 --- a/chrome/browser/resources/file_manager/css/file_manager.css +++ b/chrome/browser/resources/file_manager/css/file_manager.css @@ -568,10 +568,6 @@ body[new-ui]:not([type='full-page']) .dialog-header #maximize-button { display: none; } -body[maximized][type='full-page'] .dialog-header { - -webkit-padding-end: 75px; -} - /* Container for the detail and thumbnail list views. */ body:not([new-ui]) .dialog-body { -webkit-box-flex: 1; diff --git a/chrome/browser/resources/file_manager/js/action_choice.js b/chrome/browser/resources/file_manager/js/action_choice.js index a1bd5bb..936d431 100644 --- a/chrome/browser/resources/file_manager/js/action_choice.js +++ b/chrome/browser/resources/file_manager/js/action_choice.js @@ -191,10 +191,6 @@ ActionChoice.prototype.initDom_ = function() { metrics.startInterval('PhotoImport.Load'); this.dom_.setAttribute('loading', ''); - - util.disableBrowserShortcutKeys(this.document_); - if (!util.platform.v2()) - util.enableNewFullScreenHandler(this.document_); }; /** @@ -428,13 +424,13 @@ ActionChoice.prototype.onKeyDown_ = function(e) { ActionChoice.prototype.runAction_ = function(action) { // TODO(mtomasz): Remove these predefined actions in Apps v2. if (action == this.importPhotosToDriveAction_) { - var url = util.platform.getURL('photo_import.html') + + var url = chrome.runtime.getURL('photo_import.html') + '#' + this.sourceEntry_.fullPath; var width = 728; var height = 656; var top = Math.round((window.screen.availHeight - height) / 2); var left = Math.round((window.screen.availWidth - width) / 2); - util.platform.createWindow(url, + chrome.app.window.create(url, {height: height, width: width, left: left, top: top}); this.recordAction_('import-photos-to-drive'); this.close_(); @@ -489,9 +485,8 @@ ActionChoice.prototype.acceptAction_ = function() { * @private */ ActionChoice.prototype.onDeviceUnmounted_ = function(event) { - if (this.sourceEntry_ && event.mountPath == this.sourceEntry_.fullPath) { - util.platform.closeWindow(); - } + if (this.sourceEntry_ && event.mountPath == this.sourceEntry_.fullPath) + window.close(); }; /** @@ -500,14 +495,9 @@ ActionChoice.prototype.onDeviceUnmounted_ = function(event) { */ ActionChoice.prototype.viewFiles_ = function() { var path = this.sourceEntry_.fullPath; - if (util.platform.v2()) { - chrome.runtime.getBackgroundPage(function(bg) { - bg.launchFileManager({defaultPath: path}); - }); - } else { - var url = util.platform.getURL('main.html') + '#' + path; - chrome.fileBrowserPrivate.openNewWindow(url); - } + chrome.runtime.getBackgroundPage(function(bg) { + bg.launchFileManager({defaultPath: path}); + }); }; /** diff --git a/chrome/browser/resources/file_manager/js/action_choice_util.js b/chrome/browser/resources/file_manager/js/action_choice_util.js index 0820b11..4d4a886 100644 --- a/chrome/browser/resources/file_manager/js/action_choice_util.js +++ b/chrome/browser/resources/file_manager/js/action_choice_util.js @@ -55,7 +55,7 @@ ActionChoiceUtil.getDefinedActions = function(loadTimeData, callback) { * @param {function(string=)} callback Callback with the identifier. */ ActionChoiceUtil.getRememberedActionId = function(callback) { - util.storage.local.get(['action-choice'], function(result) { + chrome.storage.local.get(['action-choice'], function(result) { callback(result['action-choice']); }); }; @@ -66,5 +66,5 @@ ActionChoiceUtil.getRememberedActionId = function(callback) { * the remembered choice. */ ActionChoiceUtil.setRememberedActionId = function(opt_actionId) { - util.storage.local.set({'action-choice': opt_actionId}); + chrome.storage.local.set({'action-choice': opt_actionId}); }; diff --git a/chrome/browser/resources/file_manager/js/drive_banners.js b/chrome/browser/resources/file_manager/js/drive_banners.js index e3e183c..d439497 100644 --- a/chrome/browser/resources/file_manager/js/drive_banners.js +++ b/chrome/browser/resources/file_manager/js/drive_banners.js @@ -38,10 +38,10 @@ function FileListBannerController( this.volumeManager_.addEventListener('drive-connection-changed', this.onDriveConnectionChanged_.bind(this)); - util.storage.onChanged.addListener(this.onStorageChange_.bind(this)); + chrome.storage.onChanged.addListener(this.onStorageChange_.bind(this)); this.welcomeHeaderCounter_ = WELCOME_HEADER_COUNTER_LIMIT; this.warningDismissedCounter_ = 0; - util.storage.local.get([WELCOME_HEADER_COUNTER_KEY, WARNING_DISMISSED_KEY], + chrome.storage.local.get([WELCOME_HEADER_COUNTER_KEY, WARNING_DISMISSED_KEY], function(values) { this.welcomeHeaderCounter_ = parseInt(values[WELCOME_HEADER_COUNTER_KEY]) || 0; @@ -128,7 +128,7 @@ FileListBannerController.prototype.initializeWelcomeBanner_ = function() { FileListBannerController.prototype.setWelcomeHeaderCounter_ = function(value) { var values = {}; values[WELCOME_HEADER_COUNTER_KEY] = value; - util.storage.local.set(values); + chrome.storage.local.set(values); }; /** @@ -139,11 +139,11 @@ FileListBannerController.prototype.setWarningDismissedCounter_ = function(value) { var values = {}; values[WARNING_DISMISSED_KEY] = value; - util.storage.local.set(values); + chrome.storage.local.set(values); }; /** - * util.storage.onChanged event handler. + * chrome.storage.onChanged event handler. * @param {Object.<string, Object>} changes Changes values. * @param {string} areaName "local" or "sync". * @private diff --git a/chrome/browser/resources/file_manager/js/file_copy_manager.js b/chrome/browser/resources/file_manager/js/file_copy_manager.js index 0a431aa..fef1ffa7 100644 --- a/chrome/browser/resources/file_manager/js/file_copy_manager.js +++ b/chrome/browser/resources/file_manager/js/file_copy_manager.js @@ -345,10 +345,8 @@ FileCopyManager.prototype.hasQueuedTasks = function() { */ FileCopyManager.prototype.maybeScheduleCloseBackgroundPage_ = function() { if (!this.hasQueuedTasks()) { - if (this.unloadTimeout_ === null) { - this.unloadTimeout_ = setTimeout( - util.platform.v2() ? maybeCloseBackgroundPage : close, 5000); - } + if (this.unloadTimeout_ === null) + this.unloadTimeout_ = setTimeout(maybeCloseBackgroundPage, 5000); } else if (this.unloadTimeout_) { clearTimeout(this.unloadTimeout_); this.unloadTimeout_ = null; diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index e01f7f1..9e2b7e5 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -420,12 +420,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; self.onResize_.bind(self)); }); - if (!util.platform.v2()) { - window.addEventListener('popstate', this.onPopState_.bind(this)); - window.addEventListener('unload', this.onUnload_.bind(this)); - window.addEventListener('beforeunload', this.onBeforeUnload_.bind(this)); - } - var dm = this.directoryModel_; dm.addEventListener('directory-changed', this.onDirectoryChanged_.bind(this)); @@ -904,7 +898,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; // Show the window as soon as the UI pre-initialization is done. if (this.dialogType == DialogType.FULL_PAGE && - util.platform.v2() && !util.platform.runningInBrowser()) { chrome.app.window.current().show(); setTimeout(callback, 100); // Wait until the animation is finished. @@ -1150,14 +1143,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; this.fileTypeSelector_ = this.dialogDom_.querySelector('#file-type'); this.initFileTypeFilter_(); - util.disableBrowserShortcutKeys(this.document_); - - if (!util.platform.v2()) - util.enableNewFullScreenHandler(this.document_); - else - util.addIsFocusedMethod(); - - this.updateWindowState_(); + util.addIsFocusedMethod(); // Populate the static localized strings. i18nTemplate.process(this.document_, loadTimeData); @@ -1631,16 +1617,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; }; /** - * Respond to the back and forward buttons. - * @param {Event} event Pop state event. - * @private - */ - FileManager.prototype.onPopState_ = function(event) { - this.closeFilePopup_(); - this.setupCurrentDirectory_(false /* page loading */); - }; - - /** * Resize details and thumb views to fit the new window size. * @private */ @@ -1668,8 +1644,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; } this.searchBreadcrumbs_.truncate(); - - this.updateWindowState_(); }; /** @@ -1719,19 +1693,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; return this.cachedPreviewPanelHeight_; }; - /** - * @private - */ - FileManager.prototype.updateWindowState_ = function() { - util.platform.getWindowStatus(function(wnd) { - if (wnd.state == 'maximized') { - this.dialogDom_.setAttribute('maximized', 'maximized'); - } else { - this.dialogDom_.removeAttribute('maximized'); - } - }.bind(this)); - }; - FileManager.prototype.resolvePath = function( path, resultCallback, errorCallback) { return util.resolvePath(this.filesystem_.root, path, resultCallback, @@ -2066,8 +2027,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; /** * Overrides default handling for clicks on hyperlinks. - * Opens them in a separate tab and if it's an open/save dialog - * closes it. + * In a packaged apps links with targer='_blank' open in a new tab by + * default, other links do not open at all. * * @param {Event} event Click event. * @private @@ -2076,16 +2037,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; if (event.target.tagName != 'A' || !event.target.href) return; - // In a packaged apps links with targer='_blank' open in a new tab by - // default, other links do not open at all. - if (!util.platform.v2()) { - chrome.tabs.create({url: event.target.href}); - event.preventDefault(); - } - - if (this.dialogType != DialogType.FULL_PAGE) { + if (this.dialogType != DialogType.FULL_PAGE) this.onCancel_(); - } }; /** @@ -2226,8 +2179,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; if (this.closeOnUnmount_) { // If the file manager opened automatically when a usb drive inserted, // user have never changed current volume (that implies the current - // directory is still on the device) then close this tab. - util.platform.closeWindow(); + // directory is still on the device) then close this window. + window.close(); } } }; @@ -2462,7 +2415,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; }; /** - * Update the tab title. + * Update the window title. * @private */ FileManager.prototype.updateTitle_ = function() { @@ -2549,7 +2502,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; if (this.dialogType == DialogType.FULL_PAGE) this.table_.showOfflineColumn(this.shouldShowOfflineColumn()); - util.updateAppState(event.initial, this.getCurrentDirectory()); + util.updateAppState(this.getCurrentDirectory()); if (this.closeOnUnmount_ && !event.initial && PathUtil.getRootPath(event.previousDirEntry.fullPath) != diff --git a/chrome/browser/resources/file_manager/js/file_manager_commands.js b/chrome/browser/resources/file_manager/js/file_manager_commands.js index c18cb20..06297ea 100644 --- a/chrome/browser/resources/file_manager/js/file_manager_commands.js +++ b/chrome/browser/resources/file_manager/js/file_manager_commands.js @@ -218,12 +218,7 @@ Commands.importCommand = { if (!root) return; - chrome.windows.getCurrent(undefined, function(window) { - chrome.windows.create( - { url: chrome.extension.getURL('photo_import.html') + - '?' + window.id + '#' + PathUtil.getRootPath(root.fullPath), - type: 'popup' }); - }.bind(this)); + // TODO(mtomasz): Implement launching Photo Importer. }, /** * @param {Event} event Command event. diff --git a/chrome/browser/resources/file_manager/js/file_tasks.js b/chrome/browser/resources/file_manager/js/file_tasks.js index 7b3d3e3..d61b249 100644 --- a/chrome/browser/resources/file_manager/js/file_tasks.js +++ b/chrome/browser/resources/file_manager/js/file_tasks.js @@ -143,7 +143,7 @@ FileTasks.recordViewingFileTypeUMA_ = function(urls) { */ FileTasks.prototype.processTasks_ = function(tasks) { this.tasks_ = []; - var id = util.platform.getAppId(); + var id = chrome.runtime.id; var isOnDrive = false; for (var index = 0; index < this.urls_.length; ++index) { if (FileType.isOnDrive(this.urls_[index])) { @@ -314,7 +314,7 @@ FileTasks.prototype.execute_ = function(taskId, opt_urls) { FileTasks.prototype.executeInternal_ = function(taskId, urls) { this.checkAvailability_(function() { var taskParts = taskId.split('|'); - if (taskParts[0] == util.platform.getAppId() && taskParts[1] == 'file') { + if (taskParts[0] == chrome.runtime.id && taskParts[1] == 'file') { // For internal tasks we do not listen to the event to avoid // handling the same task instance from multiple tabs. // So, we manually execute the task. @@ -413,24 +413,18 @@ FileTasks.prototype.executeInternalTask_ = function(id, urls) { urls = fm.getAllUrlsInCurrentDirectory().filter(FileType.isAudio); position = urls.indexOf(selectedUrl); } - if (util.platform.v2()) { - chrome.runtime.getBackgroundPage(function(background) { - background.launchAudioPlayer({ items: urls, position: position }); - }); - } else { - chrome.mediaPlayerPrivate.play(urls, position); - } + chrome.runtime.getBackgroundPage(function(background) { + background.launchAudioPlayer({ items: urls, position: position }); + }); return; } - if (util.platform.v2()) { - if (id == 'watch') { - console.assert(urls.length == 1, 'Cannot open multiple videos'); - chrome.runtime.getBackgroundPage(function(background) { - background.launchVideoPlayer(urls[0]); - }); - return; - } + if (id == 'watch') { + console.assert(urls.length == 1, 'Cannot open multiple videos'); + chrome.runtime.getBackgroundPage(function(background) { + background.launchVideoPlayer(urls[0]); + }); + return; } if (id == 'mount-archive') { @@ -456,7 +450,6 @@ FileTasks.prototype.executeInternalTask_ = function(id, urls) { if (!success) console.error('chrome.fileBrowserPrivate.viewFiles failed', urls); }); - return; } }; @@ -528,8 +521,7 @@ FileTasks.prototype.openGalleryInternal_ = function(urls) { if (this.params_ && this.params_.gallery) { // Remove the Gallery state from the location, we do not need it any more. - util.updateAppState( - true /* replace */, null /* keep path */, '' /* remove search. */); + util.updateAppState(null /* keep path */, '' /* remove search. */); } var savedAppState = window.appState; @@ -537,18 +529,14 @@ FileTasks.prototype.openGalleryInternal_ = function(urls) { // Push a temporary state which will be replaced every time the selection // changes in the Gallery and popped when the Gallery is closed. - util.updateAppState(false /*push*/); + util.updateAppState(); var onBack = function(selectedUrls) { fm.directoryModel_.selectUrls(selectedUrls); - if (util.platform.v2()) { - fm.closeFilePopup_(); // Will call Gallery.unload. - window.appState = savedAppState; - util.saveAppState(); - document.title = savedTitle; - } else { - window.history.back(1); // This will restore document.title. - } + fm.closeFilePopup_(); // Will call Gallery.unload. + window.appState = savedAppState; + util.saveAppState(); + document.title = savedTitle; }; var onClose = function() { @@ -585,7 +573,7 @@ FileTasks.prototype.openGalleryInternal_ = function(urls) { searchResults: fm.directoryModel_.isSearching(), metadataCache: fm.metadataCache_, pageState: this.params_, - appWindow: util.platform.v2() ? chrome.app.window.current() : null, + appWindow: chrome.app.window.current(), onBack: onBack, onClose: onClose, onMaximize: onMaximize, diff --git a/chrome/browser/resources/file_manager/js/media/audio_player.js b/chrome/browser/resources/file_manager/js/media/audio_player.js index 049cd64..a6abf9d 100644 --- a/chrome/browser/resources/file_manager/js/media/audio_player.js +++ b/chrome/browser/resources/file_manager/js/media/audio_player.js @@ -31,9 +31,6 @@ function AudioPlayer(container) { this.trackList_ = createChild('track-list'); this.trackStack_ = createChild('track-stack'); - if (!util.platform.v2()) - window.addEventListener('unload', unload); - createChild('title-button collapse').addEventListener( 'click', this.onExpandCollapse_.bind(this)); @@ -231,7 +228,7 @@ AudioPlayer.prototype.onExternallyUnmounted_ = function(event) { if (!this.selectedItemFilesystemPath_) return; if (this.selectedItemFilesystemPath_.indexOf(event.mountPath) == 0) - util.platform.closeWindow(); + close(); }; /** @@ -457,18 +454,13 @@ AudioPlayer.prototype.syncHeight_ = function() { AudioPlayer.TRACK_HEIGHT : AudioPlayer.HEADER_HEIGHT + expandedListHeight); - if (util.platform.v2()) { - var appWindow = chrome.app.window.current(); - var oldHeight = appWindow.contentWindow.outerHeight; - var bottom = appWindow.contentWindow.screenY + oldHeight; - var newTop = Math.max(0, bottom - targetClientHeight); - appWindow.moveTo(appWindow.contentWindow.screenX, newTop); - appWindow.resizeTo(appWindow.contentWindow.outerWidth, - oldHeight + targetClientHeight - this.container_.clientHeight); - } else { - chrome.mediaPlayerPrivate.setWindowHeight( - targetClientHeight - this.container_.clientHeight); - } + var appWindow = chrome.app.window.current(); + var oldHeight = appWindow.contentWindow.outerHeight; + var bottom = appWindow.contentWindow.screenY + oldHeight; + var newTop = Math.max(0, bottom - targetClientHeight); + appWindow.moveTo(appWindow.contentWindow.screenX, newTop); + appWindow.resizeTo(appWindow.contentWindow.outerWidth, + oldHeight + targetClientHeight - this.container_.clientHeight); }; @@ -580,10 +572,6 @@ function FullWindowAudioControls(container, advanceTrack, onError) { e.preventDefault(); } }.bind(this)); - - util.disableBrowserShortcutKeys(document); - if (!util.platform.v2()) - util.enableNewFullScreenHandler(document); } FullWindowAudioControls.prototype = { __proto__: AudioControls.prototype }; diff --git a/chrome/browser/resources/file_manager/js/media/media_controls.js b/chrome/browser/resources/file_manager/js/media/media_controls.js index 7eeeb1f..670900d 100644 --- a/chrome/browser/resources/file_manager/js/media/media_controls.js +++ b/chrome/browser/resources/file_manager/js/media/media_controls.js @@ -1067,7 +1067,7 @@ VideoControls.prototype.savePosition = function(opt_sync) { Math.max(0, this.media_.currentTime - VideoControls.RESUME_REWIND)); } - if (opt_sync && util.platform.v2()) { + if (opt_sync) { // Packaged apps cannot save synchronously. // Pass the data to the background page. if (!window.saveOnExit) diff --git a/chrome/browser/resources/file_manager/js/media/video_player.js b/chrome/browser/resources/file_manager/js/media/video_player.js index 7879dbb..8354419 100644 --- a/chrome/browser/resources/file_manager/js/media/video_player.js +++ b/chrome/browser/resources/file_manager/js/media/video_player.js @@ -13,10 +13,9 @@ function showErrorMessage(message) { errorBanner.textContent = loadTimeData.getString(message); errorBanner.setAttribute('visible', 'true'); - if (util.platform.v2()) { - // The window is hidden if the video has not loaded yet. - chrome.app.window.current().show(); - } + + // The window is hidden if the video has not loaded yet. + chrome.app.window.current().show(); } /** @@ -66,16 +65,12 @@ function FullWindowVideoControls( } if (e.keyIdentifier == 'U+001B') { // Escape util.toggleFullScreen( - util.platform.v2() ? chrome.app.window.current() : null, + chrome.app.window.current(), false); // Leave the full screen mode. e.preventDefault(); } }.bind(this)); - util.disableBrowserShortcutKeys(document); - if (!util.platform.v2()) - util.enableNewFullScreenHandler(document); - videoContainer.addEventListener('click', this.togglePlayStateWithFeedback.bind(this)); @@ -111,7 +106,7 @@ FullWindowVideoControls.prototype.restorePlayState = function() { * @private */ FullWindowVideoControls.prototype.toggleFullScreen_ = function() { - var appWindow = util.platform.v2() ? chrome.app.window.current() : null; + var appWindow = chrome.app.window.current(); util.toggleFullScreen(appWindow, !util.isFullScreen(appWindow)); }; @@ -137,9 +132,6 @@ function loadVideoPlayer() { document.querySelector('#video-container'), document.querySelector('#controls')); - if (!util.platform.v2()) - window.addEventListener('unload', unload); - metadataCache = MetadataCache.createFull(); volumeManager = VolumeManager.getInstance(); @@ -171,7 +163,7 @@ function onExternallyUnmounted(event) { if (!selectedItemFilesystemPath) return; if (selectedItemFilesystemPath.indexOf(event.mountPath) == 0) - util.platform.closeWindow(); + window.close(); } /** @@ -223,45 +215,43 @@ function reload() { video.src = src; video.load(); - if (util.platform.v2()) { - video.addEventListener('loadedmetadata', function() { - // TODO: chrome.app.window soon will be able to resize the content area. - // Until then use approximate title bar height. - var TITLE_HEIGHT = 28; - - var aspect = video.videoWidth / video.videoHeight; - var newWidth = video.videoWidth; - var newHeight = video.videoHeight + TITLE_HEIGHT; - - var shrinkX = newWidth / window.screen.availWidth; - var shrinkY = newHeight / window.screen.availHeight; - if (shrinkX > 1 || shrinkY > 1) { - if (shrinkY > shrinkX) { - newHeight = newHeight / shrinkY; - newWidth = (newHeight - TITLE_HEIGHT) * aspect; - } else { - newWidth = newWidth / shrinkX; - newHeight = newWidth / aspect + TITLE_HEIGHT; - } + video.addEventListener('loadedmetadata', function() { + // TODO: chrome.app.window soon will be able to resize the content area. + // Until then use approximate title bar height. + var TITLE_HEIGHT = 28; + + var aspect = video.videoWidth / video.videoHeight; + var newWidth = video.videoWidth; + var newHeight = video.videoHeight + TITLE_HEIGHT; + + var shrinkX = newWidth / window.screen.availWidth; + var shrinkY = newHeight / window.screen.availHeight; + if (shrinkX > 1 || shrinkY > 1) { + if (shrinkY > shrinkX) { + newHeight = newHeight / shrinkY; + newWidth = (newHeight - TITLE_HEIGHT) * aspect; + } else { + newWidth = newWidth / shrinkX; + newHeight = newWidth / aspect + TITLE_HEIGHT; } + } - var oldLeft = window.screenX; - var oldTop = window.screenY; - var oldWidth = window.outerWidth; - var oldHeight = window.outerHeight; + var oldLeft = window.screenX; + var oldTop = window.screenY; + var oldWidth = window.outerWidth; + var oldHeight = window.outerHeight; - if (!oldWidth && !oldHeight) { - oldLeft = window.screen.availWidth / 2; - oldTop = window.screen.availHeight / 2; - } + if (!oldWidth && !oldHeight) { + oldLeft = window.screen.availWidth / 2; + oldTop = window.screen.availHeight / 2; + } - var appWindow = chrome.app.window.current(); - appWindow.resizeTo(newWidth, newHeight); - appWindow.moveTo(oldLeft - (newWidth - oldWidth) / 2, - oldTop - (newHeight - oldHeight) / 2); - appWindow.show(); - }); - } + var appWindow = chrome.app.window.current(); + appWindow.resizeTo(newWidth, newHeight); + appWindow.moveTo(oldLeft - (newWidth - oldWidth) / 2, + oldTop - (newHeight - oldHeight) / 2); + appWindow.show(); + }); // Resolve real filesystem path of the current video. selectedItemFilesystemPath = null; diff --git a/chrome/browser/resources/file_manager/js/photo/gallery.js b/chrome/browser/resources/file_manager/js/photo/gallery.js index a4d6549..83ffbe2 100644 --- a/chrome/browser/resources/file_manager/js/photo/gallery.js +++ b/chrome/browser/resources/file_manager/js/photo/gallery.js @@ -99,7 +99,7 @@ Gallery.openStandalone = function(path, pageState, opt_callback) { var currentDir; var urls = []; var selectedUrls = []; - var appWindow = util.platform.v2() ? chrome.app.window.current() : null; + var appWindow = chrome.app.window.current(); Gallery.getFileBrowserPrivate().requestFileSystem(function(filesystem) { // If the path points to the directory scan it. @@ -206,10 +206,6 @@ Gallery.prototype.initListeners_ = function() { this.keyDownBound_ = this.onKeyDown_.bind(this); this.document_.body.addEventListener('keydown', this.keyDownBound_); - util.disableBrowserShortcutKeys(this.document_); - if (!util.platform.v2()) - util.enableNewFullScreenHandler(this.document_); - this.inactivityWatcher_ = new MouseInactivityWatcher( this.container_, Gallery.FADE_TIMEOUT, this.hasActiveTool.bind(this)); @@ -753,10 +749,9 @@ Gallery.prototype.updateSelectionAndState_ = function() { this.displayStringFunction_('ITEMS_SELECTED', selectedItems.length); } - window.top.util.updateAppState(true /*replace*/, path, + window.top.util.updateAppState(path, {gallery: (this.currentMode_ == this.mosaicMode_ ? 'mosaic' : 'slide')}); - // We can't rename files in readonly directory. // We can only rename a single file. this.filenameEdit_.disabled = selectedItems.length != 1 || @@ -904,10 +899,9 @@ Gallery.prototype.toggleShare_ = function() { Gallery.prototype.updateShareMenu_ = function() { var urls = this.getSelectedUrls(); - var internalId = util.platform.getAppId(); function isShareAction(task) { var taskParts = task.taskId.split('|'); - return taskParts[0] != internalId; + return taskParts[0] != chrome.runtime.id; } var api = Gallery.getFileBrowserPrivate(); diff --git a/chrome/browser/resources/file_manager/js/photo/importing_dialog.js b/chrome/browser/resources/file_manager/js/photo/importing_dialog.js index 0e8cf08..dde1695 100644 --- a/chrome/browser/resources/file_manager/js/photo/importing_dialog.js +++ b/chrome/browser/resources/file_manager/js/photo/importing_dialog.js @@ -149,13 +149,13 @@ ImportingDialog.prototype.onOkClick_ = function() { * @private */ ImportingDialog.prototype.onViewClick_ = function() { - var url = util.platform.getURL('main.html') + + var url = chrome.runtime.getURL('main.html') + '?{%22gallery%22:%22mosaic%22}#' + this.destination_.fullPath; if (!this.parentWindowId_ || !util.redirectMainWindow(this.parentWindowId_, url)) { // The parent window hasn't been found. Launch the url as a new window. // TODO(mtomasz): Change it to chrome.fileBrowserPrivate.openNewWindow. - util.platform.createWindow(url); + chrome.app.window.create(url); } this.hide(); window.close(); diff --git a/chrome/browser/resources/file_manager/js/util.js b/chrome/browser/resources/file_manager/js/util.js index cd267ec..714571e 100644 --- a/chrome/browser/resources/file_manager/js/util.js +++ b/chrome/browser/resources/file_manager/js/util.js @@ -703,54 +703,22 @@ util.createChild = function(parent, opt_className, opt_tag) { /** * Update the app state. - * For app v1 use the top window location search query and hash. - * For app v2 use the top window appState variable. * - * @param {boolean} replace True if the history state should be replaced, - * false if pushed. * @param {string} path Path to be put in the address bar after the hash. * If null the hash is left unchanged. * @param {string|Object=} opt_param Search parameter. Used directly if string, * stringified if object. If omitted the search query is left unchanged. */ -util.updateAppState = function(replace, path, opt_param) { - if (util.platform.v2()) { - window.appState = window.appState || {}; - // |replace| parameter is ignored. There is no stack, so saving/restoring - // the state is the apps responsibility. - if (typeof opt_param == 'string') - window.appState.params = {}; - else if (typeof opt_param == 'object') - window.appState.params = opt_param; - if (path) - window.appState.defaultPath = path; - util.saveAppState(); - return; - } - - var location = document.location; - - var search; +util.updateAppState = function(path, opt_param) { + window.appState = window.appState || {}; if (typeof opt_param == 'string') - search = opt_param; + window.appState.params = {}; else if (typeof opt_param == 'object') - search = '?' + JSON.stringify(opt_param); - else - search = location.search; - - var hash; + window.appState.params = opt_param; if (path) - hash = '#' + encodeURIComponent(path); - else - hash = location.hash; - - var newLocation = location.origin + location.pathname + search + hash; - //TODO(kaznacheev): Fix replaceState for component extensions. Currently it - //does not replace the content of the address bar. - if (replace) - window.history.replaceState(undefined, path, newLocation); - else - window.history.pushState(undefined, path, newLocation); + window.appState.defaultPath = path; + util.saveAppState(); + return; }; /** @@ -783,24 +751,14 @@ function strf(id, var_args) { /** * Adapter object that abstracts away the the difference between Chrome app APIs * v1 and v2. Is only necessary while the migration to v2 APIs is in progress. + * TODO(mtomasz): Clean up this. crbug.com/240606. */ util.platform = { /** - * @return {boolean} True for v2. - */ - v2: function() { - try { - return !!(chrome.app && chrome.app.runtime); - } catch (e) { - return false; - } - }, - - /** * @return {boolean} True if Files.app is running via "chrome://files". */ runningInBrowser: function() { - return util.platform.v2() && !window.appID; + return !window.appID; }, /** @@ -818,11 +776,7 @@ util.platform = { * @param {function(Object)} callback Function accepting a preference map. */ getPreferences: function(callback) { - try { - callback(window.localStorage); - } catch (ignore) { - chrome.storage.local.get(callback); - } + chrome.storage.local.get(callback); }, /** @@ -830,13 +784,9 @@ util.platform = { * @param {function(string)} callback Function accepting the preference value. */ getPreference: function(key, callback) { - try { - callback(window.localStorage[key]); - } catch (ignore) { - chrome.storage.local.get(key, function(items) { - callback(items[key]); - }); - } + chrome.storage.local.get(key, function(items) { + callback(items[key]); + }); }, /** @@ -848,164 +798,12 @@ util.platform = { if (typeof value != 'string') value = JSON.stringify(value); - try { - window.localStorage[key] = value; - if (opt_callback) opt_callback(); - } catch (ignore) { - var items = {}; - items[key] = value; - chrome.storage.local.set(items, opt_callback); - } - }, - - /** - * @param {function(Object)} callback Function accepting a status object. - */ - getWindowStatus: function(callback) { - try { - chrome.windows.getCurrent(callback); - } catch (ignore) { - // TODO: fill the status object once the API is available. - callback({}); - } - }, - - /** - * Close current window. - */ - closeWindow: function() { - if (util.platform.v2()) { - window.close(); - } else { - chrome.tabs.getCurrent(function(tab) { - chrome.tabs.remove(tab.id); - }); - } - }, - - /** - * @return {string} Applicaton id. - */ - getAppId: function() { - if (util.platform.v2()) { - return chrome.runtime.id; - } else { - return chrome.extension.getURL('').split('/')[2]; - } - }, - - /** - * @param {string} path Path relative to the extension root. - * @return {string} Extension-based URL. - */ - getURL: function(path) { - if (util.platform.v2()) { - return chrome.runtime.getURL(path); - } else { - return chrome.extension.getURL(path); - } - }, - - /** - * Suppress default context menu in a current window. - */ - suppressContextMenu: function() { - // For packed v2 apps the default context menu would not show until - // --debug-packed-apps is added to the command line. - // For unpacked v2 apps (used for debugging) it is ok to show the menu. - if (util.platform.v2()) - return; - - document.addEventListener('contextmenu', - function(e) { e.preventDefault() }); - }, - - /** - * Creates a new window. - * @param {string} url Window url. - * @param {Object} options Window options. - */ - createWindow: function(url, options) { - if (util.platform.v2()) { - chrome.app.window.create(url, options); - } else { - var params = {}; - for (var key in options) { - if (options.hasOwnProperty(key)) { - params[key] = options[key]; - } - } - params.url = url; - params.type = 'popup'; - chrome.windows.create(params); - } + var items = {}; + items[key] = value; + chrome.storage.local.set(items, opt_callback); } }; -// TODO(serya): remove it when have migrated to AppsV2. -util.__defineGetter__('storage', function() { - delete util.storage; - if (chrome.storage) { - util.storage = chrome.storage; - return util.storage; - } - - var listeners = []; - - function StorageArea(type) { - this.type_ = type; - } - - StorageArea.prototype.set = function(items, opt_callback) { - var changes = {}; - for (var i in items) { - changes[i] = {oldValue: window.localStorage[i], newValue: items[i]}; - window.localStorage[i] = items[i]; - } - if (opt_callback) - opt_callback(); - for (var i = 0; i < listeners.length; i++) { - listeners[i](changes, this.type_); - } - }; - - StorageArea.prototype.get = function(keys, callback) { - if (!callback) { - // Since key is optionsl it's the callback. - keys(window.localStorage); - return; - } - if (typeof(keys) == 'string') - keys = [keys]; - var result = {}; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - result[key] = window.localStorage[key]; - } - callback(result); - }; - - /** - * Simulation of the AppsV2 storage interface. - * @type {Object} - */ - util.storage = { - local: new StorageArea('local'), - sync: new StorageArea('sync'), - onChanged: { - addListener: function(l) { - listeners.push(l); - }, - removeListener: function(l) { - for (var i = 0; i < listeners.length; i++) { - listeners.splice(i, 1); - } - } - } - }; - return util.storage; -}); - /** * Attach page load handler. * @param {function} handler Application-specific load handler. @@ -1013,12 +811,11 @@ util.__defineGetter__('storage', function() { util.addPageLoadHandler = function(handler) { document.addEventListener('DOMContentLoaded', function() { handler(); - util.platform.suppressContextMenu(); }); }; /** - * Save app v2 launch data to the local storage. + * Save app launch data to the local storage. */ util.saveAppState = function() { if (window.appState) @@ -1217,21 +1014,6 @@ util.boardIs = function(boardPrefix) { }; /** - * Disabled browser shortcus key events on the given document. - * @param {Element} element Element to be disabled browser shortcut keys on. - */ -util.disableBrowserShortcutKeys = function(element) { - element.addEventListener('keydown', function(e) { - switch (util.getKeyModifiers(e) + e.keyCode) { - case 'Ctrl-79': // Disable native Ctrl-O (open file). - case 'Ctrl-83': // Disable native Ctrl-S (save as). - case 'Ctrl-85': // Disable native Ctrl-U (view source). - e.preventDefault(); - } - }); -}; - -/** * Adds an isFocused method to the current window object. */ util.addIsFocusedMethod = function() { @@ -1254,92 +1036,48 @@ util.addIsFocusedMethod = function() { }; /** - * Enables the new full screen mode handler. This works only for Apps v1. - * TODO(mtomasz): Remove after dropping support for Files.app V1. - * - * @param {Document} doc Document element. - */ -util.enableNewFullScreenHandler = function(doc) { - doc.addEventListener('keydown', function(e) { - if (util.getKeyModifiers(e) + e.keyCode == '122' /* F11 */) { - util.toggleFullScreen(null, !util.isFullScreen(null)); - e.preventDefault(); - } - }); -}; - -/** * Makes a redirect to the specified Files.app's window from another window. * @param {number} id Window id. * @param {string} url Target url. * @return {boolean} True if the window has been found. False otherwise. */ util.redirectMainWindow = function(id, url) { - var windowViews = chrome.extension.getViews({ windowId: parseInt(id) }); - if (!windowViews || windowViews.length === 0) - return false; - - windowViews[0].location.href = url; - return true; + // TODO(mtomasz): Implement this for Apps V2, once the photo importer is + // restored. + return false; }; /** * Checks, if the Files.app's window is in a full screen mode. - * TODO(mtomasz): Clean up after dropping support for Files.app V1. * - * @param {AppWindow} appWindow App window to be maximized. (V2 only). - * For V1 pass NULL. + * @param {AppWindow} appWindow App window to be maximized. * @return {boolean} True if the full screen mode is enabled. */ util.isFullScreen = function(appWindow) { - if (util.platform.v2()) { - if (appWindow) { - return appWindow.isFullscreen(); - } else { - console.error('App window not passed. Unable to check status of ' + - 'the full screen mode.'); - return false; - } - } - - // TODO(mtomasz): Remove after dropping support for V1. - if (document.webkitIsFullScreen) - return true; - - // Check the parent if in a iframe. - if (window.parent != window && - window.parent.document.webkitIsFullScreen) { - return true; + if (appWindow) { + return appWindow.isFullscreen(); + } else { + console.error('App window not passed. Unable to check status of ' + + 'the full screen mode.'); + return false; } - - return false; }; /** * Toggles the full screen mode. - * TODO(mtomasz): Clean up after dropping support for Files.app V1. * - * @param {AppWindow} appWindow App window to be maximized. (V2 only). - * For V1 pass NULL. + * @param {AppWindow} appWindow App window to be maximized. * @param {boolean} enabled True for enabling, false for disabling. */ util.toggleFullScreen = function(appWindow, enabled) { - if (util.platform.v2()) { - if (appWindow) { - if (enabled) - appWindow.fullscreen(); - else - appWindow.restore(); - return; - } - - console.error( - 'App window not passed. Unable to toggle the full screen mode.'); + if (appWindow) { + if (enabled) + appWindow.fullscreen(); + else + appWindow.restore(); return; } - if (!enabled) - document.webkitCancelFullScreen(); - else - document.body.webkitRequestFullScreen(); + console.error( + 'App window not passed. Unable to toggle the full screen mode.'); }; diff --git a/chrome/browser/resources/file_manager/manifest_v1.json b/chrome/browser/resources/file_manager/manifest_v1.json deleted file mode 100644 index 123a1e9..0000000 --- a/chrome/browser/resources/file_manager/manifest_v1.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - // chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/ - "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDlhpGghtnNJ7pluQN0RDwbUxwwi99oM35ZEaFYvxPLrf0fIEC18cfDdJi6u4aJ+UoSpgzK731L0P/k4LvK2Rz9kVKOy0+IvuRrWkT7lbrLfA1UEBh02OA1AAshjmyRg4IxCqgl8ia8XWq6HKegS1y1KXZYGgb4qp7Bh9VC4cIzswIBIw==", - "name": "Files", - "version": "0.1", - "description": "File Manager", - "incognito" : "split", - "icons": { - "16": "images/icon16.png", - "128": "images/icon128.png" - }, - "permissions": [ - "fileBrowserHandler", - "fileBrowserPrivate", - "fullscreen", - "mediaPlayerPrivate", - "mediaGalleriesPrivate", - "metricsPrivate", - "unlimitedStorage", - "chrome://extension-icon/", - "chrome://resources/", - "chrome://theme/", - "tabs", - "clipboardWrite", - "clipboardRead", - "https://*.googleusercontent.com/", - "https://drive.google.com/" - ], - // chrome-extension://pmfjbimdmchhbnneeidfognadeopoehp is the image loader extension. - "content_security_policy": "default-src 'none'; script-src 'self' chrome://resources chrome-extension://pmfjbimdmchhbnneeidfognadeopoehp; style-src 'self' 'unsafe-inline' chrome://resources; frame-src 'self' about:; img-src 'self' chrome://resources chrome://theme data: https://docs.google.com https://*.googleusercontent.com chrome://extension-icon; media-src 'self' https://*.googleusercontent.com; connect-src https://drive.google.com", - "app": { - "launch": { - "container": "panel", - "local_path": "main.html" - } - }, - "file_browser_handlers": [ - { - "id": "play", - "default_title": "__MSG_PLAY_MEDIA__", - "default_icon": "images/filetype_audio.png", - "file_filters": [ - "filesystem:*.amr", - "filesystem:*.flac", - "filesystem:*.m4a", - "filesystem:*.mp3", - "filesystem:*.oga", - "filesystem:*.ogg", - "filesystem:*.wav" - ] - }, - { - "id": "watch", - "default_title": "__MSG_PLAY_MEDIA__", - "default_icon": "images/filetype_video.png", - "file_filters": [ - "filesystem:*.3gp", - "filesystem:*.avi", - "filesystem:*.m4v", - "filesystem:*.mkv", - "filesystem:*.mov", - "filesystem:*.mp4", - "filesystem:*.mpeg", - "filesystem:*.mpeg4", - "filesystem:*.mpg", - "filesystem:*.mpg4", - "filesystem:*.ogm", - "filesystem:*.ogv", - "filesystem:*.ogx", - "filesystem:*.webm" - ] - }, - { - "id": "mount-archive", - "default_title": "__MSG_MOUNT_ARCHIVE__", - "default_icon": "images/filetype_archive.png", - "file_filters": [ - "filesystem:*.rar", - "filesystem:*.tar", - "filesystem:*.tar.bz2", - "filesystem:*.tar.gz", - "filesystem:*.tbz", - "filesystem:*.tbz2", - "filesystem:*.tgz", - "filesystem:*.zip" - ] - }, - { - "id": "view-pdf", - "default_title": "__MSG_OPEN_ACTION__", - "default_icon": "images/filetype_pdf.png", - "file_filters": [ - "filesystem:*.pdf" - ] - }, - { - "id": "view-swf", - "default_title": "__MSG_OPEN_ACTION__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.swf" - ] - }, - { - "id": "view-in-browser", - "default_title": "__MSG_OPEN_ACTION__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.htm", - "filesystem:*.html", - "filesystem:*.mht", - "filesystem:*.mhtml", - "filesystem:*.txt" - ] - }, - { - "id": "install-crx", - "default_title": "__MSG_INSTALL_CRX__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.crx" - ] - }, - { - "id": "gallery", - "default_title": "__MSG_OPEN_ACTION__", - "default_icon": "images/filetype_image.png", - "file_filters": [ - // Image formats - "filesystem:*.bmp", - "filesystem:*.gif", - "filesystem:*.jpg", - "filesystem:*.jpeg", - "filesystem:*.png", - "filesystem:*.webp", - // Video formats - "filesystem:*.3gp", - "filesystem:*.avi", - "filesystem:*.m4v", - "filesystem:*.mkv", - "filesystem:*.mov", - "filesystem:*.mp4", - "filesystem:*.mpeg", - "filesystem:*.mpeg4", - "filesystem:*.mpg", - "filesystem:*.mpg4", - "filesystem:*.ogm", - "filesystem:*.ogv", - "filesystem:*.ogx", - "filesystem:*.webm" - ] - }, - { - "id": "open-hosted-generic", - "default_title": "__MSG_HOSTED__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.gdraw", - "filesystem:*.gtable" - ] - }, - { - "id": "open-hosted-gdoc", - "default_title": "__MSG_HOSTED__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.gdoc" - ] - }, - { - "id": "open-hosted-gsheet", - "default_title": "__MSG_HOSTED__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.gsheet" - ] - }, - { - "id": "open-hosted-gslides", - "default_title": "__MSG_HOSTED__", - "default_icon": "images/filetype_generic.png", - "file_filters": [ - "filesystem:*.gslides" - ] - } - ], - "chrome_url_overrides": { - "files": "main.html" - }, - "background": { - "transient": true, - "persistent": false, - "scripts": ["js/file_copy_manager.js", - "js/path_util.js", - "js/util.js", - "js/test_util.js"] - } -} diff --git a/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifests_v2.json b/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifest.json index a48f22f..a48f22f 100644 --- a/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifests_v2.json +++ b/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifest.json diff --git a/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifests_v1.json b/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifests_v1.json deleted file mode 100644 index b773915..0000000 --- a/chrome/test/data/extensions/api_test/file_browser/filesystem_operations_test/manifests_v1.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDOuXEIuoK1kAkBe0SKiJn/N9oNn3oUxGa4dwj40MnJqPn+w0aR2vuyocm0R4Drp67aYwtLjOVPF4CICRq6ICP6eU07gGwQxGdZ7HJASXV8hm0tab5I70oJmRLfFJyVAMCeWlFaOGq05v2i6EbifZM0qO5xALKNGQt+yjXi5INM5wIBIw==", - "name": "chrome.fileBrowserPrivate tests", - "version": "0.1", - "manifest_version": 2, - "description": "Tests of chrome.fileBrowserPrivate.* component extension methods", - "background": { - "scripts": ["test.js"] - }, - "permissions": [ - "fileBrowserHandler", - "fileBrowserPrivate" - ] -} diff --git a/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest_v2.json b/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest.json index fc8e810..fc8e810 100644 --- a/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest_v2.json +++ b/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest.json diff --git a/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest_v1.json b/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest_v1.json deleted file mode 100644 index 8f632e3..0000000 --- a/chrome/test/data/extensions/api_test/file_browser/handler_test_runner/manifest_v1.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDOuXEIuoK1kAkBe0SKiJn/N9oNn3oUxGa4dwj40MnJqPn+w0aR2vuyocm0R4Drp67aYwtLjOVPF4CICRq6ICP6eU07gGwQxGdZ7HJASXV8hm0tab5I70oJmRLfFJyVAMCeWlFaOGq05v2i6EbifZM0qO5xALKNGQt+yjXi5INM5wIBIw==", - "name": "chrome.fileBrowserPrivate tests", - "version": "0.1", - "manifest_version": 2, - "description": "Tests of chrome.fileBrowserPrivate.* component extension methods", - "background": { - "scripts": ["test.js"] - }, - "permissions": [ - "fileBrowserHandler", - "fileBrowserPrivate" - ] -} - diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index af61941..058e7a8 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -121,10 +121,6 @@ const char kEnterpriseEnrollmentInitialModulus[] = const char kEnterpriseEnrollmentModulusLimit[] = "enterprise-enrollment-modulus-limit"; -// Loads the File Manager as an extension instead of a platform app. -// This flag is obsolete. Remove it, once Files.app v2 is stable. -const char kFileManagerLegacy[] = "file-manager-legacy"; - // Loads the File Manager with the legacy UI. const char kFileManagerLegacyUI[] = "file-manager-legacy-ui"; diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 2e23a13..8be1f45 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -51,7 +51,6 @@ CHROMEOS_EXPORT extern const char kEnableTouchpadThreeFingerClick[]; CHROMEOS_EXPORT extern const char kEnableTouchpadThreeFingerSwipe[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[]; CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentModulusLimit[]; -CHROMEOS_EXPORT extern const char kFileManagerLegacy[]; CHROMEOS_EXPORT extern const char kFileManagerLegacyUI[]; CHROMEOS_EXPORT extern const char kFirstBoot[]; CHROMEOS_EXPORT extern const char kForceLoginManagerInTests[]; |