Skip to content

Commit 4ca2dc7

Browse files
committed
IBrowserProfileのGetCookieCollection()の戻り値をList<Cookie>に変更
1 parent 32eca6e commit 4ca2dc7

File tree

16 files changed

+64
-49
lines changed

16 files changed

+64
-49
lines changed

Diff for: BrowserCookieImplementations/Chrome.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ChromeProfile : IBrowserProfile
5454

5555
public BrowserType Type { get; }
5656

57-
public CookieCollection GetCookieCollection(string domain)
57+
public List<Cookie> GetCookieCollection(string domain)
5858
{
5959
var query = "SELECT value, name, host_key, path, expires_utc, encrypted_value FROM cookies WHERE host_key LIKE '%" + domain + "'";
6060
return GetCookieCollectionInternal(query);
@@ -98,7 +98,7 @@ private List<string> GetChildren(string path)
9898
return new List<string> { path };
9999
}
100100
}
101-
private System.Net.CookieCollection GetCookieCollectionInternal(string query)
101+
private List<Cookie> GetCookieCollectionInternal(string query)
102102
{
103103
System.Data.DataTable dt = null;
104104
using (var tempFile = new TempFileProvider())
@@ -130,7 +130,7 @@ private System.Net.CookieCollection GetCookieCollectionInternal(string query)
130130
dt = SQLiteHelper.ExecuteReader(conn, query);
131131
}
132132
}
133-
var collection = new CookieCollection();
133+
var list = new List<Cookie>();
134134
if (dt != null)
135135
{
136136
var cc = new CookieContainer();
@@ -159,12 +159,12 @@ private System.Net.CookieCollection GetCookieCollectionInternal(string query)
159159
//CookieContainerに追加できないようなサイズの大きいvalueが存在したため、適合していることをチェックする。
160160
//適合しなかったら例外が投げられ、追加しない。
161161
cc.Add(cookie);
162-
collection.Add(cookie);
162+
list.Add(cookie);
163163
}
164164
catch (CookieException) { }
165165
}
166166
}
167-
return collection;
167+
return list;
168168
}
169169
/// <summary>
170170
/// 復号化する。

Diff for: BrowserCookieImplementations/Firefox.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Cookie GetCookie(string domain, string name)
5454
return (collection != null && collection.Count > 0) ? collection[0] : null;
5555
}
5656

57-
public CookieCollection GetCookieCollection(string domain)
57+
public List<Cookie> GetCookieCollection(string domain)
5858
{
5959
var query = "SELECT value, name, host, path, expiry FROM moz_cookies WHERE host LIKE '%" + domain + "'";
6060
return GetCookieCollectionInternal(query);
@@ -66,13 +66,13 @@ public CookieCollection GetCookieCollection(string domain)
6666
///
6767
/// </summary>
6868
/// <returns></returns>
69-
private System.Net.CookieCollection GetCookieCollectionInternal(string query)
69+
private List<Cookie> GetCookieCollectionInternal(string query)
7070
{
7171
//使用中でロックが掛かっている可能性があるため、一旦コピー。
7272
var tempFile = new TempFileProvider();
7373
System.IO.File.Copy(Path, tempFile.Path, true);
7474

75-
var collection = new CookieCollection();
75+
var list = new List<Cookie>();
7676
System.Data.DataTable dt = null;
7777
using (var conn = SQLiteHelper.CreateConnection(tempFile.Path))
7878
{
@@ -107,12 +107,12 @@ private System.Net.CookieCollection GetCookieCollectionInternal(string query)
107107
//CookieContainerに追加できないようなサイズの大きいvalueが存在したため、適合していることをチェックする。
108108
//適合しなかったら例外が投げられ、追加しない。
109109
cc.Add(cookie);
110-
collection.Add(cookie);
110+
list.Add(cookie);
111111
}
112112
catch (CookieException) { }
113113
}
114114
}
115-
return collection;
115+
return list;
116116
}
117117
/// <summary>
118118
///

Diff for: BrowserCookieImplementations/IE.cs

+4-9
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,23 @@ public Cookie GetCookie(string domain, string name)
6060
return null;
6161
}
6262

