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

Side by Side Diff: src/FilterEngine.cpp

Issue 29397596: Issue 5040 - fix saving of allowed_connection_type preference (Closed)
Patch Set: Created March 29, 2017, 10:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/prefs.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 this, callback, std::placeholders::_1)); 478 this, callback, std::placeholders::_1));
479 } 479 }
480 480
481 void FilterEngine::RemoveFilterChangeCallback() 481 void FilterEngine::RemoveFilterChangeCallback()
482 { 482 {
483 jsEngine->RemoveEventCallback("filterChange"); 483 jsEngine->RemoveEventCallback("filterChange");
484 } 484 }
485 485
486 void FilterEngine::SetAllowedConnectionType(const std::string* value) 486 void FilterEngine::SetAllowedConnectionType(const std::string* value)
487 { 487 {
488 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : nullpt r); 488 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : jsEngi ne->NewValue(""));
489 } 489 }
490 490
491 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const 491 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const
492 { 492 {
493 auto prefValue = GetPref("allowed_connection_type"); 493 auto prefValue = GetPref("allowed_connection_type");
494 if (prefValue->IsUndefined()) 494 if (prefValue->AsString().empty())
495 return nullptr; 495 return nullptr;
496 return std::unique_ptr<std::string>(new std::string(prefValue->AsString())); 496 return std::unique_ptr<std::string>(new std::string(prefValue->AsString()));
497 } 497 }
498 498
499 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params) 499 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js ValueList& params)
500 { 500 {
501 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : ""); 501 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS tring() : "");
502 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); 502 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false));
503 callback(action, item); 503 callback(action, item);
504 } 504 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 554 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
555 if (filter) 555 if (filter)
556 { 556 {
557 return filter; 557 return filter;
558 } 558 }
559 currentUrl = parentUrl; 559 currentUrl = parentUrl;
560 } 560 }
561 while (urlIterator != documentUrls.end()); 561 while (urlIterator != documentUrls.end());
562 return FilterPtr(); 562 return FilterPtr();
563 } 563 }
OLDNEW
« no previous file with comments | « lib/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld