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

Side by Side Diff: src/plugin/PluginTabBase.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 #include "PluginClient.h" 3 #include "PluginClient.h"
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #ifdef SUPPORT_CONFIG 5 #ifdef SUPPORT_CONFIG
6 #include "PluginConfig.h" 6 #include "PluginConfig.h"
7 #endif 7 #endif
8 #include "PluginTab.h" 8 #include "PluginTab.h"
9 #include "PluginDomTraverser.h" 9 #include "PluginDomTraverser.h"
10 #include "PluginClass.h" 10 #include "PluginClass.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 m_isActivated = true; 88 m_isActivated = true;
89 } 89 }
90 90
91 91
92 void CPluginTabBase::OnUpdate() 92 void CPluginTabBase::OnUpdate()
93 { 93 {
94 m_isActivated = true; 94 m_isActivated = true;
95 } 95 }
96 96
97 97
98 bool CPluginTabBase::OnUpdateSettings(bool forceUpdate)
99 {
100 bool isUpdated = false;
101
102 CPluginSettings* settings = CPluginSettings::GetInstance();
103
104 int newSettingsVersion = settings->GetTabVersion(SETTING_TAB_SETTINGS_VERSION) ;
105 if ((s_settingsVersion != newSettingsVersion) || (forceUpdate))
106 {
107 s_settingsVersion = newSettingsVersion;
108 if (!settings->IsMainProcess())
109 {
110 settings->Read();
111
112 isUpdated = true;
113 }
114 }
115
116 return isUpdated;
117 }
118
119 bool CPluginTabBase::OnUpdateConfig()
120 {
121 bool isUpdated = false;
122
123 #ifdef SUPPORT_CONFIG
124 CPluginSettings* settings = CPluginSettings::GetInstance();
125
126 int newConfigVersion = settings->GetTabVersion(SETTING_TAB_CONFIG_VERSION);
127 if (s_configVersion != newConfigVersion)
128 {
129 s_configVersion = newConfigVersion;
130 isUpdated = true;
131 }
132
133 #endif // SUPPORT_CONFIG
134
135 return isUpdated;
136 }
137
138
139 void CPluginTabBase::OnNavigate(const CString& url) 98 void CPluginTabBase::OnNavigate(const CString& url)
140 { 99 {
141 SetDocumentUrl(url); 100 SetDocumentUrl(url);
142 101
143 102
144 #ifdef SUPPORT_FRAME_CACHING 103 #ifdef SUPPORT_FRAME_CACHING
145 ClearFrameCache(GetDocumentDomain()); 104 ClearFrameCache(GetDocumentDomain());
146 #endif 105 #endif
147 106
148 std::wstring domainString = GetDocumentDomain(); 107 std::wstring domainString = GetDocumentDomain();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 threadInfo.Format(L"%d.%d", ::GetCurrentProcessId(), ::GetCurrentThreadId()); 306 threadInfo.Format(L"%d.%d", ::GetCurrentProcessId(), ::GetCurrentThreadId());
348 307
349 CString debugText; 308 CString debugText;
350 309
351 debugText += L"=============================================================== ================="; 310 debugText += L"=============================================================== =================";
352 debugText += L"\nTAB THREAD " + threadInfo; 311 debugText += L"\nTAB THREAD " + threadInfo;
353 debugText += L"\n============================================================= ==================="; 312 debugText += L"\n============================================================= ===================";
354 313
355 DEBUG_GENERAL(debugText) 314 DEBUG_GENERAL(debugText)
356 315
357 CPluginClient* client = CPluginClient::GetInstance();
358
359 client->SetLocalization();
360
361 // Force loading/creation of config
362 #ifdef SUPPORT_CONFIG
363 CPluginConfig* config = CPluginConfig::GetInstance();
364
365
366 #endif // SUPPORT_CONFIG
367
368 // -------------------------------------------------------------------- 316 // --------------------------------------------------------------------
369 // Tab loop 317 // Tab loop
370 // -------------------------------------------------------------------- 318 // --------------------------------------------------------------------
371 319
372 DWORD loopCount = 0; 320 DWORD loopCount = 0;
373 DWORD tabLoopIteration = 1; 321 DWORD tabLoopIteration = 1;
374 322
375 while (!tab->m_isThreadDone) 323 while (!tab->m_isThreadDone)
376 { 324 {
377 #ifdef ENABLE_DEBUG_THREAD 325 #ifdef ENABLE_DEBUG_THREAD
378 CStringA sTabLoopIteration; 326 CStringA sTabLoopIteration;
379 sTabLoopIteration.Format("%u", tabLoopIteration); 327 sTabLoopIteration.Format("%u", tabLoopIteration);
380 328
381 DEBUG_THREAD("-------------------------------------------------------------- ------------------") 329 DEBUG_THREAD("-------------------------------------------------------------- ------------------")
382 DEBUG_THREAD("Loop iteration " + sTabLoopIteration); 330 DEBUG_THREAD("Loop iteration " + sTabLoopIteration);
383 DEBUG_THREAD("-------------------------------------------------------------- ------------------") 331 DEBUG_THREAD("-------------------------------------------------------------- ------------------")
384 #endif 332 #endif
385 // Update settings from file
386 if (tab->m_isActivated) 333 if (tab->m_isActivated)
387 { 334 {
388 bool isChanged = false; 335 bool isChanged = false;
389 336
390 settings->RefreshTab();
391
392 tab->OnUpdateSettings(false);
393
394 int newDictionaryVersion = settings->GetTabVersion(SETTING_TAB_DICTIONAR Y_VERSION);
395 if (s_dictionaryVersion != newDictionaryVersion)
396 {
397 s_dictionaryVersion = newDictionaryVersion;
398 client->SetLocalization();
399 isChanged = true;
400 }
401
402 isChanged = tab->OnUpdateConfig() ? true : isChanged;
403
404 #ifdef SUPPORT_WHITELIST
405 int newWhitelistVersion = settings->GetTabVersion(SETTING_TAB_WHITELIST_ VERSION);
406 if (s_whitelistVersion != newWhitelistVersion)
407 {
408 s_whitelistVersion = newWhitelistVersion;
409 settings->RefreshWhitelist();
410 isChanged = true;
411 }
412 #endif // SUPPORT_WHITELIST
413
414 #ifdef SUPPORT_FILTER
415 int newFilterVersion = settings->GetTabVersion(SETTING_TAB_FILTER_VERSIO N);
416 if (s_filterVersion != newFilterVersion)
417 {
418 s_filterVersion = newFilterVersion;
419 isChanged = true;
420 }
421 #endif
422 if (isChanged) 337 if (isChanged)
423 { 338 {
424 tab->m_plugin->UpdateStatusBar(); 339 tab->m_plugin->UpdateStatusBar();
425 } 340 }
426 341
427 tab->m_isActivated = false; 342 tab->m_isActivated = false;
428 } 343 }
429 344
430 // -------------------------------------------------------------------- 345 // --------------------------------------------------------------------
431 // End loop 346 // End loop
(...skipping 11 matching lines...) Expand all
443 358
444 // Non-hanging sleep 359 // Non-hanging sleep
445 Sleep(50); 360 Sleep(50);
446 } 361 }
447 362
448 tabLoopIteration++; 363 tabLoopIteration++;
449 } 364 }
450 365
451 return 0; 366 return 0;
452 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld