runtime_controller.h 2.1 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
7 8

#include <memory>
9

10
#include "flutter/flow/layers/layer_tree.h"
11
#include "flutter/lib/ui/ui_dart_state.h"
12
#include "flutter/lib/ui/window/pointer_data_packet.h"
13 14
#include "flutter/lib/ui/window/window.h"
#include "lib/ftl/macros.h"
15 16

namespace blink {
17
class DartController;
18
class DartLibraryProvider;
19
class Scene;
20
class RuntimeDelegate;
21
class View;
22
class Window;
23

24
class RuntimeController : public WindowClient, public IsolateClient {
25
 public:
26 27 28 29 30
  static std::unique_ptr<RuntimeController> Create(RuntimeDelegate* client);
  ~RuntimeController();

  void CreateDartController(const std::string& script_uri);
  DartController* dart_controller() const { return dart_controller_.get(); }
31

32
  void SetViewportMetrics(const ViewportMetrics& metrics);
33
  void SetLocale(const std::string& language_code,
A
Adam Barth 已提交
34
                 const std::string& country_code);
35
  void SetSemanticsEnabled(bool enabled);
36

A
Adam Barth 已提交
37
  void BeginFrame(ftl::TimePoint frame_time);
38

A
Adam Barth 已提交
39
  void DispatchPlatformMessage(ftl::RefPtr<PlatformMessage> message);
40 41
  void DispatchPointerDataPacket(const PointerDataPacket& packet);
  void DispatchSemanticsAction(int32_t id, SemanticsAction action);
42

43 44
  Dart_Port GetMainPort();

45 46
  std::string GetIsolateName();

47 48
  bool HasLivePorts();

49
 private:
50
  explicit RuntimeController(RuntimeDelegate* client);
51

52 53 54 55
  Window* GetWindow();

  void ScheduleFrame() override;
  void Render(Scene* scene) override;
56
  void UpdateSemantics(SemanticsUpdate* update) override;
57
  void HandlePlatformMessage(ftl::RefPtr<PlatformMessage> message) override;
A
Adam Barth 已提交
58

59 60
  void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;

61
  RuntimeDelegate* client_;
62
  ViewportMetrics viewport_metrics_;
63 64
  std::string language_code_;
  std::string country_code_;
65
  bool semantics_enabled_ = false;
66
  std::unique_ptr<DartController> dart_controller_;
A
Adam Barth 已提交
67

68
  FTL_DISALLOW_COPY_AND_ASSIGN(RuntimeController);
69 70
};

A
Adam Barth 已提交
71
}  // namespace blink
72

73
#endif  // FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_