Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 83af633

Browse files
committed
Fix windows newlines
1 parent c3060cd commit 83af633

File tree

5 files changed

+497
-497
lines changed

5 files changed

+497
-497
lines changed
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
// Copyright 2013 The Flutter Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
4-
5-
#include "flutter/shell/platform/windows/platform_handler.h"
6-
7-
#include "flutter/shell/platform/common/json_method_codec.h"
8-
9-
static constexpr char kChannelName[] = "flutter/platform";
10-
11-
static constexpr char kGetClipboardDataMethod[] = "Clipboard.getData";
12-
static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings";
13-
static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData";
14-
15-
static constexpr char kTextPlainFormat[] = "text/plain";
16-
static constexpr char kTextKey[] = "text";
17-
18-
static constexpr char kUnknownClipboardFormatMessage[] =
19-
"Unknown clipboard format";
20-
21-
namespace flutter {
22-
23-
PlatformHandler::PlatformHandler(BinaryMessenger* messenger)
24-
: channel_(std::make_unique<MethodChannel<rapidjson::Document>>(
25-
messenger,
26-
kChannelName,
27-
&JsonMethodCodec::GetInstance())) {
28-
channel_->SetMethodCallHandler(
29-
[this](const MethodCall<rapidjson::Document>& call,
30-
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
31-
HandleMethodCall(call, std::move(result));
32-
});
33-
}
34-
35-
PlatformHandler::~PlatformHandler() = default;
36-
37-
void PlatformHandler::HandleMethodCall(
38-
const MethodCall<rapidjson::Document>& method_call,
39-
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
40-
const std::string& method = method_call.method_name();
41-
if (method.compare(kGetClipboardDataMethod) == 0) {
42-
// Only one string argument is expected.
43-
const rapidjson::Value& format = method_call.arguments()[0];
44-
45-
if (strcmp(format.GetString(), kTextPlainFormat) != 0) {
46-
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
47-
return;
48-
}
49-
GetPlainText(std::move(result), kTextKey);
50-
} else if (method.compare(kHasStringsClipboardMethod) == 0) {
51-
// Only one string argument is expected.
52-
const rapidjson::Value& format = method_call.arguments()[0];
53-
54-
if (strcmp(format.GetString(), kTextPlainFormat) != 0) {
55-
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
56-
return;
57-
}
58-
HasStrings(std::move(result));
59-
} else if (method.compare(kSetClipboardDataMethod) == 0) {
60-
const rapidjson::Value& document = *method_call.arguments();
61-
rapidjson::Value::ConstMemberIterator itr = document.FindMember(kTextKey);
62-
if (itr == document.MemberEnd()) {
63-
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
64-
return;
65-
}
66-
SetPlainText(itr->value.GetString(), std::move(result));
67-
} else {
68-
result->NotImplemented();
69-
}
70-
}
71-
72-
} // namespace flutter
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/shell/platform/windows/platform_handler.h"
6+
7+
#include "flutter/shell/platform/common/json_method_codec.h"
8+
9+
static constexpr char kChannelName[] = "flutter/platform";
10+
11+
static constexpr char kGetClipboardDataMethod[] = "Clipboard.getData";
12+
static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings";
13+
static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData";
14+
15+
static constexpr char kTextPlainFormat[] = "text/plain";
16+
static constexpr char kTextKey[] = "text";
17+
18+
static constexpr char kUnknownClipboardFormatMessage[] =
19+
"Unknown clipboard format";
20+
21+
namespace flutter {
22+
23+
PlatformHandler::PlatformHandler(BinaryMessenger* messenger)
24+
: channel_(std::make_unique<MethodChannel<rapidjson::Document>>(
25+
messenger,
26+
kChannelName,
27+
&JsonMethodCodec::GetInstance())) {
28+
channel_->SetMethodCallHandler(
29+
[this](const MethodCall<rapidjson::Document>& call,
30+
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
31+
HandleMethodCall(call, std::move(result));
32+
});
33+
}
34+
35+
PlatformHandler::~PlatformHandler() = default;
36+
37+
void PlatformHandler::HandleMethodCall(
38+
const MethodCall<rapidjson::Document>& method_call,
39+
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
40+
const std::string& method = method_call.method_name();
41+
if (method.compare(kGetClipboardDataMethod) == 0) {
42+
// Only one string argument is expected.
43+
const rapidjson::Value& format = method_call.arguments()[0];
44+
45+
if (strcmp(format.GetString(), kTextPlainFormat) != 0) {
46+
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
47+
return;
48+
}
49+
GetPlainText(std::move(result), kTextKey);
50+
} else if (method.compare(kHasStringsClipboardMethod) == 0) {
51+
// Only one string argument is expected.
52+
const rapidjson::Value& format = method_call.arguments()[0];
53+
54+
if (strcmp(format.GetString(), kTextPlainFormat) != 0) {
55+
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
56+
return;
57+
}
58+
HasStrings(std::move(result));
59+
} else if (method.compare(kSetClipboardDataMethod) == 0) {
60+
const rapidjson::Value& document = *method_call.arguments();
61+
rapidjson::Value::ConstMemberIterator itr = document.FindMember(kTextKey);
62+
if (itr == document.MemberEnd()) {
63+
result->Error(kClipboardError, kUnknownClipboardFormatMessage);
64+
return;
65+
}
66+
SetPlainText(itr->value.GetString(), std::move(result));
67+
} else {
68+
result->NotImplemented();
69+
}
70+
}
71+
72+
} // namespace flutter
Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
1-
// Copyright 2013 The Flutter Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
4-
5-
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_
6-
#define FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_
7-
8-
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
9-
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
10-
#include "rapidjson/document.h"
11-
12-
namespace flutter {
13-
14-
class FlutterWindowsView;
15-
16-
// Handler for internal system channels.
17-
class PlatformHandler {
18-
public:
19-
explicit PlatformHandler(BinaryMessenger* messenger);
20-
21-
virtual ~PlatformHandler();
22-
23-
// Creates a new platform handler using the given messenger and view.
24-
static std::unique_ptr<PlatformHandler> Create(BinaryMessenger* messenger,
25-
FlutterWindowsView* view);
26-
27-
protected:
28-
// Gets plain text from the clipboard and provides it to |result| as the
29-
// value in a dictionary with the given |key|.
30-
virtual void GetPlainText(
31-
std::unique_ptr<MethodResult<rapidjson::Document>> result,
32-
std::string_view key) = 0;
33-
34-
// Provides a boolean to |result| as the value in a dictionary at key
35-
// "value" representing whether or not the clipboard has a non-empty string.
36-
virtual void HasStrings(
37-
std::unique_ptr<MethodResult<rapidjson::Document>> result) = 0;
38-
39-
// Sets the clipboard's plain text to |text|, and reports the result (either
40-
// an error, or null for success) to |result|.
41-
virtual void SetPlainText(
42-
const std::string& text,
43-
std::unique_ptr<MethodResult<rapidjson::Document>> result) = 0;
44-
45-
// A error type to use for error responses.
46-
static constexpr char kClipboardError[] = "Clipboard error";
47-
48-
private:
49-
// Called when a method is called on |channel_|;
50-
void HandleMethodCall(
51-
const MethodCall<rapidjson::Document>& method_call,
52-
std::unique_ptr<MethodResult<rapidjson::Document>> result);
53-
54-
// The MethodChannel used for communication with the Flutter engine.
55-
std::unique_ptr<MethodChannel<rapidjson::Document>> channel_;
56-
};
57-
58-
} // namespace flutter
59-
60-
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_
6+
#define FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_
7+
8+
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
9+
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
10+
#include "rapidjson/document.h"
11+
12+
namespace flutter {
13+
14+
class FlutterWindowsView;
15+
16+
// Handler for internal system channels.
17+
class PlatformHandler {
18+
public:
19+
explicit PlatformHandler(BinaryMessenger* messenger);
20+
21+
virtual ~PlatformHandler();
22+
23+
// Creates a new platform handler using the given messenger and view.
24+
static std::unique_ptr<PlatformHandler> Create(BinaryMessenger* messenger,
25+
FlutterWindowsView* view);
26+
27+
protected:
28+
// Gets plain text from the clipboard and provides it to |result| as the
29+
// value in a dictionary with the given |key|.
30+
virtual void GetPlainText(
31+
std::unique_ptr<MethodResult<rapidjson::Document>> result,
32+
std::string_view key) = 0;
33+
34+
// Provides a boolean to |result| as the value in a dictionary at key
35+
// "value" representing whether or not the clipboard has a non-empty string.
36+
virtual void HasStrings(
37+
std::unique_ptr<MethodResult<rapidjson::Document>> result) = 0;
38+
39+
// Sets the clipboard's plain text to |text|, and reports the result (either
40+
// an error, or null for success) to |result|.
41+
virtual void SetPlainText(
42+
const std::string& text,
43+
std::unique_ptr<MethodResult<rapidjson::Document>> result) = 0;
44+
45+
// A error type to use for error responses.
46+
static constexpr char kClipboardError[] = "Clipboard error";
47+
48+
private:
49+
// Called when a method is called on |channel_|;
50+
void HandleMethodCall(
51+
const MethodCall<rapidjson::Document>& method_call,
52+
std::unique_ptr<MethodResult<rapidjson::Document>> result);
53+
54+
// The MethodChannel used for communication with the Flutter engine.
55+
std::unique_ptr<MethodChannel<rapidjson::Document>> channel_;
56+
};
57+
58+
} // namespace flutter
59+
60+
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_HANDLER_H_

0 commit comments

Comments
 (0)