63-
public CookieCollection GetCookieCollection(string domain)
63+
public List<Cookie> GetCookieCollection(string domain)
6464
{
65-
var collection = new CookieCollection();
66-
foreach (var cookie in GetCookieCollectionInternal(domain))
67-
{
68-
collection.Add(cookie);
69-
}
70-
return collection;
65+
return GetCookieCollectionInternal(domain);
7166
}
7267
/// <summary>
7368
///
7469
/// </summary>
7570
/// <param name="domain"></param>
7671
/// <returns></returns>
77-
private IEnumerable<Cookie> GetCookieCollectionInternal(string domain)
72+
private List<Cookie> GetCookieCollectionInternal(string domain)
7873
{
7974
var path = "/";
8075
var cookieData = BrowserCookieImplementations.IE.Tools.GetCookieData("https://" + domain);
8176
var cookies = CookieData2Cookies(cookieData, domain, path);
8277
var cookieDataProtected = BrowserCookieImplementations.IE.Tools.GetProtectedModeCookieData("https://" + domain);
8378
var cookiesProtected = CookieData2Cookies(cookieDataProtected, domain, path);
84-
return cookies.Concat(cookiesProtected);
79+
return cookies.Concat(cookiesProtected).ToList();
8580
}
8681
private IEnumerable<Cookie> CookieData2Cookies(string cookieData, string domain, string path)
8782
{

Diff for: BrowserCookieImplementations/Opera.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OperaProfile : IBrowserProfile
3838

3939
public BrowserType Type { get; }
4040

41-
public CookieCollection GetCookieCollection(string domain)
41+
public List<Cookie> GetCookieCollection(string domain)
4242
{
4343
var query = "SELECT value, name, host_key, path, expires_utc, encrypted_value FROM cookies WHERE host_key LIKE '%" + domain + "'";
4444
return GetCookieCollectionInternal(query);
@@ -81,7 +81,7 @@ private List<string> GetChildren(string path)
8181
return new List<string> { path };
8282
}
8383
}
84-
private System.Net.CookieCollection GetCookieCollectionInternal(string query)
84+
private List<Cookie> GetCookieCollectionInternal(string query)
8585
{
8686
System.Data.DataTable dt = null;
8787
using (var tempFile = new TempFileProvider())
@@ -113,7 +113,7 @@ private System.Net.CookieCollection GetCookieCollectionInternal(string query)
113113
dt = SQLiteHelper.ExecuteReader(conn, query);
114114
}
115115
}
116-
var collection = new CookieCollection();
116+
var list = new List<Cookie>();
117117
if (dt != null)
118118
{
119119
var cc = new CookieContainer();
@@ -142,12 +142,12 @@ private System.Net.CookieCollection GetCookieCollectionInternal(string query)
142142
//CookieContainerに追加できないようなサイズの大きいvalueが存在したため、適合していることをチェックする。
143143
//適合しなかったら例外が投げられ、追加しない。
144144
cc.Add(cookie);
145-
collection.Add(cookie);
145+
list.Add(cookie);
146146
}
147147
catch (CookieException) { }
148148
}
149149
}
150-
return collection;
150+
return list;
151151
}
152152
/// <summary>
153153
/// 復号化する。

Diff for: BrowserCookieImplementations/Unknown.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public Cookie GetCookie(string domain, string name)
1616
return new Cookie("", "", "", "");
1717
}
1818

19-
public CookieCollection GetCookieCollection(string domain)
19+
public List<Cookie> GetCookieCollection(string domain)
2020
{
21-
return new CookieCollection();
21+
return new List<Cookie>();
2222
}
2323
public UnknownProfile()
2424
{

Diff for: BrowserCookieInterfaces/IBrowserProfile.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Net;
1+
using System.Collections.Generic;
2+
using System.Net;
23

34
namespace ryu_s.BrowserCookie
45
{
@@ -8,6 +9,6 @@ public interface IBrowserProfile
89
string ProfileName { get; }
910
BrowserType Type { get; }
1011
Cookie GetCookie(string domain, string name);
11-
CookieCollection GetCookieCollection(string domain);
12+
List<Cookie> GetCookieCollection(string domain);
1213
}
1314
}

Diff for: Common/EmptyBrowserProfile.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Net;
1+
using System.Collections.Generic;
2+
using System.Net;
23
using ryu_s.BrowserCookie;
34

45
namespace Common
@@ -16,9 +17,9 @@ public Cookie GetCookie(string domain, string name)
1617
return null;
1718
}
1819

19-
public CookieCollection GetCookieCollection(string domain)
20+
public List<Cookie> GetCookieCollection(string domain)
2021
{
21-
return new CookieCollection();
22+
return new List<Cookie>();
2223
}
2324
}
2425
}

