2012-01-19 19:52:59 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
2010-10-03 23:04:50 +02:00
|
|
|
// Portions copyright (c) 2006-2008 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.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-12-23 18:36:30 +01:00
|
|
|
#include "include/cef_browser.h"
|
|
|
|
#include "include/cef_client.h"
|
|
|
|
#include "include/cef_frame.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/webview_host.h"
|
|
|
|
#include "libcef/browser_devtools_agent.h"
|
|
|
|
#include "libcef/browser_devtools_client.h"
|
|
|
|
#include "libcef/browser_webview_delegate.h"
|
|
|
|
#include "libcef/browser_navigation_controller.h"
|
2012-03-22 23:08:05 +01:00
|
|
|
#include "libcef/browser_request_context_proxy.h"
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/cef_thread.h"
|
|
|
|
#include "libcef/tracker.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#if defined(OS_WIN)
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/printing/win_printing_context.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#endif
|
|
|
|
|
2011-07-03 02:03:30 +02:00
|
|
|
#include "base/scoped_temp_dir.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class WaitableEvent;
|
|
|
|
}
|
|
|
|
namespace WebKit {
|
|
|
|
class WebView;
|
|
|
|
}
|
|
|
|
|
2012-03-22 23:08:05 +01:00
|
|
|
class CefFrameImpl;
|
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
#define BUFFER_SIZE 32768
|
|
|
|
|
|
|
|
|
|
|
|
// Implementation of CefBrowser.
|
2012-01-10 00:46:23 +01:00
|
|
|
class CefBrowserImpl : public CefBrowser {
|
|
|
|
public:
|
|
|
|
class PaintDelegate : public WebWidgetHost::PaintDelegate {
|
|
|
|
public:
|
|
|
|
explicit PaintDelegate(CefBrowserImpl* browser);
|
2011-03-24 21:36:47 +01:00
|
|
|
virtual ~PaintDelegate();
|
|
|
|
|
2011-11-09 21:09:24 +01:00
|
|
|
virtual void Paint(bool popup, const std::vector<CefRect>& dirtyRects,
|
|
|
|
const void* buffer) OVERRIDE;
|
2011-03-24 21:36:47 +01:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
protected:
|
2011-03-24 21:36:47 +01:00
|
|
|
CefBrowserImpl* browser_;
|
|
|
|
};
|
|
|
|
|
2010-11-18 22:05:25 +01:00
|
|
|
CefBrowserImpl(const CefWindowInfo& windowInfo,
|
2011-06-14 17:09:55 +02:00
|
|
|
const CefBrowserSettings& settings,
|
|
|
|
gfx::NativeView opener,
|
2011-05-20 16:42:25 +02:00
|
|
|
CefRefPtr<CefClient> client);
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual ~CefBrowserImpl() {}
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
static LPCTSTR GetWndClass();
|
|
|
|
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// CefBrowser methods
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual void CloseBrowser() OVERRIDE;
|
|
|
|
virtual bool CanGoBack() OVERRIDE { return can_go_back(); }
|
|
|
|
virtual void GoBack() OVERRIDE;
|
|
|
|
virtual bool CanGoForward() OVERRIDE { return can_go_forward(); }
|
|
|
|
virtual void GoForward() OVERRIDE;
|
|
|
|
virtual void Reload() OVERRIDE;
|
|
|
|
virtual void ReloadIgnoreCache() OVERRIDE;
|
|
|
|
virtual void StopLoad() OVERRIDE;
|
|
|
|
virtual void SetFocus(bool enable) OVERRIDE;
|
2011-08-03 17:35:51 +02:00
|
|
|
virtual void ParentWindowWillClose() OVERRIDE;
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
2011-06-14 17:09:55 +02:00
|
|
|
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE
|
|
|
|
{ return opener_window(); }
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual bool IsPopup() OVERRIDE { return is_popup(); }
|
2011-08-30 18:20:27 +02:00
|
|
|
virtual bool HasDocument() OVERRIDE { return has_document(); }
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual CefRefPtr<CefClient> GetClient() OVERRIDE { return client_; }
|
2012-03-22 23:08:05 +01:00
|
|
|
virtual CefRefPtr<CefFrame> GetMainFrame() OVERRIDE;
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual CefRefPtr<CefFrame> GetFocusedFrame() OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) OVERRIDE;
|
|
|
|
virtual void GetFrameNames(std::vector<CefString>& names) OVERRIDE;
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual void Find(int identifier, const CefString& searchText,
|
2011-05-20 16:42:25 +02:00
|
|
|
bool forward, bool matchCase, bool findNext) OVERRIDE;
|
|
|
|
virtual void StopFinding(bool clearSelection) OVERRIDE;
|
|
|
|
virtual double GetZoomLevel() OVERRIDE { return zoom_level(); }
|
|
|
|
virtual void SetZoomLevel(double zoomLevel) OVERRIDE;
|
2011-10-04 13:49:36 +02:00
|
|
|
virtual void ClearHistory() OVERRIDE;
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual void ShowDevTools() OVERRIDE;
|
|
|
|
virtual void CloseDevTools() OVERRIDE;
|
|
|
|
virtual bool IsWindowRenderingDisabled() OVERRIDE;
|
|
|
|
virtual bool GetSize(PaintElementType type, int& width, int& height) OVERRIDE;
|
|
|
|
virtual void SetSize(PaintElementType type, int width, int height) OVERRIDE;
|
|
|
|
virtual bool IsPopupVisible() OVERRIDE;
|
|
|
|
virtual void HidePopup() OVERRIDE;
|
|
|
|
virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE;
|
2011-03-24 21:36:47 +01:00
|
|
|
virtual bool GetImage(PaintElementType type, int width, int height,
|
2011-05-20 16:42:25 +02:00
|
|
|
void* buffer) OVERRIDE;
|
2012-05-16 18:56:38 +02:00
|
|
|
virtual void SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
|
|
|
|
int modifiers) OVERRIDE;
|
2011-03-24 21:36:47 +01:00
|
|
|
virtual void SendMouseClickEvent(int x, int y, MouseButtonType type,
|
2011-05-20 16:42:25 +02:00
|
|
|
bool mouseUp, int clickCount) OVERRIDE;
|
|
|
|
virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE;
|
2012-05-16 18:56:38 +02:00
|
|
|
virtual void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY)
|
|
|
|
OVERRIDE;
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
|
|
|
virtual void SendCaptureLostEvent() OVERRIDE;
|
2011-01-25 16:34:50 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
// Frame-related methods
|
|
|
|
void Undo(CefRefPtr<CefFrame> frame);
|
|
|
|
void Redo(CefRefPtr<CefFrame> frame);
|
|
|
|
void Cut(CefRefPtr<CefFrame> frame);
|
|
|
|
void Copy(CefRefPtr<CefFrame> frame);
|
|
|
|
void Paste(CefRefPtr<CefFrame> frame);
|
|
|
|
void Delete(CefRefPtr<CefFrame> frame);
|
|
|
|
void SelectAll(CefRefPtr<CefFrame> frame);
|
|
|
|
void Print(CefRefPtr<CefFrame> frame);
|
|
|
|
void ViewSource(CefRefPtr<CefFrame> frame);
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString GetSource(CefRefPtr<CefFrame> frame);
|
|
|
|
CefString GetText(CefRefPtr<CefFrame> frame);
|
2010-10-03 23:04:50 +02:00
|
|
|
void LoadRequest(CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefRequest> request);
|
|
|
|
void LoadURL(CefRefPtr<CefFrame> frame,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& url);
|
2010-10-03 23:04:50 +02:00
|
|
|
void LoadString(CefRefPtr<CefFrame> frame,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& string,
|
|
|
|
const CefString& url);
|
2010-10-03 23:04:50 +02:00
|
|
|
void LoadStream(CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefStreamReader> stream,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& url);
|
2010-10-03 23:04:50 +02:00
|
|
|
void ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
2012-01-10 00:46:23 +01:00
|
|
|
const CefString& jsCode,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& scriptUrl,
|
2010-10-03 23:04:50 +02:00
|
|
|
int startLine);
|
2011-12-08 12:44:30 +01:00
|
|
|
CefRefPtr<CefFrame> GetParent(CefRefPtr<CefFrame> frame);
|
2010-11-18 22:05:25 +01:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
// CefFrames are light-weight objects managed by the browser and loosely
|
2012-03-22 23:08:05 +01:00
|
|
|
// coupled to a WebFrame object by id. If a CefFrame object does not already
|
|
|
|
// exist for the specified id one will be created. There is no guarantee that
|
|
|
|
// the same CefFrame object will be returned across different calls to this
|
|
|
|
// function.
|
|
|
|
CefRefPtr<CefFrameImpl> GetCefFrame(int64 id);
|
|
|
|
CefRefPtr<CefFrameImpl> GetOrCreateCefFrame(int64 id, const CefString& name,
|
|
|
|
const GURL& url);
|
|
|
|
void RemoveCefFrame(int64 id);
|
|
|
|
CefRefPtr<CefFrameImpl> GetMainCefFrame(int64 id, const GURL& url);
|
2011-01-29 02:42:59 +01:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD //
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
CefRefPtr<CefFrame> UIT_GetCefFrame(WebKit::WebFrame* frame);
|
2012-03-22 23:08:05 +01:00
|
|
|
void UIT_UpdateCefFrame(WebKit::WebFrame* frame);
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
// Return the main WebFrame object.
|
|
|
|
WebKit::WebFrame* UIT_GetMainWebFrame();
|
|
|
|
|
|
|
|
// Return the WebFrame object associated with the specified CefFrame. This
|
|
|
|
// may return NULL if no WebFrame with the CefFrame's name exists.
|
|
|
|
WebKit::WebFrame* UIT_GetWebFrame(CefRefPtr<CefFrame> frame);
|
|
|
|
|
|
|
|
WebKit::WebView* UIT_GetWebView() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return webviewhost_.get() ? webviewhost_->webview() : NULL;
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
WebViewHost* UIT_GetWebViewHost() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return webviewhost_.get();
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
BrowserWebViewDelegate* UIT_GetWebViewDelegate() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return delegate_.get();
|
|
|
|
}
|
2011-03-24 21:36:47 +01:00
|
|
|
gfx::NativeView UIT_GetWebViewWndHandle() {
|
2011-01-29 02:42:59 +01:00
|
|
|
REQUIRE_UIT();
|
2011-03-24 21:36:47 +01:00
|
|
|
DCHECK(!IsWindowRenderingDisabled());
|
2010-10-03 23:04:50 +02:00
|
|
|
return webviewhost_->view_handle();
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
WebKit::WebWidget* UIT_GetPopup() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return popuphost_ ? popuphost_->webwidget() : NULL;
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
WebWidgetHost* UIT_GetPopupHost() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return popuphost_;
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
BrowserWebViewDelegate* UIT_GetPopupDelegate() const {
|
|
|
|
REQUIRE_UIT();
|
2010-10-03 23:04:50 +02:00
|
|
|
return popup_delegate_.get();
|
|
|
|
}
|
2011-03-24 21:36:47 +01:00
|
|
|
gfx::NativeView UIT_GetPopupWndHandle() {
|
2011-01-29 02:42:59 +01:00
|
|
|
REQUIRE_UIT();
|
2011-03-24 21:36:47 +01:00
|
|
|
DCHECK(!IsWindowRenderingDisabled());
|
2010-10-03 23:04:50 +02:00
|
|
|
return popuphost_->view_handle();
|
|
|
|
}
|
2011-03-24 21:36:47 +01:00
|
|
|
gfx::NativeView UIT_GetMainWndHandle();
|
2011-12-30 21:55:16 +01:00
|
|
|
void UIT_ClearMainWndHandle();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
BrowserNavigationController* UIT_GetNavigationController() {
|
|
|
|
REQUIRE_UIT();
|
|
|
|
return nav_controller_.get();
|
|
|
|
}
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
// Return true to allow user editing such as entering text in form elements
|
|
|
|
bool UIT_AllowEditing() { return true; }
|
|
|
|
|
|
|
|
bool UIT_IsModal() {
|
|
|
|
REQUIRE_UIT();
|
|
|
|
return is_modal_;
|
|
|
|
}
|
|
|
|
void UIT_SetIsModal(bool val) {
|
|
|
|
REQUIRE_UIT();
|
|
|
|
is_modal_ = val;
|
|
|
|
}
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString UIT_GetTitle() {
|
2010-10-03 23:04:50 +02:00
|
|
|
REQUIRE_UIT();
|
|
|
|
return title_;
|
|
|
|
}
|
2011-01-29 02:42:59 +01:00
|
|
|
void UIT_SetTitle(const CefString& title) {
|
|
|
|
REQUIRE_UIT();
|
|
|
|
title_ = title;
|
|
|
|
}
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-01-29 23:52:34 +01:00
|
|
|
// Create the native browser window and populate browser members.
|
2011-10-21 23:00:59 +02:00
|
|
|
bool UIT_CreateBrowser(const CefString& url);
|
2011-01-29 23:52:34 +01:00
|
|
|
|
|
|
|
// Destroy the browser members. This method should only be called after the
|
|
|
|
// native browser window is not longer processing messages.
|
2010-11-15 16:39:56 +01:00
|
|
|
void UIT_DestroyBrowser();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-01-29 23:52:34 +01:00
|
|
|
// Sends a message via the OS to close the native browser window.
|
|
|
|
// UIT_DestroyBrowser will be called after the native window has closed.
|
|
|
|
void UIT_CloseBrowser();
|
|
|
|
|
|
|
|
void UIT_LoadURL(CefRefPtr<CefFrame> frame,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& url);
|
2011-01-29 23:52:34 +01:00
|
|
|
void UIT_LoadURLForRequest(CefRefPtr<CefFrame> frame,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& url,
|
|
|
|
const CefString& method,
|
2010-10-03 23:04:50 +02:00
|
|
|
const WebKit::WebHTTPBody& upload_data,
|
|
|
|
const CefRequest::HeaderMap& headers);
|
2011-01-29 23:52:34 +01:00
|
|
|
void UIT_LoadURLForRequestRef(CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefRequest> request);
|
|
|
|
void UIT_LoadHTML(CefRefPtr<CefFrame> frame,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& html,
|
|
|
|
const CefString& url);
|
2011-01-29 23:52:34 +01:00
|
|
|
void UIT_LoadHTMLForStreamRef(CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefStreamReader> stream,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& url);
|
2011-01-29 23:52:34 +01:00
|
|
|
void UIT_ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
2012-01-10 00:46:23 +01:00
|
|
|
const CefString& js_code,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& script_url,
|
2010-10-03 23:04:50 +02:00
|
|
|
int start_line);
|
|
|
|
void UIT_GoBackOrForward(int offset);
|
|
|
|
void UIT_Reload(bool ignoreCache);
|
|
|
|
bool UIT_Navigate(const BrowserNavigationEntry& entry,
|
|
|
|
bool reload,
|
|
|
|
bool ignoreCahce);
|
|
|
|
void UIT_SetFocus(WebWidgetHost* host, bool enable);
|
2011-03-24 21:36:47 +01:00
|
|
|
void UIT_SetSize(PaintElementType type, int width, int height);
|
|
|
|
void UIT_Invalidate(const CefRect& dirtyRect);
|
2012-05-16 18:56:38 +02:00
|
|
|
void UIT_SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo, int modifiers);
|
2011-03-24 21:36:47 +01:00
|
|
|
void UIT_SendMouseClickEvent(int x, int y, MouseButtonType type,
|
|
|
|
bool mouseUp, int clickCount);
|
|
|
|
void UIT_SendMouseMoveEvent(int x, int y, bool mouseLeave);
|
2012-05-16 18:56:38 +02:00
|
|
|
void UIT_SendMouseWheelEvent(int x, int y, int deltaX, int deltaY);
|
2011-03-24 21:36:47 +01:00
|
|
|
void UIT_SendFocusEvent(bool setFocus);
|
|
|
|
void UIT_SendCaptureLostEvent();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const CefString& url,
|
2010-11-16 17:45:49 +01:00
|
|
|
const CefPopupFeatures& features);
|
2010-10-03 23:04:50 +02:00
|
|
|
WebKit::WebWidget* UIT_CreatePopupWidget();
|
|
|
|
void UIT_ClosePopupWidget();
|
|
|
|
|
|
|
|
void UIT_Show(WebKit::WebNavigationPolicy policy);
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
// Handles most simple browser actions
|
2011-12-08 02:38:30 +01:00
|
|
|
void UIT_HandleActionView(cef_menu_id_t menuId);
|
|
|
|
void UIT_HandleAction(cef_menu_id_t menuId, CefRefPtr<CefFrame> frame);
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
// Save the document HTML to a temporary file and open in the default viewing
|
|
|
|
// application
|
|
|
|
bool UIT_ViewDocumentString(WebKit::WebFrame *frame);
|
|
|
|
|
|
|
|
bool UIT_CanGoBack() { return !nav_controller_->IsAtStart(); }
|
|
|
|
bool UIT_CanGoForward() { return !nav_controller_->IsAtEnd(); }
|
|
|
|
|
|
|
|
// Printing support
|
|
|
|
void UIT_PrintPages(WebKit::WebFrame* frame);
|
|
|
|
void UIT_PrintPage(int page_number, int total_pages,
|
|
|
|
const gfx::Size& canvas_size, WebKit::WebFrame* frame);
|
|
|
|
int UIT_GetPagesCount(WebKit::WebFrame* frame);
|
|
|
|
|
|
|
|
void UIT_SetUniqueID(int id) { unique_id_ = id; }
|
|
|
|
int UIT_GetUniqueID() { return unique_id_; }
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
void UIT_Find(int identifier, const CefString& search_text,
|
2010-10-03 23:04:50 +02:00
|
|
|
const WebKit::WebFindOptions& options);
|
|
|
|
void UIT_StopFinding(bool clear_selection);
|
|
|
|
void UIT_NotifyFindStatus(int identifier, int count,
|
|
|
|
const WebKit::WebRect& selection_rect,
|
|
|
|
int active_match_ordinal, bool final_update);
|
2011-01-29 02:42:59 +01:00
|
|
|
void UIT_SetZoomLevel(double zoomLevel);
|
2011-01-25 19:37:27 +01:00
|
|
|
void UIT_ShowDevTools();
|
|
|
|
void UIT_CloseDevTools();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-02-23 04:45:13 +01:00
|
|
|
void UIT_VisitDOM(CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefDOMVisitor> visitor);
|
|
|
|
|
|
|
|
// Frame objects will be deleted immediately before the frame is closed.
|
|
|
|
void UIT_AddFrameObject(WebKit::WebFrame* frame,
|
2012-01-19 19:52:59 +01:00
|
|
|
CefTrackNode* tracked_object);
|
2011-02-23 04:45:13 +01:00
|
|
|
void UIT_BeforeFrameClosed(WebKit::WebFrame* frame);
|
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
// These variables are read-only.
|
2010-11-18 22:05:25 +01:00
|
|
|
const CefBrowserSettings& settings() const { return settings_; }
|
2010-10-03 23:04:50 +02:00
|
|
|
const FilePath& file_system_root() const { return file_system_root_.path(); }
|
2011-06-14 17:09:55 +02:00
|
|
|
gfx::NativeView opener_window() { return opener_; }
|
|
|
|
bool is_popup() { return (opener_ != NULL); }
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
// These variables may be read/written from multiple threads.
|
|
|
|
void set_zoom_level(double zoomLevel);
|
|
|
|
double zoom_level();
|
|
|
|
void set_nav_state(bool can_go_back, bool can_go_forward);
|
|
|
|
bool can_go_back();
|
|
|
|
bool can_go_forward();
|
2011-08-30 18:20:27 +02:00
|
|
|
void set_has_document(bool has_document);
|
|
|
|
bool has_document();
|
2011-01-29 02:42:59 +01:00
|
|
|
|
2012-03-22 23:08:05 +01:00
|
|
|
// URL currently being loaded in the main frame.
|
|
|
|
void set_pending_url(const GURL& url);
|
|
|
|
GURL pending_url();
|
|
|
|
|
2011-10-18 02:23:32 +02:00
|
|
|
void set_is_dropping(bool is_dropping) { is_dropping_ = is_dropping; }
|
|
|
|
bool is_dropping() { return is_dropping_; }
|
|
|
|
|
2011-06-14 17:09:55 +02:00
|
|
|
#if defined(OS_WIN)
|
2012-01-10 00:46:23 +01:00
|
|
|
void set_opener_was_disabled_by_modal_loop(bool disabled) {
|
2011-06-14 17:09:55 +02:00
|
|
|
opener_was_disabled_by_modal_loop_ = disabled;
|
|
|
|
}
|
2012-01-10 00:46:23 +01:00
|
|
|
void set_internal_modal_message_loop_is_active(bool active) {
|
2011-06-14 17:09:55 +02:00
|
|
|
internal_modal_message_loop_is_active_ = active;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-24 21:36:47 +01:00
|
|
|
void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; }
|
|
|
|
|
2012-05-25 22:44:34 +02:00
|
|
|
net::URLRequestContext* request_context_proxy();
|
2012-03-22 23:08:05 +01:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
protected:
|
2011-02-01 16:37:47 +01:00
|
|
|
static void UIT_CloseView(gfx::NativeView view);
|
2011-03-08 04:54:50 +01:00
|
|
|
static bool UIT_IsViewVisible(gfx::NativeView view);
|
2011-02-01 16:37:47 +01:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
2011-01-29 23:52:34 +01:00
|
|
|
void UIT_DestroyDevToolsClient();
|
2011-01-25 19:37:27 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
CefWindowInfo window_info_;
|
2010-11-18 22:05:25 +01:00
|
|
|
CefBrowserSettings settings_;
|
2011-06-14 17:09:55 +02:00
|
|
|
// Handle of the browser window that opened this window.
|
|
|
|
gfx::NativeView opener_;
|
2010-10-03 23:04:50 +02:00
|
|
|
bool is_modal_;
|
2011-05-20 16:42:25 +02:00
|
|
|
CefRefPtr<CefClient> client_;
|
2010-10-03 23:04:50 +02:00
|
|
|
scoped_ptr<WebViewHost> webviewhost_;
|
|
|
|
WebWidgetHost* popuphost_;
|
2011-03-24 21:36:47 +01:00
|
|
|
gfx::Rect popup_rect_;
|
2010-10-03 23:04:50 +02:00
|
|
|
scoped_ptr<BrowserWebViewDelegate> delegate_;
|
|
|
|
scoped_ptr<BrowserWebViewDelegate> popup_delegate_;
|
|
|
|
scoped_ptr<BrowserNavigationController> nav_controller_;
|
2011-03-24 21:36:47 +01:00
|
|
|
scoped_ptr<PaintDelegate> paint_delegate_;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-01-25 19:37:27 +01:00
|
|
|
scoped_ptr<BrowserDevToolsAgent> dev_tools_agent_;
|
|
|
|
scoped_ptr<BrowserDevToolsClient> dev_tools_client_;
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
scoped_ptr<BrowserRequestContextProxy> request_context_proxy_;
|
2012-03-22 23:08:05 +01:00
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString title_;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-01-29 02:42:59 +01:00
|
|
|
double zoom_level_;
|
|
|
|
bool can_go_back_;
|
|
|
|
bool can_go_forward_;
|
2011-08-30 18:20:27 +02:00
|
|
|
bool has_document_;
|
2012-03-22 23:08:05 +01:00
|
|
|
GURL pending_url_;
|
2011-01-29 02:42:59 +01:00
|
|
|
|
2011-10-18 02:23:32 +02:00
|
|
|
// True if a drop action is occuring.
|
|
|
|
bool is_dropping_;
|
|
|
|
|
2012-04-02 18:28:56 +02:00
|
|
|
// True if currently in the OnSetFocus callback. Only accessed on the UI
|
|
|
|
// thread.
|
|
|
|
bool is_in_onsetfocus_;
|
|
|
|
|
2010-10-09 21:21:09 +02:00
|
|
|
#if defined(OS_WIN)
|
2010-10-03 23:04:50 +02:00
|
|
|
// Context object used to manage printing.
|
|
|
|
printing::PrintingContext print_context_;
|
2011-06-14 17:09:55 +02:00
|
|
|
|
|
|
|
// Used to re-enable the opener when a modal window gets closed.
|
|
|
|
bool opener_was_disabled_by_modal_loop_;
|
|
|
|
bool internal_modal_message_loop_is_active_;
|
2010-10-09 21:21:09 +02:00
|
|
|
#endif
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-03-22 23:08:05 +01:00
|
|
|
// Map of frame id to reference.
|
|
|
|
typedef std::map<int64, CefFrameImpl*> FrameMap;
|
2010-10-03 23:04:50 +02:00
|
|
|
FrameMap frames_;
|
2012-03-22 23:08:05 +01:00
|
|
|
|
|
|
|
// Singleton main frame reference.
|
|
|
|
CefRefPtr<CefFrameImpl> main_frame_;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2011-02-23 04:45:13 +01:00
|
|
|
typedef std::map<WebKit::WebFrame*, CefRefPtr<CefTrackManager> >
|
|
|
|
FrameObjectMap;
|
|
|
|
FrameObjectMap frame_objects_;
|
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
// Unique browser ID assigned by the context.
|
|
|
|
int unique_id_;
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
// A temporary directory for FileSystem API.
|
|
|
|
ScopedTempDir file_system_root_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
|
|
|
|
IMPLEMENT_LOCKING(CefBrowserImpl);
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Implementation of CefFrame.
|
2012-01-10 00:46:23 +01:00
|
|
|
class CefFrameImpl : public CefFrame {
|
|
|
|
public:
|
2012-03-22 23:08:05 +01:00
|
|
|
CefFrameImpl(CefBrowserImpl* browser,
|
|
|
|
int64 frame_id,
|
|
|
|
const CefString& name,
|
|
|
|
const CefString& url);
|
2011-01-29 02:42:59 +01:00
|
|
|
virtual ~CefFrameImpl();
|
2010-10-03 23:04:50 +02:00
|
|
|
|
|
|
|
// CefFrame methods
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual void Undo() OVERRIDE { browser_->Undo(this); }
|
|
|
|
virtual void Redo() OVERRIDE { browser_->Redo(this); }
|
|
|
|
virtual void Cut() OVERRIDE { browser_->Cut(this); }
|
|
|
|
virtual void Copy() OVERRIDE { browser_->Copy(this); }
|
|
|
|
virtual void Paste() OVERRIDE { browser_->Paste(this); }
|
|
|
|
virtual void Delete() OVERRIDE { browser_->Delete(this); }
|
|
|
|
virtual void SelectAll() OVERRIDE { browser_->SelectAll(this); }
|
|
|
|
virtual void Print() OVERRIDE { browser_->Print(this); }
|
|
|
|
virtual void ViewSource() OVERRIDE { browser_->ViewSource(this); }
|
|
|
|
virtual CefString GetSource() OVERRIDE { return browser_->GetSource(this); }
|
|
|
|
virtual CefString GetText() OVERRIDE { return browser_->GetText(this); }
|
2012-01-10 00:46:23 +01:00
|
|
|
virtual void LoadRequest(CefRefPtr<CefRequest> request) OVERRIDE {
|
|
|
|
return browser_->LoadRequest(this, request);
|
|
|
|
}
|
|
|
|
virtual void LoadURL(const CefString& url) OVERRIDE {
|
|
|
|
return browser_->LoadURL(this, url);
|
|
|
|
}
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual void LoadString(const CefString& string,
|
2012-01-10 00:46:23 +01:00
|
|
|
const CefString& url) OVERRIDE {
|
|
|
|
return browser_->LoadString(this, string, url);
|
|
|
|
}
|
2010-10-03 23:04:50 +02:00
|
|
|
virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
|
2012-01-10 00:46:23 +01:00
|
|
|
const CefString& url) OVERRIDE {
|
|
|
|
return browser_->LoadStream(this, stream, url);
|
|
|
|
}
|
|
|
|
virtual void ExecuteJavaScript(const CefString& jsCode,
|
2010-11-22 18:49:46 +01:00
|
|
|
const CefString& scriptUrl,
|
2012-01-10 00:46:23 +01:00
|
|
|
int startLine) OVERRIDE {
|
|
|
|
return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine);
|
|
|
|
}
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual bool IsMain() OVERRIDE { return name_.empty(); }
|
|
|
|
virtual bool IsFocused() OVERRIDE;
|
|
|
|
virtual CefString GetName() OVERRIDE { return name_; }
|
2012-03-22 23:08:05 +01:00
|
|
|
virtual int64 GetIdentifier() OVERRIDE;
|
2012-01-10 00:46:23 +01:00
|
|
|
virtual CefRefPtr<CefFrame> GetParent() OVERRIDE {
|
|
|
|
return browser_->GetParent(this);
|
|
|
|
}
|
2012-03-22 23:08:05 +01:00
|
|
|
virtual CefString GetURL() OVERRIDE;
|
2011-05-20 16:42:25 +02:00
|
|
|
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE { return browser_.get(); }
|
|
|
|
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE;
|
2011-10-28 22:30:19 +02:00
|
|
|
virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-03-22 23:08:05 +01:00
|
|
|
void set_id(int64 id);
|
|
|
|
void set_url(const CefString& url);
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
private:
|
2010-10-03 23:04:50 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> browser_;
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString name_;
|
2012-03-22 23:08:05 +01:00
|
|
|
|
|
|
|
// The below values must be protected by the lock.
|
|
|
|
base::Lock lock_;
|
|
|
|
int64 id_;
|
|
|
|
CefString url_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefFrameImpl);
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_IMPL_H_
|