summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 16:04:07 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 16:04:07 +0000
commit95bf8a5bab5b636d63862a83b6930a414d1bad0b (patch)
treed7029d59745877fef7d7b38a2c57833e1c5677f6 /chrome/browser/extensions
parente259d488cd6b93b27831289bd6a3bc0b40758c98 (diff)
downloadchromium_src-95bf8a5bab5b636d63862a83b6930a414d1bad0b.zip
chromium_src-95bf8a5bab5b636d63862a83b6930a414d1bad0b.tar.gz
chromium_src-95bf8a5bab5b636d63862a83b6930a414d1bad0b.tar.bz2
Prevent extensions from moving tabs that are being dragged. This fixes a crash on Windows and Linux related to extensions moving or removing tabs that are being dragged. This also prevents extensions from removing a window that the user is dragging tabs within.
BUG=53799 TEST=See bug report. Review URL: http://codereview.chromium.org/4856004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc24
-rw-r--r--chrome/browser/extensions/extension_tabs_module_constants.cc2
-rw-r--r--chrome/browser/extensions/extension_tabs_module_constants.h1
3 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 1812b4c..b58e07c 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -550,6 +550,13 @@ bool RemoveWindowFunction::RunImpl() {
if (!browser)
return false;
+ // Don't let the extension remove the window if the user is dragging tabs
+ // in that window.
+ if (!browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
+
browser->CloseWindow();
return true;
@@ -848,6 +855,12 @@ bool MoveTabFunction::RunImpl() {
&tab_index, &error_))
return false;
+ // Don't let the extension move the tab if the user is dragging tabs.
+ if (!source_browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
+
if (update_props->HasKey(keys::kWindowIdKey)) {
Browser* target_browser;
int window_id;
@@ -858,6 +871,11 @@ bool MoveTabFunction::RunImpl() {
if (!target_browser)
return false;
+ if (!target_browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
+
if (target_browser->type() != Browser::TYPE_NORMAL) {
error_ = keys::kCanOnlyMoveTabsWithinNormalWindowsError;
return false;
@@ -917,6 +935,12 @@ bool RemoveTabFunction::RunImpl() {
&browser, NULL, &contents, NULL, &error_))
return false;
+ // Don't let the extension remove a tab if the user is dragging tabs around.
+ if (!browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
+
// Close the tab in this convoluted way, since there's a chance that the tab
// is being dragged, or we're in some other nested event loop. This code path
// should ensure that the tab is safely closed under such circumstances,
diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc
index 6405783..6ea521f 100644
--- a/chrome/browser/extensions/extension_tabs_module_constants.cc
+++ b/chrome/browser/extensions/extension_tabs_module_constants.cc
@@ -58,6 +58,8 @@ const char kNoCurrentWindowError[] = "No current window";
const char kNoLastFocusedWindowError[] = "No last-focused window";
const char kWindowNotFoundError[] = "No window with id: *.";
const char kTabNotFoundError[] = "No tab with id: *.";
+const char kTabStripNotEditableError[] =
+ "Tabs cannot be edited right now (user may be dragging a tab).";
const char kNoSelectedTabError[] = "No selected tab";
const char kInvalidUrlError[] = "Invalid url: \"*\".";
const char kInternalVisibleTabCaptureError[] =
diff --git a/chrome/browser/extensions/extension_tabs_module_constants.h b/chrome/browser/extensions/extension_tabs_module_constants.h
index 89c1cd3..4ac09de 100644
--- a/chrome/browser/extensions/extension_tabs_module_constants.h
+++ b/chrome/browser/extensions/extension_tabs_module_constants.h
@@ -61,6 +61,7 @@ extern const char kNoCurrentWindowError[];
extern const char kNoLastFocusedWindowError[];
extern const char kWindowNotFoundError[];
extern const char kTabNotFoundError[];
+extern const char kTabStripNotEditableError[];
extern const char kNoSelectedTabError[];
extern const char kInvalidUrlError[];
extern const char kInternalVisibleTabCaptureError[];