OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 5 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "ui/base/clipboard/clipboard.h" | 11 #include "ui/base/clipboard/clipboard.h" |
12 | 12 |
13 const char* BrowserActionDragData::kClipboardFormatString = | 13 namespace { |
14 "chromium/x-browser-actions"; | 14 |
15 // The MIME type for the clipboard format for BrowserActionDragData. | |
16 const char* kClipboardFormatString = "chromium/x-browser-actions"; | |
dcheng
2014/07/17 19:58:02
Minor nit: const char kClipboardFormatString[]
Devlin
2014/07/17 20:43:34
Sure, done.
| |
17 | |
18 } | |
15 | 19 |
16 BrowserActionDragData::BrowserActionDragData() | 20 BrowserActionDragData::BrowserActionDragData() |
17 : profile_(NULL), index_(static_cast<size_t>(-1)) { | 21 : profile_(NULL), index_(static_cast<size_t>(-1)) { |
18 } | 22 } |
19 | 23 |
20 BrowserActionDragData::BrowserActionDragData( | 24 BrowserActionDragData::BrowserActionDragData( |
21 const std::string& id, int index) | 25 const std::string& id, int index) |
22 : profile_(NULL), id_(id), index_(index) { | 26 : profile_(NULL), id_(id), index_(index) { |
23 } | 27 } |
24 | 28 |
25 bool BrowserActionDragData::IsFromProfile(Profile* profile) const { | 29 bool BrowserActionDragData::GetDropFormats( |
30 int* formats, std::set<ui::OSExchangeData::CustomFormat>* custom_formats) { | |
dcheng
2014/07/17 19:58:03
Given that |formats| isn't used here at all, proba
Devlin
2014/07/17 20:43:34
Mmkay. Originally I had it just so it shadowed th
| |
31 custom_formats->insert(GetBrowserActionCustomFormat()); | |
32 return true; | |
33 } | |
34 | |
35 bool BrowserActionDragData::AreDropTypesRequired() { | |
36 return true; | |
37 } | |
38 | |
39 bool BrowserActionDragData::CanDrop(const ui::OSExchangeData& data, | |
40 const Profile* profile) { | |
41 BrowserActionDragData drop_data; | |
42 return drop_data.Read(data) && drop_data.IsFromProfile(profile); | |
43 } | |
44 | |
45 bool BrowserActionDragData::IsFromProfile(const Profile* profile) const { | |
26 return profile_ == profile; | 46 return profile_ == profile; |
27 } | 47 } |
28 | 48 |
29 #if defined(TOOLKIT_VIEWS) | 49 #if defined(TOOLKIT_VIEWS) |
30 void BrowserActionDragData::Write( | 50 void BrowserActionDragData::Write( |
31 Profile* profile, ui::OSExchangeData* data) const { | 51 Profile* profile, ui::OSExchangeData* data) const { |
32 DCHECK(data); | 52 DCHECK(data); |
33 Pickle data_pickle; | 53 Pickle data_pickle; |
34 WriteToPickle(profile, &data_pickle); | 54 WriteToPickle(profile, &data_pickle); |
35 data->SetPickledData(GetBrowserActionCustomFormat(), data_pickle); | 55 data->SetPickledData(GetBrowserActionCustomFormat(), data_pickle); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 if (!pickle->ReadString(&data_iterator, &id_)) | 99 if (!pickle->ReadString(&data_iterator, &id_)) |
80 return false; | 100 return false; |
81 | 101 |
82 uint64 index; | 102 uint64 index; |
83 if (!pickle->ReadUInt64(&data_iterator, &index)) | 103 if (!pickle->ReadUInt64(&data_iterator, &index)) |
84 return false; | 104 return false; |
85 index_ = static_cast<size_t>(index); | 105 index_ = static_cast<size_t>(index); |
86 | 106 |
87 return true; | 107 return true; |
88 } | 108 } |
OLD | NEW |