| package engine |
|
|
| |
| |
| type RouteRule interface { |
| |
| Name() string |
| |
| Decide(op Capability, url string) Decision |
| } |
|
|
| |
|
|
| |
| |
| type CapabilityRule struct{} |
|
|
| func (CapabilityRule) Name() string { return "capability" } |
|
|
| func (CapabilityRule) Decide(op Capability, _ string) Decision { |
| switch op { |
| case CapScreenshot, CapPDF, CapEvaluate, CapCookies: |
| return UseChrome |
| } |
| return Undecided |
| } |
|
|
| |
| |
| type ContentHintRule struct{} |
|
|
| func (ContentHintRule) Name() string { return "content-hint" } |
|
|
| func (ContentHintRule) Decide(op Capability, url string) Decision { |
| if op != CapNavigate && op != CapSnapshot && op != CapText { |
| return Undecided |
| } |
| |
| |
| for _, ext := range []string{".html", ".htm", ".xml", ".txt", ".md"} { |
| if len(url) > len(ext) && url[len(url)-len(ext):] == ext { |
| return UseLite |
| } |
| } |
| return Undecided |
| } |
|
|
| |
| |
| type DefaultLiteRule struct{} |
|
|
| func (DefaultLiteRule) Name() string { return "default-lite" } |
|
|
| func (DefaultLiteRule) Decide(op Capability, _ string) Decision { |
| switch op { |
| case CapNavigate, CapSnapshot, CapText, CapClick, CapType: |
| return UseLite |
| } |
| return Undecided |
| } |
|
|
| |
| |
| type DefaultChromeRule struct{} |
|
|
| func (DefaultChromeRule) Name() string { return "default-chrome" } |
|
|
| func (DefaultChromeRule) Decide(_ Capability, _ string) Decision { |
| return UseChrome |
| } |
|
|