2012-12-30 12:17:49 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework 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_BROWSER_BROWSER_INFO_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_BROWSER_INFO_H_
|
|
|
|
#pragma once
|
|
|
|
|
2013-07-15 22:25:59 +02:00
|
|
|
#include <set>
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
|
|
|
|
// CefBrowserInfo is used to associate a browser ID and render view/process
|
|
|
|
// IDs with a particular CefBrowserHostImpl. Render view/process IDs may change
|
|
|
|
// during the lifetime of a single CefBrowserHostImpl.
|
|
|
|
//
|
|
|
|
// CefBrowserInfo objects are managed by CefContentBrowserClient and should not
|
|
|
|
// be created directly.
|
|
|
|
class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
|
|
|
public:
|
|
|
|
CefBrowserInfo(int browser_id, bool is_popup);
|
|
|
|
|
|
|
|
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_; }
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_mime_handler_view() const { return is_mime_handler_view_; }
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
void set_windowless(bool windowless);
|
2015-07-16 23:40:01 +02:00
|
|
|
void set_mime_handler_view(bool mime_handler_view);
|
2013-04-16 21:23:00 +02:00
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
// Adds an ID pair if it doesn't already exist.
|
|
|
|
void add_render_view_id(int render_process_id, int render_routing_id);
|
|
|
|
void add_render_frame_id(int render_process_id, int render_routing_id);
|
2012-12-30 12:17:49 +01:00
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
// Remove an ID pair if it exists.
|
|
|
|
void remove_render_view_id(int render_process_id, int render_routing_id);
|
|
|
|
void remove_render_frame_id(int render_process_id, int render_routing_id);
|
|
|
|
|
|
|
|
// Returns true if this browser matches the specified ID pair.
|
|
|
|
bool is_render_view_id_match(int render_process_id, int render_routing_id);
|
|
|
|
bool is_render_frame_id_match(int render_process_id, int render_routing_id);
|
2012-12-30 12:17:49 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser();
|
|
|
|
void set_browser(CefRefPtr<CefBrowserHostImpl> browser);
|
|
|
|
|
|
|
|
private:
|
2014-11-12 20:25:15 +01:00
|
|
|
friend class base::RefCountedThreadSafe<CefBrowserInfo>;
|
|
|
|
|
|
|
|
~CefBrowserInfo();
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
typedef std::set<std::pair<int, int> > RenderIdSet;
|
|
|
|
|
|
|
|
void add_render_id(RenderIdSet* id_set,
|
|
|
|
int render_process_id,
|
|
|
|
int render_routing_id);
|
|
|
|
void remove_render_id(RenderIdSet* id_set,
|
|
|
|
int render_process_id,
|
|
|
|
int render_routing_id);
|
|
|
|
bool is_render_id_match(const RenderIdSet* id_set,
|
|
|
|
int render_process_id,
|
|
|
|
int render_routing_id);
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
int browser_id_;
|
|
|
|
bool is_popup_;
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_windowless_;
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_mime_handler_view_;
|
2012-12-30 12:17:49 +01:00
|
|
|
|
|
|
|
base::Lock lock_;
|
|
|
|
|
|
|
|
// The below members must be protected by |lock_|.
|
2013-07-15 22:25:59 +02:00
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
// Set of mapped (process_id, routing_id) pairs. Keeping this set is
|
|
|
|
// necessary for the following reasons:
|
2013-07-15 22:25:59 +02:00
|
|
|
// 1. When navigating cross-origin the new (pending) RenderViewHost will be
|
|
|
|
// created before the old (current) RenderViewHost is destroyed.
|
|
|
|
// 2. When canceling and asynchronously continuing navigation of the same URL
|
|
|
|
// a new RenderViewHost may be created for the first (canceled) navigation
|
|
|
|
// and then destroyed as a result of the second (allowed) navigation.
|
|
|
|
// 3. Out-of-process iframes have their own render IDs which must also be
|
|
|
|
// associated with the host browser.
|
2014-01-02 23:41:11 +01:00
|
|
|
RenderIdSet render_view_id_set_;
|
|
|
|
RenderIdSet render_frame_id_set_;
|
2012-12-30 12:17:49 +01:00
|
|
|
|
|
|
|
// May be NULL if the browser has not yet been created or if the browser has
|
|
|
|
// been destroyed.
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_BROWSER_INFO_H_
|