blob: 2a19358b6ef52a1ea734156820da270a325d46d1 [file] [log] [blame]
// Copyright 2021 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 IOS_WEB_JS_MESSAGING_WEB_FRAME_INTERNAL_H_
#define IOS_WEB_JS_MESSAGING_WEB_FRAME_INTERNAL_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/time/time.h"
#include "base/values.h"
namespace web {
class JavaScriptContentWorld;
class WebFrameInternal {
public:
// Calls the JavaScript function |name| in the frame context in the same
// manner as the inherited CallJavaScriptFunction functions. |content_world|
// is optional, but if specified, the function will be executed within that
// world.
virtual bool CallJavaScriptFunctionInContentWorld(
const std::string& name,
const std::vector<base::Value>& parameters,
JavaScriptContentWorld* content_world) = 0;
// Calls the JavaScript function in the same condition as
// |CallJavaScriptFunctionInContentWorld| above. In addition, |callback| will
// be called with the value returned by the JavaScript execution if it
// completes before |timeout| is reached. If |timeout| is reached, |callback|
// is called with a null value.
// Returns true if function call was requested, false otherwise. Function call
// may still fail even if this function returns true. Always returns false if
// |CanCallJavaScriptFunction| is false.
virtual bool CallJavaScriptFunctionInContentWorld(
const std::string& name,
const std::vector<base::Value>& parameters,
JavaScriptContentWorld* content_world,
base::OnceCallback<void(const base::Value*)> callback,
base::TimeDelta timeout) = 0;
};
} // namespace web
#endif // IOS_WEB_JS_MESSAGING_WEB_FRAME_INTERNAL_H_