OSDN Git Service

Merge commit webブラウザとのセッション情報共有機能
[coroid/inqubus.git] / frontend / src / saccubus / net / CookieWinChromium.java
1 package saccubus.net;
2
3 import java.io.File;
4 import java.io.IOException;
5 import org.apache.commons.lang.StringUtils;
6
7 /**
8  * Windows ChromiumのCookieディレクトリを決め打ちして扱います.
9  * @author orz (saccubus)
10  * @author yuki
11  */
12 class CookieWinChromium extends Cookie {
13
14     private static final String CHROMIUM_PATH = "/Chromium/User Data/Default/Cookies";
15
16     @Override
17     protected String getNicoUserSession() throws IOException {
18         final String localAppData = System.getenv("LOCALAPPDATA");
19         if (StringUtils.isNotEmpty(localAppData)) {
20             // Win7 32bit
21             final File cookieFile = new File(localAppData + CHROMIUM_PATH);
22             if (cookieFile.isFile()) {
23                 return getUserSession("UTF-8", cookieFile);
24             }
25         }
26
27         final String userProfile = System.getenv("USERPROFILE");
28         if (StringUtils.isNotEmpty(userProfile)) {
29             // XP 32bit
30             final File cookieFile = new File(userProfile + "/Local Settings/Application Data" + CHROMIUM_PATH);
31             if (cookieFile.isFile()) {
32                 return getUserSession("UTF-8", cookieFile);
33             }
34         }
35
36         return "";
37
38     }
39 }