summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 00:30:11 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 00:30:11 +0000
commitb96f37d0d4d2425175194bd6fb5dc4458d47971b (patch)
tree37d43b2cb90881a369811dae4ac4ea6a4acc30f6
parent4c6092c5b185ac77c5751947f3ec335bc3db68f2 (diff)
downloadchromium_src-b96f37d0d4d2425175194bd6fb5dc4458d47971b.zip
chromium_src-b96f37d0d4d2425175194bd6fb5dc4458d47971b.tar.gz
chromium_src-b96f37d0d4d2425175194bd6fb5dc4458d47971b.tar.bz2
Only allow tabs to be dragged between compatible windows.
Right now, this means windows with the same Profile. http://crbug.com/12241 TEST=Open some tabs in incognito and regular windows. Try to drag between. Should be able to drag between like security contexts (incognito to incognito, regular to regular), but not across. Review URL: http://codereview.chromium.org/119266 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17807 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm15
-rw-r--r--chrome/browser/cocoa/tab_view.mm6
-rw-r--r--chrome/browser/cocoa/tab_window_controller.h4
-rw-r--r--chrome/browser/cocoa/tab_window_controller.mm6
4 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 2cb822b..a138905 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -364,6 +364,21 @@ willPositionSheet:(NSWindow *)sheet
return [tabStripController_ selectedTabGrowBoxRect];
}
+// Accept tabs from a BrowserWindowController with the same Profile.
+- (BOOL)canReceiveFrom:(TabWindowController*)source {
+ if (![source isKindOfClass:[BrowserWindowController class]]) {
+ return NO;
+ }
+
+ BrowserWindowController* realSource =
+ static_cast<BrowserWindowController*>(source);
+ if (browser_->profile() != realSource->browser_->profile()) {
+ return NO;
+ }
+
+ return YES;
+}
+
// Move a given tab view to the location of the current placeholder. If there is
// no placeholder, it will go at the end. |controller| is the window controller
// of a tab being dropped from a different window. It will be nil if the drag is
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm
index fe45b592..ee655f2 100644
--- a/chrome/browser/cocoa/tab_view.mm
+++ b/chrome/browser/cocoa/tab_view.mm
@@ -182,7 +182,11 @@ static const double kDragStartDistance = 3.0;
if (![window isVisible]) continue;
NSWindowController *controller = [window windowController];
if ([controller isKindOfClass:[TabWindowController class]]) {
- [targets addObject:controller];
+ TabWindowController* realController =
+ static_cast<TabWindowController*>(controller);
+ if ([realController canReceiveFrom:sourceController_]) {
+ [targets addObject:controller];
+ }
}
}
}
diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h
index 313887d..4f97173 100644
--- a/chrome/browser/cocoa/tab_window_controller.h
+++ b/chrome/browser/cocoa/tab_window_controller.h
@@ -62,6 +62,10 @@
// Removes the placeholder installed by |-insertPlaceholderForTab:atLocation:|.
- (void)removePlaceholder;
+// Called to check if the receiver can receive dragged tabs from
+// source. Return YES if so. The default implementation returns NO.
+- (BOOL)canReceiveFrom:(TabWindowController*)source;
+
// Move a given tab view to the location of the current placeholder. If there is
// no placeholder, it will go at the end. |controller| is the window controller
// of a tab being dropped from a different window. It will be nil if the drag is
diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm
index 8d808a4..12fc4a5 100644
--- a/chrome/browser/cocoa/tab_window_controller.mm
+++ b/chrome/browser/cocoa/tab_window_controller.mm
@@ -100,6 +100,12 @@
return overlayWindow_;
}
+- (BOOL)canReceiveFrom:(TabWindowController*)source {
+ // subclass must implement
+ NOTIMPLEMENTED();
+ return NO;
+}
+
- (void)moveTabView:(NSView*)view
fromController:(TabWindowController*)dragController {
NOTIMPLEMENTED();