Diff for: LineLiveSitePlugin/LineLiveCommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ protected virtual CookieContainer GetCookieContainer(IBrowserProfile browserProf
120120
try
121121
{
122122
var cookies = browserProfile.GetCookieCollection("live.line.me");
123-
cc.Add(cookies);
123+
foreach (var cookie in cookies)
124+
{
125+
cc.Add(cookie);
126+
}
124127
}
125128
catch (Exception ex)
126129
{

Diff for: MirrativSitePlugin/MirrativCommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ protected virtual CookieContainer GetCookieContainer(IBrowserProfile browserProf
123123
try
124124
{
125125
var cookies = browserProfile.GetCookieCollection("mirrativ.com");
126-
cc.Add(cookies);
126+
foreach (var cookie in cookies)
127+
{
128+
cc.Add(cookie);
129+
}
127130
}
128131
catch (Exception ex)
129132
{

Diff for: MultiCommentViewer/ViewModels/EmptyBrowserProfile.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ryu_s.BrowserCookie;
2+
using System.Collections.Generic;
23
using System.Net;
34

45
namespace MultiCommentViewer
@@ -16,9 +17,9 @@ public Cookie GetCookie(string domain, string name)
1617
return null;
1718
}
1819

19-
public CookieCollection GetCookieCollection(string domain)
20+
public List<Cookie> GetCookieCollection(string domain)
2021
{
21-
return new CookieCollection();
22+
return new List<Cookie>();
2223
}
2324
}
2425
}

Diff for: NicoSitePlugin/NicoCommentProvider.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,10 @@ protected virtual CookieContainer GetCookieContainer(IBrowserProfile browserProf
594594
try
595595
{
596596
var cookies = browserProfile.GetCookieCollection("nicovideo.jp");
597-
598-
cc.Add(cookies);
597+
foreach (var cookie in cookies)
598+
{
599+
cc.Add(cookie);
600+
}
599601
}
600602
catch { }
601603
return cc;

Diff for: OpenrecSitePlugin/CommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ protected virtual CookieContainer CreateCookieContainer(IBrowserProfile browserP
8787
try
8888
{
8989
var cookies = browserProfile.GetCookieCollection("openrec.tv");
90-
cc.Add(cookies);
90+
foreach (var cookie in cookies)
91+
{
92+
cc.Add(cookie);
93+
}
9194
}
9295
catch { }
9396
return cc;

Diff for: TwicasSitePlugin/TwicasCommentProvider.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ protected virtual CookieContainer CreateCookieContainer(IBrowserProfile browserP
5959
try
6060
{
6161
var cookies = browserProfile.GetCookieCollection("twitcasting.tv");
62-
cc.Add(cookies);
62+
foreach (var cookie in cookies)
63+
{
64+
cc.Add(cookie);
65+
}
6366
}
6467
catch { }
6568
return cc;
@@ -90,13 +93,7 @@ public async Task ConnectAsync(string input, global::ryu_s.BrowserCookie.IBrowse
9093
//Info
9194
return;
9295
}
93-
_cc = new CookieContainer();
94-
try
95-
{
96-
var cookies = browserProfile.GetCookieCollection("twitcasting.tv");
97-
_cc.Add(cookies);
98-
}
99-
catch { }
96+
_cc = CreateCookieContainer(browserProfile);
10097

10198
CanConnect = false;
10299
CanDisconnect = true;

Diff for: TwitchSitePlugin/CommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ protected virtual CookieContainer GetCookieContainer(IBrowserProfile browserProf
7474
try
7575
{
7676
var cookies = browserProfile.GetCookieCollection("twitch.tv");
77-
cc.Add(cookies);
77+
foreach (var cookie in cookies)
78+
{
79+
cc.Add(cookie);
80+
}
7881
}
7982
catch (Exception ex)
8083
{

Diff for: WhowatchSitePlugin/WhowatchCommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ protected virtual CookieContainer CreateCookieContainer(IBrowserProfile browserP
359359
try
360360
{
361361
var cookies = browserProfile.GetCookieCollection("whowatch.tv");
362-
cc.Add(cookies);
362+
foreach (var cookie in cookies)
363+
{
364+
cc.Add(cookie);
365+
}
363366
}
364367
catch { }
365368
return cc;

Diff for: YouTubeLiveSitePlugin/Test2/CommentProvider.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ protected virtual CookieContainer CreateCookieContainer(IBrowserProfile browserP
115115
try
116116
{
117117
var cookies = browserProfile.GetCookieCollection("youtube.com");
118-
cc.Add(cookies);
118+
foreach (var cookie in cookies)
119+
{
120+
cc.Add(cookie);
121+
}
119122
}
120123
catch { }
121124
return cc;

0 commit comments

Comments
 (0)