Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Unified Diff: chrome/browser/views/extensions/browser_action_drag_data.cc

Issue 549224: Support reordering of Browser Actions within the container. Currently does no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/views/extensions/browser_action_drag_data.cc
===================================================================
--- chrome/browser/views/extensions/browser_action_drag_data.cc (revision 0)
+++ chrome/browser/views/extensions/browser_action_drag_data.cc (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/views/extensions/browser_action_drag_data.h"
+
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/pickle.h"
+#include "base/string_util.h"
+#include "chrome/browser/profile.h"
+
+const char* BrowserActionDragData::kClipboardFormatString =
+ "chromium/x-browser-actions";
+
+BrowserActionDragData::BrowserActionDragData()
+ : index_(-1) {
+}
+
+BrowserActionDragData::BrowserActionDragData(
+ const std::string& id, int index)
+ : 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());
+}
+
+#if defined(TOOLKIT_VIEWS)
+void BrowserActionDragData::Write(
+ Profile* profile, OSExchangeData* data) const {
+ DCHECK(data);
+ Pickle data_pickle;
+ WriteToPickle(profile, &data_pickle);
+ data->SetPickledData(GetBrowserActionCustomFormat(), data_pickle);
+}
+
+bool BrowserActionDragData::Read(const OSExchangeData& data) {
+ if (!data.HasCustomFormat(GetBrowserActionCustomFormat()))
+ return false;
+
+ Pickle drag_data_pickle;
+ if (!data.GetPickledData(GetBrowserActionCustomFormat(), &drag_data_pickle))
+ return false;
+
+ if (!ReadFromPickle(&drag_data_pickle))
+ return false;
+
+ return true;
+}
+
+// static
+OSExchangeData::CustomFormat
+ BrowserActionDragData::GetBrowserActionCustomFormat() {
+ static OSExchangeData::CustomFormat format;
+ static bool format_valid = false;
+
+ if (!format_valid) {
+ format_valid = true;
+ format = OSExchangeData::RegisterCustomFormat(
+ BrowserActionDragData::kClipboardFormatString);
+ }
+ return format;
+}
+#endif
+
+void BrowserActionDragData::WriteToPickle(
+ Profile* profile, Pickle* pickle) const {
+ FilePath::WriteStringTypeToPickle(pickle, profile->GetPath().value());
+ pickle->WriteString(id_);
+ pickle->WriteInt(index_);
+}
+
+bool BrowserActionDragData::ReadFromPickle(Pickle* pickle) {
+ void* data_iterator = NULL;
+ if (!FilePath::ReadStringTypeFromPickle(pickle, &data_iterator,
+ &profile_path_)) {
+ return false;
+ }
+
+ if (!pickle->ReadString(&data_iterator, &id_))
+ return false;
+
+ int index;
+ if (!pickle->ReadInt(&data_iterator, &index))
+ return false;
+
+ index_ = index;
+ return true;
+}
Property changes on: chrome\browser\views\extensions\browser_action_drag_data.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698