Skip to content

Commit

Permalink
CR feedback flutter#2
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkezone committed Apr 18, 2021
1 parent 9327ec1 commit 721f922
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
5 changes: 3 additions & 2 deletions shell/platform/windows/flutter_project_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ UniqueAotDataPtr FlutterProjectBundle::LoadAotData(

FlutterProjectBundle::~FlutterProjectBundle() {}

void FlutterProjectBundle::SetSwitches(std::vector<std::string> switches) {
engine_switches_ = std::move(switches);
void FlutterProjectBundle::SetSwitches(
std::vector<std::string> const& switches) {
engine_switches_ = switches;
}

const std::vector<std::string> FlutterProjectBundle::GetSwitches() {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/flutter_project_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FlutterProjectBundle {
const std::vector<std::string> GetSwitches();

// Sets engine switches.
void SetSwitches(std::vector<std::string> switches);
void SetSwitches(std::vector<std::string> const& switches);

// Attempts to load AOT data for this bundle. The returned data must be
// retained until any engine instance it is passed to has been shut down.
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/windows/flutter_windows_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ FlutterWindowsEngine::~FlutterWindowsEngine() {
Stop();
}

void FlutterWindowsEngine::SetSwitches(std::vector<std::string> switches) {
void FlutterWindowsEngine::SetSwitches(
std::vector<std::string> const& switches) {
project_->SetSwitches(switches);
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/flutter_windows_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FlutterWindowsEngine {
FlutterDesktopOnPluginRegistrarDestroyed callback);

// Sets switches member to the given switches.
void SetSwitches(std::vector<std::string> switches);
void SetSwitches(std::vector<std::string> const& switches);

FlutterDesktopMessengerRef messenger() { return messenger_.get(); }

Expand Down
25 changes: 11 additions & 14 deletions shell/platform/windows/flutter_windows_winuwp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ static flutter::FlutterWindowsEngine* EngineFromHandle(
}

// Resturns a list of discrete arguments splitting the input using a ",".
std::vector<std::string> split(std::string const s) {
std::vector<std::string> SplitCommaSeparatedString(const std::string& s) {
// Split by ','.
std::vector<std::string> components;
std::istringstream stream(s);
std::string component;
while (getline(stream, component, ',')) {
components.push_back(component);
}
return (std::move(components));
return (components);
}

FlutterDesktopViewControllerRef
Expand All @@ -64,19 +64,16 @@ FlutterDesktopViewControllerCreateFromCoreWindow(
std::vector<std::string> engine_switches;
winrt::Windows::ApplicationModel::Activation::LaunchActivatedEventArgs launch{
nullptr};
switch (arg_interface.Kind()) {
case winrt::Windows::ApplicationModel::Activation::ActivationKind::Launch:
launch = arg_interface.as<winrt::Windows::ApplicationModel::Activation::
LaunchActivatedEventArgs>();
if (launch != nullptr) {
std::string launchargs = winrt::to_string(launch.Arguments());
if (!launchargs.empty()) {
engine_switches = split(launchargs);
}
if (arg_interface.Kind() ==
winrt::Windows::ApplicationModel::Activation::ActivationKind::Launch) {
launch = arg_interface.as<winrt::Windows::ApplicationModel::Activation::
LaunchActivatedEventArgs>();
if (launch != nullptr) {
std::string launchargs = winrt::to_string(launch.Arguments());
if (!launchargs.empty()) {
engine_switches = SplitCommaSeparatedString(launchargs);
}
break;
default:
break;
}
}

state->view->GetEngine()->SetSwitches(engine_switches);
Expand Down

0 comments on commit 721f922

Please sign in to comment.