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

Side by Side Diff: shell/src/PrefsCommand.cpp

Issue 29508569: Issue 5450 - don't expose std::shared_ptr<JsEngine> (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Aug. 7, 2017, 8:39 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 | « shell/src/Main.cpp ('k') | src/FilterEngine.cpp » ('j') | 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 std::string pref; 62 std::string pref;
63 argumentStream >> pref; 63 argumentStream >> pref;
64 64
65 auto current = filterEngine.GetPref(pref); 65 auto current = filterEngine.GetPref(pref);
66 if (current.IsUndefined()) 66 if (current.IsUndefined())
67 std::cout << "No such preference" << std::endl; 67 std::cout << "No such preference" << std::endl;
68 else if (current.IsString()) 68 else if (current.IsString())
69 { 69 {
70 std::string value; 70 std::string value;
71 std::getline(argumentStream, value); 71 std::getline(argumentStream, value);
72 filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value)); 72 filterEngine.SetPref(pref, filterEngine.GetJsEngine().NewValue(value));
73 } 73 }
74 else if (current.IsNumber()) 74 else if (current.IsNumber())
75 { 75 {
76 int64_t value; 76 int64_t value;
77 argumentStream >> value; 77 argumentStream >> value;
78 filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value)); 78 filterEngine.SetPref(pref, filterEngine.GetJsEngine().NewValue(value));
79 } 79 }
80 else if (current.IsBool()) 80 else if (current.IsBool())
81 { 81 {
82 bool value; 82 bool value;
83 argumentStream >> value; 83 argumentStream >> value;
84 filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value)); 84 filterEngine.SetPref(pref, filterEngine.GetJsEngine().NewValue(value));
85 } 85 }
86 else 86 else
87 std::cout << "Cannot set a preference of unknown type" << std::endl; 87 std::cout << "Cannot set a preference of unknown type" << std::endl;
88 } 88 }
89 else 89 else
90 throw NoSuchCommandError(name + " " + action); 90 throw NoSuchCommandError(name + " " + action);
91 } 91 }
92 92
93 std::string PrefsCommand::GetDescription() const 93 std::string PrefsCommand::GetDescription() const
94 { 94 {
95 return "Get and set preferences"; 95 return "Get and set preferences";
96 } 96 }
97 97
98 std::string PrefsCommand::GetUsage() const 98 std::string PrefsCommand::GetUsage() const
99 { 99 {
100 return name + " [show PREF|set PREF VALUE]"; 100 return name + " [show PREF|set PREF VALUE]";
101 } 101 }
OLDNEW
« no previous file with comments | « shell/src/Main.cpp ('k') | src/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld