Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginClientBase.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: Minor CallEngine refactoring Created July 26, 2013, 2:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 // Internet / FTP 3 // Internet / FTP
4 #include <wininet.h> 4 #include <wininet.h>
5 5
6 // IP adapter 6 // IP adapter
7 #include <iphlpapi.h> 7 #include <iphlpapi.h>
8 8
9 #include "PluginSettings.h" 9 #include "PluginSettings.h"
10 #include "PluginSystem.h" 10 #include "PluginSystem.h"
11 #include "PluginHttpRequest.h"
12 #include "PluginMutex.h" 11 #include "PluginMutex.h"
13 #include "PluginClass.h" 12 #include "PluginClass.h"
14 13
15 #include "PluginClientBase.h" 14 #include "PluginClientBase.h"
16 15
17 // IP adapter 16 // IP adapter
18 #pragma comment(lib, "IPHLPAPI.lib") 17 #pragma comment(lib, "IPHLPAPI.lib")
19 18
20 // IE functions 19 // IE functions
21 #pragma comment(lib, "iepmapi.lib") 20 #pragma comment(lib, "iepmapi.lib")
(...skipping 14 matching lines...) Expand all
36 } 35 }
37 36
38 37
39 CPluginClientBase::~CPluginClientBase() 38 CPluginClientBase::~CPluginClientBase()
40 { 39 {
41 } 40 }
42 41
43 42
44 bool CPluginClientBase::IsValidDomain(const CString& domain) 43 bool CPluginClientBase::IsValidDomain(const CString& domain)
45 { 44 {
46 return domain != ABPDOMAIN && 45 return domain != L"about:blank" &&
47 domain != USERS_HOST &&
48 domain != L"about:blank" &&
49 domain != L"about:tabs" && 46 domain != L"about:tabs" &&
50 domain.Find(L"javascript:") != 0 && 47 domain.Find(L"javascript:") != 0 &&
51 !domain.IsEmpty(); 48 !domain.IsEmpty();
52 } 49 }
53 50
54 51
55 CString& CPluginClientBase::UnescapeUrl(CString& url) 52 CString& CPluginClientBase::UnescapeUrl(CString& url)
56 { 53 {
57 CString unescapedUrl; 54 CString unescapedUrl;
58 DWORD cb = 2048; 55 DWORD cb = 2048;
59 56
60 if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(c b), &cb, 0))) 57 if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(c b), &cb, 0)))
61 { 58 {
62 unescapedUrl.ReleaseBuffer(); 59 unescapedUrl.ReleaseBuffer();
63 unescapedUrl.Truncate(cb); 60 unescapedUrl.Truncate(cb);
64 61
65 url.ReleaseBuffer(); 62 url.ReleaseBuffer();
66 url = unescapedUrl; 63 url = unescapedUrl;
67 } 64 }
68 65
69 return url; 66 return url;
70 } 67 }
71 68
72 69
73 void CPluginClientBase::SetLocalization()
74 {
75 CPluginSystem* system = CPluginSystem::GetInstance();
76 CString browserLanguage = system->GetBrowserLanguage();
77
78 CPluginSettings* settings = CPluginSettings::GetInstance();
79 if (settings->IsMainProcess() && settings->IsMainThread() && !settings->Has(SE TTING_LANGUAGE))
80 {
81 // TODO: We might want to set this to "en" if browserLanguage is not in filt erLanguagesList
82 settings->SetString(SETTING_LANGUAGE, browserLanguage);
83 settings->Write();
84 }
85 }
86
87
88 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread Id) 70 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread Id)
89 { 71 {
90 // Prevent circular references 72 // Prevent circular references
91 if (CPluginSettings::HasInstance() && isAsync) 73 if (CPluginSettings::HasInstance() && isAsync)
92 { 74 {
93 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); 75 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId);
94 76
95 CString pluginError; 77 CString pluginError;
96 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); 78 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid);
97 79
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 118
137 hasError = true; 119 hasError = true;
138 120
139 s_pluginErrors.erase(it); 121 s_pluginErrors.erase(it);
140 } 122 }
141 } 123 }
142 s_criticalSectionLocal.Unlock(); 124 s_criticalSectionLocal.Unlock();
143 125
144 return hasError; 126 return hasError;
145 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld