summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfukino <fukino@chromium.org>2014-09-01 04:04:14 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-01 11:06:20 +0000
commit46c5b30d31a0fa9b5f8200af08d80babbf305d41 (patch)
treec6a74c413780be92fe9f0eb57bee6bc5e426467b
parent6e873ef3ec639f9db3afd4d9082d51b49dc4c4df (diff)
downloadchromium_src-46c5b30d31a0fa9b5f8200af08d80babbf305d41.zip
chromium_src-46c5b30d31a0fa9b5f8200af08d80babbf305d41.tar.gz
chromium_src-46c5b30d31a0fa9b5f8200af08d80babbf305d41.tar.bz2
Remove "Move window to..." from gear menu.
This CL removes: - "Move window to..." menu item from the gear menu. - Remove APIs fileBrowserPrivate.onProfileAdded and fileBrowserPrivate.onDesktopChanged as they are used only for updating gear menu. - Remove corresponding tests. BUG=408965 TEST=run browser_test, unit_tests TBR=benwells@chromium.org # TBRing for just removing unused events from file_browser_private.idl Review URL: https://codereview.chromium.org/530553006 Cr-Commit-Position: refs/heads/master@{#292860}
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/event_router.cc61
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/event_router.h30
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc6
-rw-r--r--chrome/browser/chromeos/file_manager/file_manager_browsertest.cc20
-rw-r--r--chrome/common/extensions/api/file_browser_private.idl7
-rw-r--r--chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager/multi_profile.js106
-rw-r--r--chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager_test_manifest.json1
-rw-r--r--ui/file_manager/file_manager/foreground/js/file_manager.js62
-rw-r--r--ui/file_manager/file_manager/main.html1
9 files changed, 5 insertions, 289 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.cc b/chrome/browser/chromeos/extensions/file_manager/event_router.cc
index c459ccb..9d85d4a 100644
--- a/chrome/browser/chromeos/extensions/file_manager/event_router.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/event_router.cc
@@ -38,7 +38,6 @@
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/event_router.h"
@@ -251,22 +250,6 @@ std::string FileErrorToErrorName(base::File::Error error_code) {
}
}
-void GrantAccessForAddedProfileToRunningInstance(Profile* added_profile,
- Profile* running_profile) {
- extensions::ProcessManager* const process_manager =
- extensions::ExtensionSystem::Get(running_profile)->process_manager();
- if (!process_manager)
- return;
-
- extensions::ExtensionHost* const extension_host =
- process_manager->GetBackgroundHostForExtension(kFileManagerAppId);
- if (!extension_host || !extension_host->render_process_host())
- return;
-
- const int id = extension_host->render_process_host()->GetID();
- file_manager::util::SetupProfileFileAccessPermissions(id, added_profile);
-}
-
// Checks if we should send a progress event or not according to the
// |last_time| of sending an event. If |always| is true, the function always
// returns true. If the function returns true, the function also updates
@@ -367,7 +350,6 @@ EventRouter::DriveJobInfoWithStatus::DriveJobInfoWithStatus(
EventRouter::EventRouter(Profile* profile)
: pref_change_registrar_(new PrefChangeRegistrar),
profile_(profile),
- multi_user_window_manager_observer_registered_(false),
device_event_router_(new DeviceEventRouterImpl(profile)),
weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -413,14 +395,6 @@ void EventRouter::Shutdown() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
power_manager_client->RemoveObserver(device_event_router_.get());
- chrome::MultiUserWindowManager* const multi_user_window_manager =
- chrome::MultiUserWindowManager::GetInstance();
- if (multi_user_window_manager &&
- multi_user_window_manager_observer_registered_) {
- multi_user_window_manager_observer_registered_ = false;
- multi_user_window_manager->RemoveObserver(this);
- }
-
profile_ = NULL;
}
@@ -471,10 +445,6 @@ void EventRouter::ObserveEvents() {
pref_change_registrar_->Add(prefs::kDisableDriveHostedFiles, callback);
pref_change_registrar_->Add(prefs::kDisableDrive, callback);
pref_change_registrar_->Add(prefs::kUse24HourClock, callback);
-
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_PROFILE_ADDED,
- content::NotificationService::AllSources());
}
// File watch setup routines.
@@ -940,35 +910,4 @@ void EventRouter::OnFormatCompleted(const std::string& device_path,
// Do nothing.
}
-void EventRouter::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_PROFILE_ADDED) {
- Profile* const added_profile = content::Source<Profile>(source).ptr();
- if (!added_profile->IsOffTheRecord())
- GrantAccessForAddedProfileToRunningInstance(added_profile, profile_);
-
- BroadcastEvent(profile_,
- file_browser_private::OnProfileAdded::kEventName,
- file_browser_private::OnProfileAdded::Create());
- }
-}
-
-void EventRouter::RegisterMultiUserWindowManagerObserver() {
- if (multi_user_window_manager_observer_registered_)
- return;
- chrome::MultiUserWindowManager* const multi_user_window_manager =
- chrome::MultiUserWindowManager::GetInstance();
- if (multi_user_window_manager) {
- multi_user_window_manager->AddObserver(this);
- multi_user_window_manager_observer_registered_ = true;
- }
-}
-
-void EventRouter::OnOwnerEntryChanged(aura::Window* window) {
- BroadcastEvent(profile_,
- file_browser_private::OnDesktopChanged::kEventName,
- file_browser_private::OnDesktopChanged::Create());
-}
-
} // namespace file_manager
diff --git a/chrome/browser/chromeos/extensions/file_manager/event_router.h b/chrome/browser/chromeos/extensions/file_manager/event_router.h
index 7e094d6..7d187ea 100644
--- a/chrome/browser/chromeos/extensions/file_manager/event_router.h
+++ b/chrome/browser/chromeos/extensions/file_manager/event_router.h
@@ -21,12 +21,9 @@
#include "chrome/browser/chromeos/file_manager/volume_manager.h"
#include "chrome/browser/chromeos/file_manager/volume_manager_observer.h"
#include "chrome/browser/drive/drive_service_interface.h"
-#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#include "chrome/common/extensions/api/file_browser_private.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/network/network_state_handler_observer.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "webkit/browser/fileapi/file_system_operation.h"
class PrefChangeRegistrar;
@@ -51,14 +48,11 @@ class DeviceEventRouter;
// Monitors changes in disk mounts, network connection state and preferences
// affecting File Manager. Dispatches appropriate File Browser events.
-class EventRouter
- : public chromeos::NetworkStateHandlerObserver,
- public drive::FileSystemObserver,
- public drive::JobListObserver,
- public drive::DriveServiceObserver,
- public VolumeManagerObserver,
- public content::NotificationObserver,
- public chrome::MultiUserWindowManager::Observer {
+class EventRouter : public chromeos::NetworkStateHandlerObserver,
+ public drive::FileSystemObserver,
+ public drive::JobListObserver,
+ public drive::DriveServiceObserver,
+ public VolumeManagerObserver {
public:
explicit EventRouter(Profile* profile);
virtual ~EventRouter();
@@ -96,9 +90,6 @@ class EventRouter
const GURL& destination_url,
int64 size);
- // Register observer to the multi user window manager.
- void RegisterMultiUserWindowManagerObserver();
-
// chromeos::NetworkStateHandlerObserver overrides.
virtual void DefaultNetworkChanged(
const chromeos::NetworkState* network) OVERRIDE;
@@ -135,14 +126,6 @@ class EventRouter
virtual void OnFormatCompleted(
const std::string& device_path, bool success) OVERRIDE;
- // content::NotificationObserver overrides.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- // chrome::MultiUserWindowManager::Observer overrides:
- virtual void OnOwnerEntryChanged(aura::Window* window) OVERRIDE;
-
private:
typedef std::map<base::FilePath, FileWatcher*> WatcherMap;
@@ -202,9 +185,6 @@ class EventRouter
scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
Profile* profile_;
- content::NotificationRegistrar notification_registrar_;
- bool multi_user_window_manager_observer_registered_;
-
scoped_ptr<DeviceEventRouter> device_event_router_;
// Note: This should remain the last member so it'll be destroyed and
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
index ed0aea0..67e57bd 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
@@ -11,7 +11,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
-#include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
#include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
#include "chrome/browser/chromeos/file_manager/app_installer.h"
@@ -418,11 +417,6 @@ bool FileBrowserPrivateVisitDesktopFunction::RunSync() {
return false;
}
- // Observe owner changes of windows.
- file_manager::EventRouter* const event_router =
- file_manager::FileBrowserPrivateAPI::Get(GetProfile())->event_router();
- event_router->RegisterMultiUserWindowManagerObserver();
-
// Move the window to the user's desktop.
window_manager->ShowWindowForUser(app_window->GetNativeWindow(),
params->profile_id);
diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
index 63e8501..a8c82e7 100644
--- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
+++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
@@ -1219,26 +1219,6 @@ IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) {
StartTest();
}
-// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
-#define MAYBE_PRE_VisitDesktopMenu DISABLED_PRE_VisitDesktopMenu
-#define MAYBE_VisitDesktopMenu DISABLED_VisitDesktopMenu
-#else
-#define MAYBE_PRE_VisitDesktopMenu PRE_VisitDesktopMenu
-#define MAYBE_VisitDesktopMenu VisitDesktopMenu
-#endif
-IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
- MAYBE_PRE_VisitDesktopMenu) {
- AddAllUsers();
-}
-
-IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
- MAYBE_VisitDesktopMenu) {
- // Test for the menu item for visiting other profile's desktop.
- set_test_case_name("multiProfileVisitDesktopMenu");
- StartTest();
-}
-
template<GuestMode M>
class GalleryBrowserTestBase : public FileManagerBrowserTestBase {
public:
diff --git a/chrome/common/extensions/api/file_browser_private.idl b/chrome/common/extensions/api/file_browser_private.idl
index d4f1b24..112b4d8 100644
--- a/chrome/common/extensions/api/file_browser_private.idl
+++ b/chrome/common/extensions/api/file_browser_private.idl
@@ -818,12 +818,5 @@ interface Events {
static void onDeviceChanged(DeviceEvent event);
static void onDriveSyncError(DriveSyncErrorEvent event);
-
- // Dispatched when a profile is added.
- static void onProfileAdded();
-
- // Dispatched when any window moves another desktop.
- // TODO(hirono): Add information which window is moved.
- static void onDesktopChanged();
};
};
diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager/multi_profile.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager/multi_profile.js
deleted file mode 100644
index 65423d5..0000000
--- a/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager/multi_profile.js
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-'use strict';
-
-/**
- * @type {string}
- * @const
- */
-var UNTIL_ADDED = 'untilAdded';
-
-/**
- * @type {string}
- * @const
- */
-var UNTIL_REMOVED = 'untilRemoved';
-
-/**
- * Waits for the 'move to profileId' menu to appear or to disappear.
- * @param {string} windowId Window ID.
- * @param {string} profileId Profile ID.
- * @param {string} waitMode UNTIL_ADDED or UNTIL_REMOVED.
- * @return {Promise} Promise to be fulfilled when the menu appears or
- * disappears.
- */
-function waitForVisitDesktopMenu(windowId, profileId, waitMode) {
- if (waitMode !== UNTIL_ADDED && waitMode !== UNTIL_REMOVED)
- throw new Error('Wait mode is invalid: ' + waitMode);
- return repeatUntil(function() {
- return callRemoteTestUtil('queryAllElements', windowId, ['.visit-desktop']).
- then(function(elements) {
- var found = false;
- for (var i = 0; i < elements.length; i++) {
- if (elements[i].text.indexOf(profileId) !== -1) {
- found = true;
- break;
- }
- }
- if ((waitMode === UNTIL_ADDED && !found) ||
- (waitMode === UNTIL_REMOVED && found))
- return pending(
- 'Waiting for the visit desktop menu to %s: ' +
- '%s, but currently it is %j.',
- waitMode === UNTIL_ADDED ? 'contain' : 'exclude',
- profileId,
- elements);
- });
- });
-}
-
-testcase.multiProfileVisitDesktopMenu = function() {
- var appId;
- StepsRunner.run([
- function() {
- setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
- },
- // Add all users.
- function(inAppId) {
- appId = inAppId;
- chrome.test.sendMessage(JSON.stringify({name: 'addAllUsers'}),
- this.next);
- },
- // Wait for menu items. Profiles for non-current desktop should appear and
- // the profile for the current desktop (alice) should be hidden.
- function(json) {
- chrome.test.assertTrue(JSON.parse(json));
- Promise.all([
- waitForVisitDesktopMenu(appId, 'bob@invalid.domain', UNTIL_ADDED),
- waitForVisitDesktopMenu(appId, 'charlie@invalid.domain', UNTIL_ADDED),
- waitForVisitDesktopMenu(appId, 'alice@invalid.domain', UNTIL_REMOVED)
- ]).
- then(this.next, function(error) {
- chrome.test.fail(error.stack || error);
- });
- },
- // Activate the visit desktop menu.
- function() {
- callRemoteTestUtil('runVisitDesktopMenu',
- appId,
- ['bob@invalid.domain'],
- this.next);
- },
- // Wait for the new menu state. Now 'alice' is shown and 'bob' is hidden.
- function(result) {
- chrome.test.assertTrue(result);
- Promise.all([
- waitForVisitDesktopMenu(appId, 'bob@invalid.domain', UNTIL_REMOVED),
- waitForVisitDesktopMenu(appId, 'charlie@invalid.domain', UNTIL_ADDED),
- waitForVisitDesktopMenu(appId, 'alice@invalid.domain', UNTIL_ADDED)
- ]).
- then(this.next, function(error) {
- chrome.test.fail(error.stack || error);
- });
- },
- // Check that the window owner has indeed been changed.
- function() {
- chrome.test.sendMessage(JSON.stringify({name: 'getWindowOwnerId'}),
- this.next);
- },
- function(result) {
- chrome.test.assertEq('bob@invalid.domain', result);
- checkIfNoErrorsOccured(this.next);
- }
- ]);
-};
diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager_test_manifest.json b/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager_test_manifest.json
index fd39ad2..3d6eeb9 100644
--- a/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager_test_manifest.json
+++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/file_manager_test_manifest.json
@@ -19,7 +19,6 @@
"file_manager/folder_shortcuts.js",
"file_manager/grid_view.js",
"file_manager/keyboard_operations.js",
- "file_manager/multi_profile.js",
"file_manager/open_audio_files.js",
"file_manager/open_video_files.js",
"file_manager/open_zip_files.js",
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager.js b/ui/file_manager/file_manager/foreground/js/file_manager.js
index 9fee885..7ca5611 100644
--- a/ui/file_manager/file_manager/foreground/js/file_manager.js
+++ b/ui/file_manager/file_manager/foreground/js/file_manager.js
@@ -478,12 +478,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
this.gearButton_ = this.dialogDom_.querySelector('#gear-button');
this.gearButton_.addEventListener('menushow',
this.onShowGearMenu_.bind(this));
- chrome.fileBrowserPrivate.onDesktopChanged.addListener(function() {
- this.updateVisitDesktopMenus_();
- }.bind(this));
- chrome.fileBrowserPrivate.onProfileAdded.addListener(
- this.updateVisitDesktopMenus_.bind(this));
- this.updateVisitDesktopMenus_();
this.dialogDom_.querySelector('#gear-menu').menuItemSelector =
'menuitem, hr';
@@ -2155,62 +2149,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
};
/**
- * Update menus that move the window to the other profile's desktop.
- * TODO(hirono): Add the GearMenu class and make it a member of the class.
- * TODO(hirono): Handle the case where a profile is added while the menu is
- * opened.
- * @private
- */
- FileManager.prototype.updateVisitDesktopMenus_ = function() {
- var gearMenu = this.document_.querySelector('#gear-menu');
- var separator =
- this.document_.querySelector('#multi-profile-separator');
-
- // Remove existing menu items.
- var oldItems =
- this.document_.querySelectorAll('#gear-menu .visit-desktop');
- for (var i = 0; i < oldItems.length; i++) {
- gearMenu.removeChild(oldItems[i]);
- }
- separator.hidden = true;
-
- if (this.dialogType !== DialogType.FULL_PAGE)
- return;
-
- // Obtain the profile information.
- chrome.fileBrowserPrivate.getProfiles(function(profiles,
- currentId,
- displayedId) {
- // Check if the menus are needed or not.
- var insertingPosition = separator.nextSibling;
- if (profiles.length === 1 && profiles[0].profileId === displayedId)
- return;
-
- separator.hidden = false;
- for (var i = 0; i < profiles.length; i++) {
- var profile = profiles[i];
- if (profile.profileId === displayedId)
- continue;
- var item = this.document_.createElement('menuitem');
- cr.ui.MenuItem.decorate(item);
- gearMenu.insertBefore(item, insertingPosition);
- item.className = 'visit-desktop';
- item.label = strf('VISIT_DESKTOP_OF_USER',
- profile.displayName,
- profile.profileId);
- item.addEventListener('activate', function(inProfile, event) {
- // Stop propagate and hide the menu manually, in order to prevent the
- // focus from being back to the button. (cf. http://crbug.com/248479)
- event.stopPropagation();
- this.gearButton_.hideMenu();
- this.gearButton_.blur();
- chrome.fileBrowserPrivate.visitDesktop(inProfile.profileId);
- }.bind(this, profile));
- }
- }.bind(this));
- };
-
- /**
* Refreshes space info of the current volume.
* @param {boolean} showLoadingCaption Whether show loading caption or not.
* @private
diff --git a/ui/file_manager/file_manager/main.html b/ui/file_manager/file_manager/main.html
index 9c957ca..0feb24d 100644
--- a/ui/file_manager/file_manager/main.html
+++ b/ui/file_manager/file_manager/main.html
@@ -241,7 +241,6 @@
<menu id="gear-menu" class="chrome-menu" showShortcuts>
<menuitem id="gear-menu-newwindow" command="#new-window"></menuitem>
<menuitem id="gear-menu-newfolder" command="#new-folder"></menuitem>
- <hr id="multi-profile-separator">
<hr id="drive-separator">
<menuitem id="gear-menu-drive-sync-settings"
command="#drive-sync-settings"></menuitem>