dart_library_provider_files.h 1.3 KB
Newer Older
1 2 3 4 5 6 7 8
// 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.

#ifndef SKY_SHELL_DART_DART_LIBRARY_PROVIDER_FILES_H_
#define SKY_SHELL_DART_DART_LIBRARY_PROVIDER_FILES_H_

#include "base/files/file_path.h"
9 10
#include "flutter/tonic/dart_library_provider.h"
#include "flutter/tonic/parsers/packages_map.h"
11 12 13 14 15 16

namespace sky {
namespace shell {

class DartLibraryProviderFiles : public blink::DartLibraryProvider {
 public:
17
  DartLibraryProviderFiles();
18 19
  ~DartLibraryProviderFiles() override;

20 21
  void LoadPackagesMap(const base::FilePath& packages);

22 23
 protected:
  // |DartLibraryProvider| implementation:
24
  void GetLibraryAsStream(const std::string& name,
25 26 27 28
                          blink::DataPipeConsumerCallback callback) override;
  Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url) override;

 private:
29 30 31
  base::FilePath GetFilePathForURL(std::string url);
  base::FilePath GetFilePathForPackageURL(std::string url);
  base::FilePath GetFilePathForFileURL(std::string url);
32

33 34
  base::FilePath packages_;
  tonic::PackagesMap packages_map_;
35 36 37 38 39 40 41 42

  DISALLOW_COPY_AND_ASSIGN(DartLibraryProviderFiles);
};

}  // namespace shell
}  // namespace sky

#endif  // SKY_SHELL_DART_DART_LIBRARY_PROVIDER_FILES_H_