• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36 
37 #ifndef CEF_INCLUDE_CEF_BROWSER_H_
38 #define CEF_INCLUDE_CEF_BROWSER_H_
39 #pragma once
40 
41 #include <vector>
42 #include "include/cef_base.h"
43 #include "include/cef_devtools_message_observer.h"
44 #include "include/cef_drag_data.h"
45 #include "include/cef_frame.h"
46 #include "include/cef_image.h"
47 #include "include/cef_navigation_entry.h"
48 #include "include/cef_registration.h"
49 #include "include/cef_request_context.h"
50 
51 class CefBrowserHost;
52 class CefClient;
53 
54 ///
55 // Class used to represent a browser. When used in the browser process the
56 // methods of this class may be called on any thread unless otherwise indicated
57 // in the comments. When used in the render process the methods of this class
58 // may only be called on the main thread.
59 ///
60 /*--cef(source=library)--*/
61 class CefBrowser : public virtual CefBaseRefCounted {
62  public:
63   ///
64   // True if this object is currently valid. This will return false after
65   // CefLifeSpanHandler::OnBeforeClose is called.
66   ///
67   /*--cef()--*/
68   virtual bool IsValid() = 0;
69 
70   ///
71   // Returns the browser host object. This method can only be called in the
72   // browser process.
73   ///
74   /*--cef()--*/
75   virtual CefRefPtr<CefBrowserHost> GetHost() = 0;
76 
77   ///
78   // Returns true if the browser can navigate backwards.
79   ///
80   /*--cef()--*/
81   virtual bool CanGoBack() = 0;
82 
83   ///
84   // Navigate backwards.
85   ///
86   /*--cef()--*/
87   virtual void GoBack() = 0;
88 
89   ///
90   // Returns true if the browser can navigate forwards.
91   ///
92   /*--cef()--*/
93   virtual bool CanGoForward() = 0;
94 
95   ///
96   // Navigate forwards.
97   ///
98   /*--cef()--*/
99   virtual void GoForward() = 0;
100 
101   ///
102   // Returns true if the browser is currently loading.
103   ///
104   /*--cef()--*/
105   virtual bool IsLoading() = 0;
106 
107   ///
108   // Reload the current page.
109   ///
110   /*--cef()--*/
111   virtual void Reload() = 0;
112 
113   ///
114   // Reload the current page ignoring any cached data.
115   ///
116   /*--cef()--*/
117   virtual void ReloadIgnoreCache() = 0;
118 
119   ///
120   // Stop loading the page.
121   ///
122   /*--cef()--*/
123   virtual void StopLoad() = 0;
124 
125   ///
126   // Returns the globally unique identifier for this browser. This value is also
127   // used as the tabId for extension APIs.
128   ///
129   /*--cef()--*/
130   virtual int GetIdentifier() = 0;
131 
132   ///
133   // Returns true if this object is pointing to the same handle as |that|
134   // object.
135   ///
136   /*--cef()--*/
137   virtual bool IsSame(CefRefPtr<CefBrowser> that) = 0;
138 
139   ///
140   // Returns true if the browser is a popup.
141   ///
142   /*--cef()--*/
143   virtual bool IsPopup() = 0;
144 
145   ///
146   // Returns true if a document has been loaded in the browser.
147   ///
148   /*--cef()--*/
149   virtual bool HasDocument() = 0;
150 
151   ///
152   // Returns the main (top-level) frame for the browser. In the browser process
153   // this will return a valid object until after
154   // CefLifeSpanHandler::OnBeforeClose is called. In the renderer process this
155   // will return NULL if the main frame is hosted in a different renderer
156   // process (e.g. for cross-origin sub-frames). The main frame object will
157   // change during cross-origin navigation or re-navigation after renderer
158   // process termination (due to crashes, etc).
159   ///
160   /*--cef()--*/
161   virtual CefRefPtr<CefFrame> GetMainFrame() = 0;
162 
163   ///
164   // Returns the focused frame for the browser.
165   ///
166   /*--cef()--*/
167   virtual CefRefPtr<CefFrame> GetFocusedFrame() = 0;
168 
169   ///
170   // Returns the frame with the specified identifier, or NULL if not found.
171   ///
172   /*--cef(capi_name=get_frame_byident)--*/
173   virtual CefRefPtr<CefFrame> GetFrame(int64 identifier) = 0;
174 
175   ///
176   // Returns the frame with the specified name, or NULL if not found.
177   ///
178   /*--cef(optional_param=name)--*/
179   virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) = 0;
180 
181   ///
182   // Returns the number of frames that currently exist.
183   ///
184   /*--cef()--*/
185   virtual size_t GetFrameCount() = 0;
186 
187   ///
188   // Returns the identifiers of all existing frames.
189   ///
190   /*--cef(count_func=identifiers:GetFrameCount)--*/
191   virtual void GetFrameIdentifiers(std::vector<int64>& identifiers) = 0;
192 
193   ///
194   // Returns the names of all existing frames.
195   ///
196   /*--cef()--*/
197   virtual void GetFrameNames(std::vector<CefString>& names) = 0;
198 };
199 
200 ///
201 // Callback interface for CefBrowserHost::RunFileDialog. The methods of this
202 // class will be called on the browser process UI thread.
203 ///
204 /*--cef(source=client)--*/
205 class CefRunFileDialogCallback : public virtual CefBaseRefCounted {
206  public:
207   ///
208   // Called asynchronously after the file dialog is dismissed.
209   // |selected_accept_filter| is the 0-based index of the value selected from
210   // the accept filters array passed to CefBrowserHost::RunFileDialog.
211   // |file_paths| will be a single value or a list of values depending on the
212   // dialog mode. If the selection was cancelled |file_paths| will be empty.
213   ///
214   /*--cef(index_param=selected_accept_filter,optional_param=file_paths)--*/
215   virtual void OnFileDialogDismissed(
216       int selected_accept_filter,
217       const std::vector<CefString>& file_paths) = 0;
218 };
219 
220 ///
221 // Callback interface for CefBrowserHost::GetNavigationEntries. The methods of
222 // this class will be called on the browser process UI thread.
223 ///
224 /*--cef(source=client)--*/
225 class CefNavigationEntryVisitor : public virtual CefBaseRefCounted {
226  public:
227   ///
228   // Method that will be executed. Do not keep a reference to |entry| outside of
229   // this callback. Return true to continue visiting entries or false to stop.
230   // |current| is true if this entry is the currently loaded navigation entry.
231   // |index| is the 0-based index of this entry and |total| is the total number
232   // of entries.
233   ///
234   /*--cef()--*/
235   virtual bool Visit(CefRefPtr<CefNavigationEntry> entry,
236                      bool current,
237                      int index,
238                      int total) = 0;
239 };
240 
241 ///
242 // Callback interface for CefBrowserHost::PrintToPDF. The methods of this class
243 // will be called on the browser process UI thread.
244 ///
245 /*--cef(source=client)--*/
246 class CefPdfPrintCallback : public virtual CefBaseRefCounted {
247  public:
248   ///
249   // Method that will be executed when the PDF printing has completed. |path|
250   // is the output path. |ok| will be true if the printing completed
251   // successfully or false otherwise.
252   ///
253   /*--cef()--*/
254   virtual void OnPdfPrintFinished(const CefString& path, bool ok) = 0;
255 };
256 
257 ///
258 // Callback interface for CefBrowserHost::DownloadImage. The methods of this
259 // class will be called on the browser process UI thread.
260 ///
261 /*--cef(source=client)--*/
262 class CefDownloadImageCallback : public virtual CefBaseRefCounted {
263  public:
264   ///
265   // Method that will be executed when the image download has completed.
266   // |image_url| is the URL that was downloaded and |http_status_code| is the
267   // resulting HTTP status code. |image| is the resulting image, possibly at
268   // multiple scale factors, or empty if the download failed.
269   ///
270   /*--cef(optional_param=image)--*/
271   virtual void OnDownloadImageFinished(const CefString& image_url,
272                                        int http_status_code,
273                                        CefRefPtr<CefImage> image) = 0;
274 };
275 
276 ///
277 // Class used to represent the browser process aspects of a browser. The methods
278 // of this class can only be called in the browser process. They may be called
279 // on any thread in that process unless otherwise indicated in the comments.
280 ///
281 /*--cef(source=library)--*/
282 class CefBrowserHost : public virtual CefBaseRefCounted {
283  public:
284   typedef cef_drag_operations_mask_t DragOperationsMask;
285   typedef cef_file_dialog_mode_t FileDialogMode;
286   typedef cef_mouse_button_type_t MouseButtonType;
287   typedef cef_paint_element_type_t PaintElementType;
288 
289   ///
290   // Create a new browser using the window parameters specified by |windowInfo|.
291   // All values will be copied internally and the actual window (if any) will be
292   // created on the UI thread. If |request_context| is empty the global request
293   // context will be used. This method can be called on any browser process
294   // thread and will not block. The optional |extra_info| parameter provides an
295   // opportunity to specify extra information specific to the created browser
296   // that will be passed to CefRenderProcessHandler::OnBrowserCreated() in the
297   // render process.
298   ///
299   /*--cef(optional_param=client,optional_param=url,
300           optional_param=request_context,optional_param=extra_info)--*/
301   static bool CreateBrowser(const CefWindowInfo& windowInfo,
302                             CefRefPtr<CefClient> client,
303                             const CefString& url,
304                             const CefBrowserSettings& settings,
305                             CefRefPtr<CefDictionaryValue> extra_info,
306                             CefRefPtr<CefRequestContext> request_context);
307 
308   ///
309   // Create a new browser using the window parameters specified by |windowInfo|.
310   // If |request_context| is empty the global request context will be used. This
311   // method can only be called on the browser process UI thread. The optional
312   // |extra_info| parameter provides an opportunity to specify extra information
313   // specific to the created browser that will be passed to
314   // CefRenderProcessHandler::OnBrowserCreated() in the render process.
315   ///
316   /*--cef(optional_param=client,optional_param=url,
317           optional_param=request_context,optional_param=extra_info)--*/
318   static CefRefPtr<CefBrowser> CreateBrowserSync(
319       const CefWindowInfo& windowInfo,
320       CefRefPtr<CefClient> client,
321       const CefString& url,
322       const CefBrowserSettings& settings,
323       CefRefPtr<CefDictionaryValue> extra_info,
324       CefRefPtr<CefRequestContext> request_context);
325 
326   ///
327   // Returns the hosted browser object.
328   ///
329   /*--cef()--*/
330   virtual CefRefPtr<CefBrowser> GetBrowser() = 0;
331 
332   ///
333   // Request that the browser close. The JavaScript 'onbeforeunload' event will
334   // be fired. If |force_close| is false the event handler, if any, will be
335   // allowed to prompt the user and the user can optionally cancel the close.
336   // If |force_close| is true the prompt will not be displayed and the close
337   // will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the
338   // event handler allows the close or if |force_close| is true. See
339   // CefLifeSpanHandler::DoClose() documentation for additional usage
340   // information.
341   ///
342   /*--cef()--*/
343   virtual void CloseBrowser(bool force_close) = 0;
344 
345   ///
346   // Helper for closing a browser. Call this method from the top-level window
347   // close handler (if any). Internally this calls CloseBrowser(false) if the
348   // close has not yet been initiated. This method returns false while the close
349   // is pending and true after the close has completed. See CloseBrowser() and
350   // CefLifeSpanHandler::DoClose() documentation for additional usage
351   // information. This method must be called on the browser process UI thread.
352   ///
353   /*--cef()--*/
354   virtual bool TryCloseBrowser() = 0;
355 
356   ///
357   // Set whether the browser is focused.
358   ///
359   /*--cef()--*/
360   virtual void SetFocus(bool focus) = 0;
361 
362   ///
363   // Retrieve the window handle (if any) for this browser. If this browser is
364   // wrapped in a CefBrowserView this method should be called on the browser
365   // process UI thread and it will return the handle for the top-level native
366   // window.
367   ///
368   /*--cef()--*/
369   virtual CefWindowHandle GetWindowHandle() = 0;
370 
371   ///
372   // Retrieve the window handle (if any) of the browser that opened this
373   // browser. Will return NULL for non-popup browsers or if this browser is
374   // wrapped in a CefBrowserView. This method can be used in combination with
375   // custom handling of modal windows.
376   ///
377   /*--cef()--*/
378   virtual CefWindowHandle GetOpenerWindowHandle() = 0;
379 
380   ///
381   // Returns true if this browser is wrapped in a CefBrowserView.
382   ///
383   /*--cef()--*/
384   virtual bool HasView() = 0;
385 
386   ///
387   // Returns the client for this browser.
388   ///
389   /*--cef()--*/
390   virtual CefRefPtr<CefClient> GetClient() = 0;
391 
392   ///
393   // Returns the request context for this browser.
394   ///
395   /*--cef()--*/
396   virtual CefRefPtr<CefRequestContext> GetRequestContext() = 0;
397 
398   ///
399   // Get the current zoom level. The default zoom level is 0.0. This method can
400   // only be called on the UI thread.
401   ///
402   /*--cef()--*/
403   virtual double GetZoomLevel() = 0;
404 
405   ///
406   // Change the zoom level to the specified value. Specify 0.0 to reset the
407   // zoom level. If called on the UI thread the change will be applied
408   // immediately. Otherwise, the change will be applied asynchronously on the
409   // UI thread.
410   ///
411   /*--cef()--*/
412   virtual void SetZoomLevel(double zoomLevel) = 0;
413 
414   ///
415   // Call to run a file chooser dialog. Only a single file chooser dialog may be
416   // pending at any given time. |mode| represents the type of dialog to display.
417   // |title| to the title to be used for the dialog and may be empty to show the
418   // default title ("Open" or "Save" depending on the mode). |default_file_path|
419   // is the path with optional directory and/or file name component that will be
420   // initially selected in the dialog. |accept_filters| are used to restrict the
421   // selectable file types and may any combination of (a) valid lower-cased MIME
422   // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g.
423   // ".txt" or ".png"), or (c) combined description and file extension delimited
424   // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg").
425   // |selected_accept_filter| is the 0-based index of the filter that will be
426   // selected by default. |callback| will be executed after the dialog is
427   // dismissed or immediately if another dialog is already pending. The dialog
428   // will be initiated asynchronously on the UI thread.
429   ///
430   /*--cef(optional_param=title,optional_param=default_file_path,
431           optional_param=accept_filters,index_param=selected_accept_filter)--*/
432   virtual void RunFileDialog(FileDialogMode mode,
433                              const CefString& title,
434                              const CefString& default_file_path,
435                              const std::vector<CefString>& accept_filters,
436                              int selected_accept_filter,
437                              CefRefPtr<CefRunFileDialogCallback> callback) = 0;
438 
439   ///
440   // Download the file at |url| using CefDownloadHandler.
441   ///
442   /*--cef()--*/
443   virtual void StartDownload(const CefString& url) = 0;
444 
445   ///
446   // Download |image_url| and execute |callback| on completion with the images
447   // received from the renderer. If |is_favicon| is true then cookies are not
448   // sent and not accepted during download. Images with density independent
449   // pixel (DIP) sizes larger than |max_image_size| are filtered out from the
450   // image results. Versions of the image at different scale factors may be
451   // downloaded up to the maximum scale factor supported by the system. If there
452   // are no image results <= |max_image_size| then the smallest image is resized
453   // to |max_image_size| and is the only result. A |max_image_size| of 0 means
454   // unlimited. If |bypass_cache| is true then |image_url| is requested from the
455   // server even if it is present in the browser cache.
456   ///
457   /*--cef()--*/
458   virtual void DownloadImage(const CefString& image_url,
459                              bool is_favicon,
460                              uint32 max_image_size,
461                              bool bypass_cache,
462                              CefRefPtr<CefDownloadImageCallback> callback) = 0;
463 
464   ///
465   // Print the current browser contents.
466   ///
467   /*--cef()--*/
468   virtual void Print() = 0;
469 
470   ///
471   // Print the current browser contents to the PDF file specified by |path| and
472   // execute |callback| on completion. The caller is responsible for deleting
473   // |path| when done. For PDF printing to work on Linux you must implement the
474   // CefPrintHandler::GetPdfPaperSize method.
475   ///
476   /*--cef(optional_param=callback)--*/
477   virtual void PrintToPDF(const CefString& path,
478                           const CefPdfPrintSettings& settings,
479                           CefRefPtr<CefPdfPrintCallback> callback) = 0;
480 
481   ///
482   // Search for |searchText|. |forward| indicates whether to search forward or
483   // backward within the page. |matchCase| indicates whether the search should
484   // be case-sensitive. |findNext| indicates whether this is the first request
485   // or a follow-up. The search will be restarted if |searchText| or |matchCase|
486   // change. The search will be stopped if |searchText| is empty. The
487   // CefFindHandler instance, if any, returned via CefClient::GetFindHandler
488   // will be called to report find results.
489   ///
490   /*--cef()--*/
491   virtual void Find(const CefString& searchText,
492                     bool forward,
493                     bool matchCase,
494                     bool findNext) = 0;
495 
496   ///
497   // Cancel all searches that are currently going on.
498   ///
499   /*--cef()--*/
500   virtual void StopFinding(bool clearSelection) = 0;
501 
502   ///
503   // Open developer tools (DevTools) in its own browser. The DevTools browser
504   // will remain associated with this browser. If the DevTools browser is
505   // already open then it will be focused, in which case the |windowInfo|,
506   // |client| and |settings| parameters will be ignored. If |inspect_element_at|
507   // is non-empty then the element at the specified (x,y) location will be
508   // inspected. The |windowInfo| parameter will be ignored if this browser is
509   // wrapped in a CefBrowserView.
510   ///
511   /*--cef(optional_param=windowInfo,optional_param=client,
512           optional_param=settings,optional_param=inspect_element_at)--*/
513   virtual void ShowDevTools(const CefWindowInfo& windowInfo,
514                             CefRefPtr<CefClient> client,
515                             const CefBrowserSettings& settings,
516                             const CefPoint& inspect_element_at) = 0;
517 
518   ///
519   // Explicitly close the associated DevTools browser, if any.
520   ///
521   /*--cef()--*/
522   virtual void CloseDevTools() = 0;
523 
524   ///
525   // Returns true if this browser currently has an associated DevTools browser.
526   // Must be called on the browser process UI thread.
527   ///
528   /*--cef()--*/
529   virtual bool HasDevTools() = 0;
530 
531   ///
532   // Send a method call message over the DevTools protocol. |message| must be a
533   // UTF8-encoded JSON dictionary that contains "id" (int), "method" (string)
534   // and "params" (dictionary, optional) values. See the DevTools protocol
535   // documentation at https://chromedevtools.github.io/devtools-protocol/ for
536   // details of supported methods and the expected "params" dictionary contents.
537   // |message| will be copied if necessary. This method will return true if
538   // called on the UI thread and the message was successfully submitted for
539   // validation, otherwise false. Validation will be applied asynchronously and
540   // any messages that fail due to formatting errors or missing parameters may
541   // be discarded without notification. Prefer ExecuteDevToolsMethod if a more
542   // structured approach to message formatting is desired.
543   //
544   // Every valid method call will result in an asynchronous method result or
545   // error message that references the sent message "id". Event messages are
546   // received while notifications are enabled (for example, between method calls
547   // for "Page.enable" and "Page.disable"). All received messages will be
548   // delivered to the observer(s) registered with AddDevToolsMessageObserver.
549   // See CefDevToolsMessageObserver::OnDevToolsMessage documentation for details
550   // of received message contents.
551   //
552   // Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
553   // AddDevToolsMessageObserver methods does not require an active DevTools
554   // front-end or remote-debugging session. Other active DevTools sessions will
555   // continue to function independently. However, any modification of global
556   // browser state by one session may not be reflected in the UI of other
557   // sessions.
558   //
559   // Communication with the DevTools front-end (when displayed) can be logged
560   // for development purposes by passing the
561   // `--devtools-protocol-log-file=<path>` command-line flag.
562   ///
563   /*--cef()--*/
564   virtual bool SendDevToolsMessage(const void* message,
565                                    size_t message_size) = 0;
566 
567   ///
568   // Execute a method call over the DevTools protocol. This is a more structured
569   // version of SendDevToolsMessage. |message_id| is an incremental number that
570   // uniquely identifies the message (pass 0 to have the next number assigned
571   // automatically based on previous values). |method| is the method name.
572   // |params| are the method parameters, which may be empty. See the DevTools
573   // protocol documentation (linked above) for details of supported methods and
574   // the expected |params| dictionary contents. This method will return the
575   // assigned message ID if called on the UI thread and the message was
576   // successfully submitted for validation, otherwise 0. See the
577   // SendDevToolsMessage documentation for additional usage information.
578   ///
579   /*--cef(optional_param=params)--*/
580   virtual int ExecuteDevToolsMethod(int message_id,
581                                     const CefString& method,
582                                     CefRefPtr<CefDictionaryValue> params) = 0;
583 
584   ///
585   // Add an observer for DevTools protocol messages (method results and events).
586   // The observer will remain registered until the returned Registration object
587   // is destroyed. See the SendDevToolsMessage documentation for additional
588   // usage information.
589   ///
590   /*--cef()--*/
591   virtual CefRefPtr<CefRegistration> AddDevToolsMessageObserver(
592       CefRefPtr<CefDevToolsMessageObserver> observer) = 0;
593 
594   ///
595   // Retrieve a snapshot of current navigation entries as values sent to the
596   // specified visitor. If |current_only| is true only the current navigation
597   // entry will be sent, otherwise all navigation entries will be sent.
598   ///
599   /*--cef()--*/
600   virtual void GetNavigationEntries(
601       CefRefPtr<CefNavigationEntryVisitor> visitor,
602       bool current_only) = 0;
603 
604   ///
605   // If a misspelled word is currently selected in an editable node calling
606   // this method will replace it with the specified |word|.
607   ///
608   /*--cef()--*/
609   virtual void ReplaceMisspelling(const CefString& word) = 0;
610 
611   ///
612   // Add the specified |word| to the spelling dictionary.
613   ///
614   /*--cef()--*/
615   virtual void AddWordToDictionary(const CefString& word) = 0;
616 
617   ///
618   // Returns true if window rendering is disabled.
619   ///
620   /*--cef()--*/
621   virtual bool IsWindowRenderingDisabled() = 0;
622 
623   ///
624   // Notify the browser that the widget has been resized. The browser will first
625   // call CefRenderHandler::GetViewRect to get the new size and then call
626   // CefRenderHandler::OnPaint asynchronously with the updated regions. This
627   // method is only used when window rendering is disabled.
628   ///
629   /*--cef()--*/
630   virtual void WasResized() = 0;
631 
632   ///
633   // Notify the browser that it has been hidden or shown. Layouting and
634   // CefRenderHandler::OnPaint notification will stop when the browser is
635   // hidden. This method is only used when window rendering is disabled.
636   ///
637   /*--cef()--*/
638   virtual void WasHidden(bool hidden) = 0;
639 
640   ///
641   // Send a notification to the browser that the screen info has changed. The
642   // browser will then call CefRenderHandler::GetScreenInfo to update the
643   // screen information with the new values. This simulates moving the webview
644   // window from one display to another, or changing the properties of the
645   // current display. This method is only used when window rendering is
646   // disabled.
647   ///
648   /*--cef()--*/
649   virtual void NotifyScreenInfoChanged() = 0;
650 
651   ///
652   // Invalidate the view. The browser will call CefRenderHandler::OnPaint
653   // asynchronously. This method is only used when window rendering is
654   // disabled.
655   ///
656   /*--cef()--*/
657   virtual void Invalidate(PaintElementType type) = 0;
658 
659   ///
660   // Issue a BeginFrame request to Chromium.  Only valid when
661   // CefWindowInfo::external_begin_frame_enabled is set to true.
662   ///
663   /*--cef()--*/
664   virtual void SendExternalBeginFrame() = 0;
665 
666   ///
667   // Send a key event to the browser.
668   ///
669   /*--cef()--*/
670   virtual void SendKeyEvent(const CefKeyEvent& event) = 0;
671 
672   ///
673   // Send a mouse click event to the browser. The |x| and |y| coordinates are
674   // relative to the upper-left corner of the view.
675   ///
676   /*--cef()--*/
677   virtual void SendMouseClickEvent(const CefMouseEvent& event,
678                                    MouseButtonType type,
679                                    bool mouseUp,
680                                    int clickCount) = 0;
681 
682   ///
683   // Send a mouse move event to the browser. The |x| and |y| coordinates are
684   // relative to the upper-left corner of the view.
685   ///
686   /*--cef()--*/
687   virtual void SendMouseMoveEvent(const CefMouseEvent& event,
688                                   bool mouseLeave) = 0;
689 
690   ///
691   // Send a mouse wheel event to the browser. The |x| and |y| coordinates are
692   // relative to the upper-left corner of the view. The |deltaX| and |deltaY|
693   // values represent the movement delta in the X and Y directions respectively.
694   // In order to scroll inside select popups with window rendering disabled
695   // CefRenderHandler::GetScreenPoint should be implemented properly.
696   ///
697   /*--cef()--*/
698   virtual void SendMouseWheelEvent(const CefMouseEvent& event,
699                                    int deltaX,
700                                    int deltaY) = 0;
701 
702   ///
703   // Send a touch event to the browser for a windowless browser.
704   ///
705   /*--cef()--*/
706   virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
707 
708   ///
709   // Send a capture lost event to the browser.
710   ///
711   /*--cef()--*/
712   virtual void SendCaptureLostEvent() = 0;
713 
714   ///
715   // Notify the browser that the window hosting it is about to be moved or
716   // resized. This method is only used on Windows and Linux.
717   ///
718   /*--cef()--*/
719   virtual void NotifyMoveOrResizeStarted() = 0;
720 
721   ///
722   // Returns the maximum rate in frames per second (fps) that CefRenderHandler::
723   // OnPaint will be called for a windowless browser. The actual fps may be
724   // lower if the browser cannot generate frames at the requested rate. The
725   // minimum value is 1 and the maximum value is 60 (default 30). This method
726   // can only be called on the UI thread.
727   ///
728   /*--cef()--*/
729   virtual int GetWindowlessFrameRate() = 0;
730 
731   ///
732   // Set the maximum rate in frames per second (fps) that CefRenderHandler::
733   // OnPaint will be called for a windowless browser. The actual fps may be
734   // lower if the browser cannot generate frames at the requested rate. The
735   // minimum value is 1 and the maximum value is 60 (default 30). Can also be
736   // set at browser creation via CefBrowserSettings.windowless_frame_rate.
737   ///
738   /*--cef()--*/
739   virtual void SetWindowlessFrameRate(int frame_rate) = 0;
740 
741   ///
742   // Begins a new composition or updates the existing composition. Blink has a
743   // special node (a composition node) that allows the input method to change
744   // text without affecting other DOM nodes. |text| is the optional text that
745   // will be inserted into the composition node. |underlines| is an optional set
746   // of ranges that will be underlined in the resulting text.
747   // |replacement_range| is an optional range of the existing text that will be
748   // replaced. |selection_range| is an optional range of the resulting text that
749   // will be selected after insertion or replacement. The |replacement_range|
750   // value is only used on OS X.
751   //
752   // This method may be called multiple times as the composition changes. When
753   // the client is done making changes the composition should either be canceled
754   // or completed. To cancel the composition call ImeCancelComposition. To
755   // complete the composition call either ImeCommitText or
756   // ImeFinishComposingText. Completion is usually signaled when:
757   //   A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR
758   //      flag (on Windows), or;
759   //   B. The client receives a "commit" signal of GtkIMContext (on Linux), or;
760   //   C. insertText of NSTextInput is called (on Mac).
761   //
762   // This method is only used when window rendering is disabled.
763   ///
764   /*--cef(optional_param=text, optional_param=underlines)--*/
765   virtual void ImeSetComposition(
766       const CefString& text,
767       const std::vector<CefCompositionUnderline>& underlines,
768       const CefRange& replacement_range,
769       const CefRange& selection_range) = 0;
770 
771   ///
772   // Completes the existing composition by optionally inserting the specified
773   // |text| into the composition node. |replacement_range| is an optional range
774   // of the existing text that will be replaced. |relative_cursor_pos| is where
775   // the cursor will be positioned relative to the current cursor position. See
776   // comments on ImeSetComposition for usage. The |replacement_range| and
777   // |relative_cursor_pos| values are only used on OS X.
778   // This method is only used when window rendering is disabled.
779   ///
780   /*--cef(optional_param=text)--*/
781   virtual void ImeCommitText(const CefString& text,
782                              const CefRange& replacement_range,
783                              int relative_cursor_pos) = 0;
784 
785   ///
786   // Completes the existing composition by applying the current composition node
787   // contents. If |keep_selection| is false the current selection, if any, will
788   // be discarded. See comments on ImeSetComposition for usage.
789   // This method is only used when window rendering is disabled.
790   ///
791   /*--cef()--*/
792   virtual void ImeFinishComposingText(bool keep_selection) = 0;
793 
794   ///
795   // Cancels the existing composition and discards the composition node
796   // contents without applying them. See comments on ImeSetComposition for
797   // usage.
798   // This method is only used when window rendering is disabled.
799   ///
800   /*--cef()--*/
801   virtual void ImeCancelComposition() = 0;
802 
803   ///
804   // Call this method when the user drags the mouse into the web view (before
805   // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop).
806   // |drag_data| should not contain file contents as this type of data is not
807   // allowed to be dragged into the web view. File contents can be removed using
808   // CefDragData::ResetFileContents (for example, if |drag_data| comes from
809   // CefRenderHandler::StartDragging).
810   // This method is only used when window rendering is disabled.
811   ///
812   /*--cef()--*/
813   virtual void DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
814                                    const CefMouseEvent& event,
815                                    DragOperationsMask allowed_ops) = 0;
816 
817   ///
818   // Call this method each time the mouse is moved across the web view during
819   // a drag operation (after calling DragTargetDragEnter and before calling
820   // DragTargetDragLeave/DragTargetDrop).
821   // This method is only used when window rendering is disabled.
822   ///
823   /*--cef()--*/
824   virtual void DragTargetDragOver(const CefMouseEvent& event,
825                                   DragOperationsMask allowed_ops) = 0;
826 
827   ///
828   // Call this method when the user drags the mouse out of the web view (after
829   // calling DragTargetDragEnter).
830   // This method is only used when window rendering is disabled.
831   ///
832   /*--cef()--*/
833   virtual void DragTargetDragLeave() = 0;
834 
835   ///
836   // Call this method when the user completes the drag operation by dropping
837   // the object onto the web view (after calling DragTargetDragEnter).
838   // The object being dropped is |drag_data|, given as an argument to
839   // the previous DragTargetDragEnter call.
840   // This method is only used when window rendering is disabled.
841   ///
842   /*--cef()--*/
843   virtual void DragTargetDrop(const CefMouseEvent& event) = 0;
844 
845   ///
846   // Call this method when the drag operation started by a
847   // CefRenderHandler::StartDragging call has ended either in a drop or
848   // by being cancelled. |x| and |y| are mouse coordinates relative to the
849   // upper-left corner of the view. If the web view is both the drag source
850   // and the drag target then all DragTarget* methods should be called before
851   // DragSource* mthods.
852   // This method is only used when window rendering is disabled.
853   ///
854   /*--cef()--*/
855   virtual void DragSourceEndedAt(int x, int y, DragOperationsMask op) = 0;
856 
857   ///
858   // Call this method when the drag operation started by a
859   // CefRenderHandler::StartDragging call has completed. This method may be
860   // called immediately without first calling DragSourceEndedAt to cancel a
861   // drag operation. If the web view is both the drag source and the drag
862   // target then all DragTarget* methods should be called before DragSource*
863   // mthods.
864   // This method is only used when window rendering is disabled.
865   ///
866   /*--cef()--*/
867   virtual void DragSourceSystemDragEnded() = 0;
868 
869   ///
870   // Returns the current visible navigation entry for this browser. This method
871   // can only be called on the UI thread.
872   ///
873   /*--cef()--*/
874   virtual CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() = 0;
875 
876   ///
877   // Set accessibility state for all frames. |accessibility_state| may be
878   // default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT
879   // then accessibility will be disabled by default and the state may be further
880   // controlled with the "force-renderer-accessibility" and
881   // "disable-renderer-accessibility" command-line switches. If
882   // |accessibility_state| is STATE_ENABLED then accessibility will be enabled.
883   // If |accessibility_state| is STATE_DISABLED then accessibility will be
884   // completely disabled.
885   //
886   // For windowed browsers accessibility will be enabled in Complete mode (which
887   // corresponds to kAccessibilityModeComplete in Chromium). In this mode all
888   // platform accessibility objects will be created and managed by Chromium's
889   // internal implementation. The client needs only to detect the screen reader
890   // and call this method appropriately. For example, on macOS the client can
891   // handle the @"AXEnhancedUserInterface" accessibility attribute to detect
892   // VoiceOver state changes and on Windows the client can handle WM_GETOBJECT
893   // with OBJID_CLIENT to detect accessibility readers.
894   //
895   // For windowless browsers accessibility will be enabled in TreeOnly mode
896   // (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In
897   // this mode renderer accessibility is enabled, the full tree is computed, and
898   // events are passed to CefAccessibiltyHandler, but platform accessibility
899   // objects are not created. The client may implement platform accessibility
900   // objects using CefAccessibiltyHandler callbacks if desired.
901   ///
902   /*--cef()--*/
903   virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0;
904 
905   ///
906   // Enable notifications of auto resize via CefDisplayHandler::OnAutoResize.
907   // Notifications are disabled by default. |min_size| and |max_size| define the
908   // range of allowed sizes.
909   ///
910   /*--cef()--*/
911   virtual void SetAutoResizeEnabled(bool enabled,
912                                     const CefSize& min_size,
913                                     const CefSize& max_size) = 0;
914 
915   ///
916   // Returns the extension hosted in this browser or NULL if no extension is
917   // hosted. See CefRequestContext::LoadExtension for details.
918   ///
919   /*--cef()--*/
920   virtual CefRefPtr<CefExtension> GetExtension() = 0;
921 
922   ///
923   // Returns true if this browser is hosting an extension background script.
924   // Background hosts do not have a window and are not displayable. See
925   // CefRequestContext::LoadExtension for details.
926   ///
927   /*--cef()--*/
928   virtual bool IsBackgroundHost() = 0;
929 
930   ///
931   //  Set whether the browser's audio is muted.
932   ///
933   /*--cef()--*/
934   virtual void SetAudioMuted(bool mute) = 0;
935 
936   ///
937   // Returns true if the browser's audio is muted.  This method can only be
938   // called on the UI thread.
939   ///
940   /*--cef()--*/
941   virtual bool IsAudioMuted() = 0;
942 };
943 
944 #endif  // CEF_INCLUDE_CEF_BROWSER_H_
945