mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Returns fake preferences if PrefValue::Missing.
If the pref_map().get() enum returns PrefValue::Missing, then fake values are returned just like before.
This commit is contained in:
parent
c8d911817f
commit
9048185a10
1 changed files with 40 additions and 1 deletions
|
@ -67,11 +67,50 @@ impl Actor for PreferenceActor {
|
|||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Missing => ActorMessageStatus::Ignored,
|
||||
PrefValue::Missing => handle_missing_preference(self.name(), msg_type, stream),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// if the preferences are missing from pref_map then we return a
|
||||
// fake preference response based on msg_type.
|
||||
fn handle_missing_preference(
|
||||
name: String,
|
||||
msg_type: &str,
|
||||
stream: &mut TcpStream,
|
||||
) -> ActorMessageStatus {
|
||||
match msg_type {
|
||||
"getBoolPref" => {
|
||||
let reply = BoolReply {
|
||||
from: name,
|
||||
value: false,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
"getCharPref" => {
|
||||
let reply = CharReply {
|
||||
from: name,
|
||||
value: "".to_owned(),
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
"getIntPref" => {
|
||||
let reply = IntReply {
|
||||
from: name,
|
||||
value: 0,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
_ => ActorMessageStatus::Ignored,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct BoolReply {
|
||||
from: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue