2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 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 CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <map>
|
2019-05-24 22:23:43 +02:00
|
|
|
#include <memory>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "include/cef_browser.h"
|
|
|
|
#include "include/cef_client.h"
|
2012-04-27 23:19:06 +02:00
|
|
|
#include "libcef/common/tracker.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/renderer/frame_impl.h"
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
#include "third_party/blink/public/web/web_view_observer.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
namespace blink {
|
2017-07-27 01:19:27 +02:00
|
|
|
class WebFrame;
|
2017-05-31 17:33:30 +02:00
|
|
|
class WebNode;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace blink
|
2017-05-31 17:33:30 +02:00
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
namespace content {
|
|
|
|
class RenderView;
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Renderer plumbing for CEF features. There is a one-to-one relationship
|
|
|
|
// between RenderView on the renderer side and RenderViewHost on the browser
|
|
|
|
// side.
|
|
|
|
//
|
2019-05-24 22:23:43 +02:00
|
|
|
// RenderViewObserver: Interface for observing RenderView notifications.
|
2021-03-04 23:36:57 +01:00
|
|
|
class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
|
|
|
static CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
|
|
|
static CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* frame);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// CefBrowser methods.
|
2021-05-21 03:42:58 +02:00
|
|
|
bool IsValid() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowserHost> GetHost() override;
|
|
|
|
bool CanGoBack() override;
|
|
|
|
void GoBack() override;
|
|
|
|
bool CanGoForward() override;
|
|
|
|
void GoForward() override;
|
|
|
|
bool IsLoading() override;
|
|
|
|
void Reload() override;
|
|
|
|
void ReloadIgnoreCache() override;
|
|
|
|
void StopLoad() override;
|
|
|
|
int GetIdentifier() override;
|
|
|
|
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
|
|
|
bool IsPopup() override;
|
|
|
|
bool HasDocument() override;
|
|
|
|
CefRefPtr<CefFrame> GetMainFrame() override;
|
|
|
|
CefRefPtr<CefFrame> GetFocusedFrame() override;
|
|
|
|
CefRefPtr<CefFrame> GetFrame(int64 identifier) override;
|
|
|
|
CefRefPtr<CefFrame> GetFrame(const CefString& name) override;
|
|
|
|
size_t GetFrameCount() override;
|
|
|
|
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
|
|
|
|
void GetFrameNames(std::vector<CefString>& names) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
CefBrowserImpl(content::RenderView* render_view,
|
|
|
|
int browser_id,
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_popup,
|
|
|
|
bool is_windowless);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefBrowserImpl() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-06-11 17:52:49 +02:00
|
|
|
// Returns the matching CefFrameImpl reference or creates a new one.
|
2017-07-27 01:19:27 +02:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(blink::WebLocalFrame* frame);
|
2016-01-06 20:20:54 +01:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(int64_t frame_id);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
// Frame objects will be deleted immediately before the frame is closed.
|
2016-01-06 20:20:54 +01:00
|
|
|
void AddFrameObject(int64_t frame_id, CefTrackNode* tracked_object);
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
int browser_id() const { return browser_id_; }
|
|
|
|
bool is_popup() const { return is_popup_; }
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_windowless() const { return is_windowless_; }
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
// blink::WebViewObserver methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnDestruct() override;
|
2019-05-24 22:23:43 +02:00
|
|
|
void FrameDetached(int64_t frame_id);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-09-13 01:36:54 +02:00
|
|
|
void OnLoadingStateChange(bool isLoading);
|
2019-05-24 22:23:43 +02:00
|
|
|
|
|
|
|
private:
|
2012-12-30 12:17:49 +01:00
|
|
|
// ID of the browser that this RenderView is associated with. During loading
|
|
|
|
// of cross-origin requests multiple RenderViews may be associated with the
|
|
|
|
// same browser ID.
|
|
|
|
int browser_id_;
|
2012-04-03 03:34:16 +02:00
|
|
|
bool is_popup_;
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_windowless_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Map of unique frame ids to CefFrameImpl references.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<int64, CefRefPtr<CefFrameImpl>> FrameMap;
|
2012-04-03 03:34:16 +02:00
|
|
|
FrameMap frames_;
|
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
// Map of unique frame ids to CefTrackManager objects that need to be cleaned
|
|
|
|
// up when the frame is deleted.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<int64, CefRefPtr<CefTrackManager>> FrameObjectMap;
|
2012-04-27 23:19:06 +02:00
|
|
|
FrameObjectMap frame_objects_;
|
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
struct LoadingState {
|
|
|
|
LoadingState(bool is_loading, bool can_go_back, bool can_go_forward)
|
|
|
|
: is_loading_(is_loading),
|
|
|
|
can_go_back_(can_go_back),
|
|
|
|
can_go_forward_(can_go_forward) {}
|
|
|
|
|
|
|
|
bool IsMatch(bool is_loading, bool can_go_back, bool can_go_forward) const {
|
|
|
|
return is_loading_ == is_loading && can_go_back_ == can_go_back &&
|
|
|
|
can_go_forward_ == can_go_forward;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_loading_;
|
|
|
|
bool can_go_back_;
|
|
|
|
bool can_go_forward_;
|
|
|
|
};
|
|
|
|
std::unique_ptr<LoadingState> last_loading_state_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_
|