• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "libcef/browser/browser_platform_delegate.h"
6 
7 #include "libcef/browser/alloy/alloy_browser_host_impl.h"
8 
9 #include "base/logging.h"
10 
11 CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
12 
~CefBrowserPlatformDelegate()13 CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
14   DCHECK(!browser_);
15 }
16 
CreateWebContents(CefBrowserCreateParams & create_params,bool & own_web_contents)17 content::WebContents* CefBrowserPlatformDelegate::CreateWebContents(
18     CefBrowserCreateParams& create_params,
19     bool& own_web_contents) {
20   NOTREACHED();
21   return nullptr;
22 }
23 
CreateViewForWebContents(content::WebContentsView ** view,content::RenderViewHostDelegateView ** delegate_view)24 void CefBrowserPlatformDelegate::CreateViewForWebContents(
25     content::WebContentsView** view,
26     content::RenderViewHostDelegateView** delegate_view) {
27   NOTREACHED();
28 }
29 
WebContentsCreated(content::WebContents * web_contents,bool owned)30 void CefBrowserPlatformDelegate::WebContentsCreated(
31     content::WebContents* web_contents,
32     bool owned) {
33   // We should not have a browser at this point.
34   DCHECK(!browser_);
35 
36   DCHECK(!web_contents_);
37   web_contents_ = web_contents;
38 }
39 
AddNewContents(content::WebContents * source,std::unique_ptr<content::WebContents> new_contents,const GURL & target_url,WindowOpenDisposition disposition,const gfx::Rect & initial_rect,bool user_gesture,bool * was_blocked)40 void CefBrowserPlatformDelegate::AddNewContents(
41     content::WebContents* source,
42     std::unique_ptr<content::WebContents> new_contents,
43     const GURL& target_url,
44     WindowOpenDisposition disposition,
45     const gfx::Rect& initial_rect,
46     bool user_gesture,
47     bool* was_blocked) {
48   NOTREACHED();
49 }
50 
WebContentsDestroyed(content::WebContents * web_contents)51 void CefBrowserPlatformDelegate::WebContentsDestroyed(
52     content::WebContents* web_contents) {
53   DCHECK(web_contents_ && web_contents_ == web_contents);
54   web_contents_ = nullptr;
55 }
56 
ShouldTransferNavigation(bool is_main_frame_navigation)57 bool CefBrowserPlatformDelegate::ShouldTransferNavigation(
58     bool is_main_frame_navigation) {
59   return true;
60 }
61 
RenderViewCreated(content::RenderViewHost * render_view_host)62 void CefBrowserPlatformDelegate::RenderViewCreated(
63     content::RenderViewHost* render_view_host) {}
64 
RenderViewReady()65 void CefBrowserPlatformDelegate::RenderViewReady() {}
66 
BrowserCreated(CefBrowserHostBase * browser)67 void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
68   // We should have an associated WebContents at this point.
69   DCHECK(web_contents_);
70 
71   DCHECK(!browser_);
72   DCHECK(browser);
73   browser_ = browser;
74 }
75 
CreateExtensionHost(const extensions::Extension * extension,const GURL & url,extensions::mojom::ViewType host_type)76 void CefBrowserPlatformDelegate::CreateExtensionHost(
77     const extensions::Extension* extension,
78     const GURL& url,
79     extensions::mojom::ViewType host_type) {
80   NOTREACHED();
81 }
82 
GetExtensionHost() const83 extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost()
84     const {
85   NOTREACHED();
86   return nullptr;
87 }
88 
NotifyBrowserCreated()89 void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
90 
NotifyBrowserDestroyed()91 void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
92 
BrowserDestroyed(CefBrowserHostBase * browser)93 void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostBase* browser) {
94   // WebContentsDestroyed should already be called.
95   DCHECK(!web_contents_);
96 
97   DCHECK(browser_ && browser_ == browser);
98   browser_ = nullptr;
99 }
100 
CreateHostWindow()101 bool CefBrowserPlatformDelegate::CreateHostWindow() {
102   NOTREACHED();
103   return true;
104 }
105 
CloseHostWindow()106 void CefBrowserPlatformDelegate::CloseHostWindow() {
107   NOTREACHED();
108 }
109 
GetHostWindowHandle() const110 CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const {
111   NOTREACHED();
112   return kNullWindowHandle;
113 }
114 
115 #if defined(TOOLKIT_VIEWS)
GetWindowWidget() const116 views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
117   NOTREACHED();
118   return nullptr;
119 }
120 
GetBrowserView() const121 CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
122   NOTREACHED();
123   return nullptr;
124 }
125 #endif  // defined(TOOLKIT_VIEWS)
126 
PopupWebContentsCreated(const CefBrowserSettings & settings,CefRefPtr<CefClient> client,content::WebContents * new_web_contents,CefBrowserPlatformDelegate * new_platform_delegate,bool is_devtools)127 void CefBrowserPlatformDelegate::PopupWebContentsCreated(
128     const CefBrowserSettings& settings,
129     CefRefPtr<CefClient> client,
130     content::WebContents* new_web_contents,
131     CefBrowserPlatformDelegate* new_platform_delegate,
132     bool is_devtools) {}
133 
PopupBrowserCreated(CefBrowserHostBase * new_browser,bool is_devtools)134 void CefBrowserPlatformDelegate::PopupBrowserCreated(
135     CefBrowserHostBase* new_browser,
136     bool is_devtools) {}
137 
GetBackgroundColor() const138 SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
139   NOTREACHED();
140   return SkColor();
141 }
142 
WasResized()143 void CefBrowserPlatformDelegate::WasResized() {
144   NOTREACHED();
145 }
146 
SendKeyEvent(const CefKeyEvent & event)147 void CefBrowserPlatformDelegate::SendKeyEvent(const CefKeyEvent& event) {
148   NOTIMPLEMENTED();
149 }
150 
SendMouseClickEvent(const CefMouseEvent & event,CefBrowserHost::MouseButtonType type,bool mouseUp,int clickCount)151 void CefBrowserPlatformDelegate::SendMouseClickEvent(
152     const CefMouseEvent& event,
153     CefBrowserHost::MouseButtonType type,
154     bool mouseUp,
155     int clickCount) {
156   NOTIMPLEMENTED();
157 }
158 
SendMouseMoveEvent(const CefMouseEvent & event,bool mouseLeave)159 void CefBrowserPlatformDelegate::SendMouseMoveEvent(const CefMouseEvent& event,
160                                                     bool mouseLeave) {
161   NOTIMPLEMENTED();
162 }
163 
SendMouseWheelEvent(const CefMouseEvent & event,int deltaX,int deltaY)164 void CefBrowserPlatformDelegate::SendMouseWheelEvent(const CefMouseEvent& event,
165                                                      int deltaX,
166                                                      int deltaY) {
167   NOTIMPLEMENTED();
168 }
169 
SendTouchEvent(const CefTouchEvent & event)170 void CefBrowserPlatformDelegate::SendTouchEvent(const CefTouchEvent& event) {
171   NOTIMPLEMENTED();
172 }
173 
SendFocusEvent(bool setFocus)174 void CefBrowserPlatformDelegate::SendFocusEvent(bool setFocus) {
175   NOTIMPLEMENTED();
176 }
177 
SendCaptureLostEvent()178 void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
179   NOTIMPLEMENTED();
180 }
181 
182 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
NotifyMoveOrResizeStarted()183 void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
184 
SizeTo(int width,int height)185 void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
186 #endif
187 
GetScreenPoint(const gfx::Point & view) const188 gfx::Point CefBrowserPlatformDelegate::GetScreenPoint(
189     const gfx::Point& view) const {
190   NOTREACHED();
191   return gfx::Point();
192 }
193 
ViewText(const std::string & text)194 void CefBrowserPlatformDelegate::ViewText(const std::string& text) {
195   NOTIMPLEMENTED();
196 }
197 
HandleKeyboardEvent(const content::NativeWebKeyboardEvent & event)198 bool CefBrowserPlatformDelegate::HandleKeyboardEvent(
199     const content::NativeWebKeyboardEvent& event) {
200   NOTREACHED();
201   return false;
202 }
203 
PreHandleGestureEvent(content::WebContents * source,const blink::WebGestureEvent & event)204 bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
205     content::WebContents* source,
206     const blink::WebGestureEvent& event) {
207   return false;
208 }
209 
IsNeverComposited(content::WebContents * web_contents)210 bool CefBrowserPlatformDelegate::IsNeverComposited(
211     content::WebContents* web_contents) {
212   return false;
213 }
214 
GetEventHandle(const content::NativeWebKeyboardEvent & event) const215 CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
216     const content::NativeWebKeyboardEvent& event) const {
217   NOTREACHED();
218   return kNullEventHandle;
219 }
220 
221 std::unique_ptr<CefFileDialogRunner>
CreateFileDialogRunner()222 CefBrowserPlatformDelegate::CreateFileDialogRunner() {
223   NOTIMPLEMENTED();
224   return nullptr;
225 }
226 
227 std::unique_ptr<CefJavaScriptDialogRunner>
CreateJavaScriptDialogRunner()228 CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
229   NOTIMPLEMENTED();
230   return nullptr;
231 }
232 
CreateMenuRunner()233 std::unique_ptr<CefMenuRunner> CefBrowserPlatformDelegate::CreateMenuRunner() {
234   NOTIMPLEMENTED();
235   return nullptr;
236 }
237 
IsWindowless() const238 bool CefBrowserPlatformDelegate::IsWindowless() const {
239   return false;
240 }
241 
IsViewsHosted() const242 bool CefBrowserPlatformDelegate::IsViewsHosted() const {
243   return false;
244 }
245 
WasHidden(bool hidden)246 void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
247   NOTREACHED();
248 }
249 
NotifyScreenInfoChanged()250 void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
251   NOTREACHED();
252 }
253 
Invalidate(cef_paint_element_type_t type)254 void CefBrowserPlatformDelegate::Invalidate(cef_paint_element_type_t type) {
255   NOTREACHED();
256 }
257 
SendExternalBeginFrame()258 void CefBrowserPlatformDelegate::SendExternalBeginFrame() {
259   NOTREACHED();
260 }
261 
SetWindowlessFrameRate(int frame_rate)262 void CefBrowserPlatformDelegate::SetWindowlessFrameRate(int frame_rate) {
263   NOTREACHED();
264 }
265 
ImeSetComposition(const CefString & text,const std::vector<CefCompositionUnderline> & underlines,const CefRange & replacement_range,const CefRange & selection_range)266 void CefBrowserPlatformDelegate::ImeSetComposition(
267     const CefString& text,
268     const std::vector<CefCompositionUnderline>& underlines,
269     const CefRange& replacement_range,
270     const CefRange& selection_range) {
271   NOTREACHED();
272 }
273 
ImeCommitText(const CefString & text,const CefRange & replacement_range,int relative_cursor_pos)274 void CefBrowserPlatformDelegate::ImeCommitText(
275     const CefString& text,
276     const CefRange& replacement_range,
277     int relative_cursor_pos) {
278   NOTREACHED();
279 }
280 
ImeFinishComposingText(bool keep_selection)281 void CefBrowserPlatformDelegate::ImeFinishComposingText(bool keep_selection) {
282   NOTREACHED();
283 }
284 
ImeCancelComposition()285 void CefBrowserPlatformDelegate::ImeCancelComposition() {
286   NOTREACHED();
287 }
288 
DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,const CefMouseEvent & event,cef_drag_operations_mask_t allowed_ops)289 void CefBrowserPlatformDelegate::DragTargetDragEnter(
290     CefRefPtr<CefDragData> drag_data,
291     const CefMouseEvent& event,
292     cef_drag_operations_mask_t allowed_ops) {
293   NOTREACHED();
294 }
295 
DragTargetDragOver(const CefMouseEvent & event,cef_drag_operations_mask_t allowed_ops)296 void CefBrowserPlatformDelegate::DragTargetDragOver(
297     const CefMouseEvent& event,
298     cef_drag_operations_mask_t allowed_ops) {
299   NOTREACHED();
300 }
301 
DragTargetDragLeave()302 void CefBrowserPlatformDelegate::DragTargetDragLeave() {
303   NOTREACHED();
304 }
305 
DragTargetDrop(const CefMouseEvent & event)306 void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) {
307   NOTREACHED();
308 }
309 
StartDragging(const content::DropData & drop_data,blink::DragOperationsMask allowed_ops,const gfx::ImageSkia & image,const gfx::Vector2d & image_offset,const blink::mojom::DragEventSourceInfo & event_info,content::RenderWidgetHostImpl * source_rwh)310 void CefBrowserPlatformDelegate::StartDragging(
311     const content::DropData& drop_data,
312     blink::DragOperationsMask allowed_ops,
313     const gfx::ImageSkia& image,
314     const gfx::Vector2d& image_offset,
315     const blink::mojom::DragEventSourceInfo& event_info,
316     content::RenderWidgetHostImpl* source_rwh) {
317   NOTREACHED();
318 }
319 
UpdateDragCursor(ui::mojom::DragOperation operation)320 void CefBrowserPlatformDelegate::UpdateDragCursor(
321     ui::mojom::DragOperation operation) {
322   NOTREACHED();
323 }
324 
DragSourceEndedAt(int x,int y,cef_drag_operations_mask_t op)325 void CefBrowserPlatformDelegate::DragSourceEndedAt(
326     int x,
327     int y,
328     cef_drag_operations_mask_t op) {
329   NOTREACHED();
330 }
331 
DragSourceSystemDragEnded()332 void CefBrowserPlatformDelegate::DragSourceSystemDragEnded() {
333   NOTREACHED();
334 }
335 
AccessibilityEventReceived(const content::AXEventNotificationDetails & eventData)336 void CefBrowserPlatformDelegate::AccessibilityEventReceived(
337     const content::AXEventNotificationDetails& eventData) {
338   NOTREACHED();
339 }
340 
AccessibilityLocationChangesReceived(const std::vector<content::AXLocationChangeNotificationDetails> & locData)341 void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
342     const std::vector<content::AXLocationChangeNotificationDetails>& locData) {
343   NOTREACHED();
344 }
345 
GetDialogPosition(const gfx::Size & size)346 gfx::Point CefBrowserPlatformDelegate::GetDialogPosition(
347     const gfx::Size& size) {
348   NOTREACHED();
349   return gfx::Point();
350 }
351 
GetMaximumDialogSize()352 gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
353   NOTREACHED();
354   return gfx::Size();
355 }
356 
SetAutoResizeEnabled(bool enabled,const CefSize & min_size,const CefSize & max_size)357 void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,
358                                                       const CefSize& min_size,
359                                                       const CefSize& max_size) {
360   NOTIMPLEMENTED();
361 }
362 
SetAccessibilityState(cef_state_t accessibility_state)363 void CefBrowserPlatformDelegate::SetAccessibilityState(
364     cef_state_t accessibility_state) {
365   NOTIMPLEMENTED();
366 }
367 
IsPrintPreviewSupported() const368 bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
369   return true;
370 }
371 
Print()372 void CefBrowserPlatformDelegate::Print() {
373   NOTIMPLEMENTED();
374 }
375 
PrintToPDF(const CefString & path,const CefPdfPrintSettings & settings,CefRefPtr<CefPdfPrintCallback> callback)376 void CefBrowserPlatformDelegate::PrintToPDF(
377     const CefString& path,
378     const CefPdfPrintSettings& settings,
379     CefRefPtr<CefPdfPrintCallback> callback) {
380   NOTIMPLEMENTED();
381 }
382 
Find(int identifier,const CefString & searchText,bool forward,bool matchCase,bool findNext)383 void CefBrowserPlatformDelegate::Find(int identifier,
384                                       const CefString& searchText,
385                                       bool forward,
386                                       bool matchCase,
387                                       bool findNext) {
388   NOTIMPLEMENTED();
389 }
390 
StopFinding(bool clearSelection)391 void CefBrowserPlatformDelegate::StopFinding(bool clearSelection) {
392   NOTIMPLEMENTED();
393 }
394 
395 // static
TranslateWebEventModifiers(uint32 cef_modifiers)396 int CefBrowserPlatformDelegate::TranslateWebEventModifiers(
397     uint32 cef_modifiers) {
398   int result = 0;
399   // Set modifiers based on key state.
400   if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
401     result |= blink::WebInputEvent::kShiftKey;
402   if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
403     result |= blink::WebInputEvent::kControlKey;
404   if (cef_modifiers & EVENTFLAG_ALT_DOWN)
405     result |= blink::WebInputEvent::kAltKey;
406   if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
407     result |= blink::WebInputEvent::kMetaKey;
408   if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
409     result |= blink::WebInputEvent::kLeftButtonDown;
410   if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
411     result |= blink::WebInputEvent::kMiddleButtonDown;
412   if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
413     result |= blink::WebInputEvent::kRightButtonDown;
414   if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
415     result |= blink::WebInputEvent::kCapsLockOn;
416   if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
417     result |= blink::WebInputEvent::kNumLockOn;
418   if (cef_modifiers & EVENTFLAG_IS_LEFT)
419     result |= blink::WebInputEvent::kIsLeft;
420   if (cef_modifiers & EVENTFLAG_IS_RIGHT)
421     result |= blink::WebInputEvent::kIsRight;
422   if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
423     result |= blink::WebInputEvent::kIsKeyPad;
424   return result;
425 }
426