diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 23:52:24 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 23:52:24 +0000 |
commit | 26d2f47eba267fc034ae77d0ca1fefdc7cb86135 (patch) | |
tree | b74e28bcd8f16e914b88935bf4ca710bddc64586 /chrome | |
parent | 08173b245a9fbe6381a805cc5987d434a641d96e (diff) | |
download | chromium_src-26d2f47eba267fc034ae77d0ca1fefdc7cb86135.zip chromium_src-26d2f47eba267fc034ae77d0ca1fefdc7cb86135.tar.gz chromium_src-26d2f47eba267fc034ae77d0ca1fefdc7cb86135.tar.bz2 |
Don't allow dragging browser actions between regular and incognito windows.
This fixes a crash.
Also small fix to Pickle::ReadBytes to fix up the iterator if it is NULL.
BUG=39340
Review URL: http://codereview.chromium.org/1542007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
3 files changed, 16 insertions, 17 deletions
diff --git a/chrome/browser/views/extensions/browser_action_drag_data.cc b/chrome/browser/views/extensions/browser_action_drag_data.cc index 103738f..2d772ea 100644 --- a/chrome/browser/views/extensions/browser_action_drag_data.cc +++ b/chrome/browser/views/extensions/browser_action_drag_data.cc @@ -14,19 +14,16 @@ const char* BrowserActionDragData::kClipboardFormatString = "chromium/x-browser-actions"; BrowserActionDragData::BrowserActionDragData() - : index_(-1) { + : profile_id_(0), index_(-1) { } BrowserActionDragData::BrowserActionDragData( const std::string& id, int index) - : id_(id), - index_(index) { + : profile_id_(0), id_(id), index_(index) { } bool BrowserActionDragData::IsFromProfile(Profile* profile) const { - // An empty path means the data is not associated with any profile. - return (!profile_path_.empty() && - profile_path_ == profile->GetPath().value()); + return (profile_id_ == profile->GetRuntimeId()); } #if defined(TOOLKIT_VIEWS) @@ -69,25 +66,25 @@ OSExchangeData::CustomFormat void BrowserActionDragData::WriteToPickle( Profile* profile, Pickle* pickle) const { - FilePath::WriteStringTypeToPickle(pickle, profile->GetPath().value()); + ProfileId profile_id = profile->GetRuntimeId(); + pickle->WriteBytes(&profile_id, sizeof(profile_id)); pickle->WriteString(id_); - pickle->WriteInt(index_); + pickle->WriteSize(index_); } bool BrowserActionDragData::ReadFromPickle(Pickle* pickle) { void* data_iterator = NULL; - if (!FilePath::ReadStringTypeFromPickle(pickle, &data_iterator, - &profile_path_)) { + + const char* tmp; + if (!pickle->ReadBytes(&data_iterator, &tmp, sizeof(profile_id_))) return false; - } + memcpy(&profile_id_, tmp, sizeof(profile_id_)); if (!pickle->ReadString(&data_iterator, &id_)) return false; - int index; - if (!pickle->ReadInt(&data_iterator, &index)) + if (!pickle->ReadSize(&data_iterator, &index_)) return false; - index_ = index; return true; } diff --git a/chrome/browser/views/extensions/browser_action_drag_data.h b/chrome/browser/views/extensions/browser_action_drag_data.h index 8d5d514b..583185b 100644 --- a/chrome/browser/views/extensions/browser_action_drag_data.h +++ b/chrome/browser/views/extensions/browser_action_drag_data.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" +#include "chrome/browser/profile.h" #if defined(TOOLKIT_VIEWS) #include "app/os_exchange_data.h" @@ -44,8 +45,8 @@ class BrowserActionDragData { void WriteToPickle(Profile* profile, Pickle* pickle) const; bool ReadFromPickle(Pickle* pickle); - // Path of the profile we originated from. - FilePath::StringType profile_path_; + // ID of the profile we originated from. + ProfileId profile_id_; // The id of the view being dragged. std::string id_; diff --git a/chrome/browser/views/extensions/browser_action_drag_data_unittest.cc b/chrome/browser/views/extensions/browser_action_drag_data_unittest.cc index 7f54b0c..da4eb2c 100644 --- a/chrome/browser/views/extensions/browser_action_drag_data_unittest.cc +++ b/chrome/browser/views/extensions/browser_action_drag_data_unittest.cc @@ -37,8 +37,9 @@ TEST_F(BrowserActionDragDataTest, BrowserActionDragDataFormat) { profile.SetID(L"id"); const std::string extension_id = "42"; + const ProfileId profile_id = profile.GetRuntimeId(); Pickle pickle; - pickle.WriteWString(profile.GetPath().ToWStringHack()); + pickle.WriteBytes(&profile_id, sizeof(profile_id)); pickle.WriteString(extension_id); pickle.WriteInt(42); |