~abreu-alexandre/oxide/remove-chromedriver-build

« back to all changes in this revision

Viewing changes to qt/core/browser/oxide_qt_web_view.cc

  • Committer: Chris Coulson
  • Date: 2016-02-24 23:07:10 UTC
  • mfrom: (1334.1.14 web-view-cleanup)
  • Revision ID: chris.coulson@canonical.com-20160224230710-q4173wx4h4e9cbe3
Move compositing, input event and windowing event handling out of WebView

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <utility>
24
24
#include <vector>
25
25
 
26
 
#include <QCursor>
27
 
#include <QDragEnterEvent>
28
 
#include <QDragMoveEvent>
29
 
#include <QDropEvent>
30
26
#include <QGuiApplication>
31
27
#include <QInputEvent>
32
 
#include <QKeyEvent>
33
 
#include <QPixmap>
34
28
#include <QScreen>
35
29
#include <QString>
36
30
#include <QtDebug>
38
32
 
39
33
#include "base/logging.h"
40
34
#include "base/macros.h"
41
 
#include "base/memory/ref_counted.h"
42
 
#include "base/memory/scoped_vector.h"
43
35
#include "base/pickle.h"
44
36
#include "base/strings/utf_string_conversions.h"
45
37
#include "cc/output/compositor_frame_metadata.h"
46
 
#include "content/common/cursors/webcursor.h"
47
38
#include "content/public/browser/native_web_keyboard_event.h"
48
39
#include "content/public/browser/navigation_controller.h"
49
40
#include "content/browser/web_contents/web_contents_impl.h"
50
41
#include "net/base/net_errors.h"
51
 
#include "third_party/WebKit/public/platform/WebCursorInfo.h"
52
42
#include "third_party/WebKit/public/platform/WebTopControlsState.h"
53
43
#include "third_party/WebKit/public/web/WebDragOperation.h"
54
 
#include "ui/events/event.h"
55
44
#include "ui/gfx/geometry/point.h"
56
45
#include "ui/gfx/geometry/rect.h"
57
 
#include "ui/gfx/geometry/rect_f.h"
58
46
#include "ui/gfx/geometry/size.h"
59
 
#include "ui/touch_selection/touch_selection_controller.h"
60
47
#include "url/gurl.h"
61
48
 
62
49
#include "qt/core/api/oxideqdownloadrequest.h"
75
62
#include "qt/core/api/oxideqfindcontroller_p.h"
76
63
#include "qt/core/api/oxideqwebpreferences.h"
77
64
#include "qt/core/api/oxideqwebpreferences_p.h"
78
 
#include "qt/core/browser/input/oxide_qt_input_method_context.h"
 
65
#include "qt/core/glue/oxide_qt_contents_view_proxy_client.h"
79
66
#include "qt/core/glue/oxide_qt_web_frame_proxy_client.h"
80
67
#include "qt/core/glue/oxide_qt_web_view_proxy_client.h"
81
 
#include "shared/browser/compositor/oxide_compositor_frame_data.h"
82
 
#include "shared/browser/compositor/oxide_compositor_frame_handle.h"
83
68
#include "shared/browser/oxide_browser_process_main.h"
84
69
#include "shared/browser/oxide_content_types.h"
85
70
#include "shared/browser/oxide_fullscreen_helper.h"
94
79
#include "shared/browser/ssl/oxide_certificate_error_dispatcher.h"
95
80
#include "shared/common/oxide_enum_flags.h"
96
81
 
97
 
#include "oxide_qt_contents_native_view_data.h"
98
 
#include "oxide_qt_drag_utils.h"
 
82
#include "oxide_qt_contents_view.h"
 
83
#include "oxide_qt_event_utils.h"
99
84
#include "oxide_qt_file_picker.h"
100
85
#include "oxide_qt_find_controller.h"
101
86
#include "oxide_qt_javascript_dialog.h"
102
87
#include "oxide_qt_screen_utils.h"
103
88
#include "oxide_qt_script_message_handler.h"
104
 
#include "oxide_qt_skutils.h"
105
 
#include "oxide_qt_touch_handle_drawable.h"
106
89
#include "oxide_qt_web_context.h"
107
 
#include "oxide_qt_web_context_menu.h"
108
90
#include "oxide_qt_web_frame.h"
109
 
#include "oxide_qt_web_popup_menu.h"
110
91
#include "oxide_qt_web_preferences.h"
111
92
 
112
93
namespace oxide {
118
99
using oxide::WebFrameTreeObserver;
119
100
using oxide::WebFrameTree;
120
101
 
 
102
OXIDE_MAKE_ENUM_BITWISE_OPERATORS(EditCapabilityFlags)
 
103
 
121
104
namespace {
122
105
 
123
106
OxideQLoadEvent::ErrorDomain ErrorDomainFromErrorCode(int error_code) {
152
135
  return OxideQLoadEvent::ErrorDomainInternal;
153
136
}
154
137
 
155
 
inline QCursor QCursorFromWebCursor(blink::WebCursorInfo::Type type) {
156
 
  Qt::CursorShape cs = Qt::ArrowCursor;
157
 
  switch (type) {
158
 
  case blink::WebCursorInfo::TypeCross:
159
 
    cs = Qt::CrossCursor;
160
 
    break;
161
 
 
162
 
  case blink::WebCursorInfo::TypeHand:
163
 
    cs = Qt::PointingHandCursor;
164
 
    break;
165
 
 
166
 
  case blink::WebCursorInfo::TypeCell:
167
 
  case blink::WebCursorInfo::TypeIBeam:
168
 
    cs = Qt::IBeamCursor;
169
 
    break;
170
 
 
171
 
  case blink::WebCursorInfo::TypeWait:
172
 
    cs = Qt::WaitCursor;
173
 
    break;
174
 
 
175
 
  case blink::WebCursorInfo::TypeHelp:
176
 
    cs = Qt::WhatsThisCursor;
177
 
    break;
178
 
 
179
 
  case blink::WebCursorInfo::TypeEastResize:
180
 
  case blink::WebCursorInfo::TypeWestResize:
181
 
  case blink::WebCursorInfo::TypeEastWestResize:
182
 
    cs = Qt::SizeHorCursor;
183
 
    break;
184
 
 
185
 
  case blink::WebCursorInfo::TypeNorthResize:
186
 
  case blink::WebCursorInfo::TypeSouthResize:
187
 
  case blink::WebCursorInfo::TypeNorthSouthResize:
188
 
    cs = Qt::SizeVerCursor;
189
 
    break;
190
 
 
191
 
  case blink::WebCursorInfo::TypeNorthEastResize:
192
 
  case blink::WebCursorInfo::TypeSouthWestResize:
193
 
    cs = Qt::SizeBDiagCursor;
194
 
    break;
195
 
 
196
 
  case blink::WebCursorInfo::TypeNorthWestResize:
197
 
  case blink::WebCursorInfo::TypeSouthEastResize:
198
 
    cs = Qt::SizeFDiagCursor;
199
 
    break;
200
 
 
201
 
  case blink::WebCursorInfo::TypeNorthEastSouthWestResize:
202
 
  case blink::WebCursorInfo::TypeNorthWestSouthEastResize:
203
 
  case blink::WebCursorInfo::TypeMove:
204
 
    cs = Qt::SizeAllCursor;
205
 
    break;
206
 
 
207
 
  case blink::WebCursorInfo::TypeColumnResize:
208
 
    cs = Qt::SplitHCursor;
209
 
    break;
210
 
 
211
 
  case blink::WebCursorInfo::TypeRowResize:
212
 
    cs = Qt::SplitVCursor;
213
 
    break;
214
 
 
215
 
  case blink::WebCursorInfo::TypeMiddlePanning:
216
 
  case blink::WebCursorInfo::TypeEastPanning:
217
 
  case blink::WebCursorInfo::TypeNorthPanning:
218
 
  case blink::WebCursorInfo::TypeNorthEastPanning:
219
 
  case blink::WebCursorInfo::TypeNorthWestPanning:
220
 
  case blink::WebCursorInfo::TypeSouthPanning:
221
 
  case blink::WebCursorInfo::TypeSouthEastPanning:
222
 
  case blink::WebCursorInfo::TypeSouthWestPanning:
223
 
  case blink::WebCursorInfo::TypeWestPanning:
224
 
  case blink::WebCursorInfo::TypeGrab:
225
 
  case blink::WebCursorInfo::TypeGrabbing:
226
 
    cs = Qt::ClosedHandCursor;
227
 
    break;
228
 
 
229
 
  case blink::WebCursorInfo::TypeProgress:
230
 
    cs = Qt::BusyCursor;
231
 
    break;
232
 
 
233
 
  case blink::WebCursorInfo::TypeNoDrop:
234
 
  case blink::WebCursorInfo::TypeNotAllowed:
235
 
    cs = Qt::ForbiddenCursor;
236
 
    break;
237
 
 
238
 
  case blink::WebCursorInfo::TypeCopy:
239
 
  case blink::WebCursorInfo::TypeContextMenu:
240
 
  case blink::WebCursorInfo::TypeVerticalText:
241
 
  case blink::WebCursorInfo::TypeAlias:
242
 
  case blink::WebCursorInfo::TypeZoomIn:
243
 
  case blink::WebCursorInfo::TypeZoomOut:
244
 
  case blink::WebCursorInfo::TypeCustom:
245
 
  case blink::WebCursorInfo::TypePointer:
246
 
  case blink::WebCursorInfo::TypeNone:
247
 
  default:
248
 
    break;
249
 
  }
250
 
 
251
 
  return QCursor(cs);
252
 
}
253
 
 
254
138
static const char* STATE_SERIALIZER_MAGIC_NUMBER = "oxide";
255
139
static uint16_t STATE_SERIALIZER_VERSION = 1;
256
140
 
350
234
 
351
235
}
352
236
 
353
 
class CompositorFrameHandleImpl : public CompositorFrameHandle {
354
 
 public:
355
 
  CompositorFrameHandleImpl(oxide::CompositorFrameHandle* frame,
356
 
                            int location_bar_content_offset)
357
 
      : frame_(frame) {
358
 
    if (frame_.get()) {
359
 
      rect_ = QRect(0, location_bar_content_offset,
360
 
                    frame_->data()->size_in_pixels.width(),
361
 
                    frame_->data()->size_in_pixels.height());
362
 
    }
363
 
  }
364
 
 
365
 
  virtual ~CompositorFrameHandleImpl() {}
366
 
 
367
 
  CompositorFrameHandle::Type GetType() final {
368
 
    if (!frame_.get()) {
369
 
      return CompositorFrameHandle::TYPE_INVALID;
370
 
    }
371
 
    if (frame_->data()->gl_frame_data) {
372
 
      DCHECK_NE(frame_->data()->gl_frame_data->type,
373
 
                oxide::GLFrameData::Type::INVALID);
374
 
      if (frame_->data()->gl_frame_data->type ==
375
 
          oxide::GLFrameData::Type::TEXTURE) {
376
 
        return CompositorFrameHandle::TYPE_ACCELERATED;
377
 
      }
378
 
      return CompositorFrameHandle::TYPE_IMAGE;
379
 
    }
380
 
    if (frame_->data()->software_frame_data) {
381
 
      return CompositorFrameHandle::TYPE_SOFTWARE;
382
 
    }
383
 
 
384
 
    NOTREACHED();
385
 
    return CompositorFrameHandle::TYPE_INVALID;
386
 
  }
387
 
 
388
 
  const QRect& GetRect() const final {
389
 
    return rect_;
390
 
  }
391
 
 
392
 
  QImage GetSoftwareFrame() final {
393
 
    DCHECK_EQ(GetType(), CompositorFrameHandle::TYPE_SOFTWARE);
394
 
    return QImage(
395
 
        static_cast<uchar *>(frame_->data()->software_frame_data->pixels),
396
 
        frame_->data()->size_in_pixels.width(),
397
 
        frame_->data()->size_in_pixels.height(),
398
 
        QImage::Format_ARGB32);
399
 
  }
400
 
 
401
 
  unsigned int GetAcceleratedFrameTexture() final {
402
 
    DCHECK_EQ(GetType(), CompositorFrameHandle::TYPE_ACCELERATED);
403
 
    return frame_->data()->gl_frame_data->resource.texture;
404
 
  }
405
 
 
406
 
  EGLImageKHR GetImageFrame() final {
407
 
    return frame_->data()->gl_frame_data->resource.egl_image;
408
 
  }
409
 
 
410
 
 private:
411
 
  scoped_refptr<oxide::CompositorFrameHandle> frame_;
412
 
  QRect rect_;
413
 
};
414
 
 
415
237
WebView::WebView(WebViewProxyClient* client,
 
238
                 ContentsViewProxyClient* view_client,
 
239
                 QObject* handle,
416
240
                 OxideQSecurityStatus* security_status)
417
 
    : input_method_context_(new InputMethodContext(this)),
 
241
    : contents_view_(new ContentsView(view_client, handle)),
418
242
      client_(client),
419
243
      security_status_(security_status),
420
 
      frame_tree_torn_down_(false) {}
 
244
      frame_tree_torn_down_(false) {
 
245
  DCHECK(client);
 
246
  DCHECK(handle);
 
247
 
 
248
  setHandle(handle);
 
249
}
421
250
 
422
251
float WebView::GetDeviceScaleFactor() const {
423
 
  QScreen* screen = client_->GetScreen();
 
252
  QScreen* screen = contents_view_->client()->GetScreen();
424
253
  if (!screen) {
425
254
    screen = QGuiApplication::primaryScreen();
426
255
  }
432
261
  return locationBarContentOffsetPix();
433
262
}
434
263
 
435
 
void WebView::CommonInit(OxideQFindController* find_controller,
436
 
                         QObject* native_view) {
437
 
  content::WebContents* contents = view_->GetWebContents();
 
264
float WebView::GetLocationBarContentOffsetDip() const {
 
265
  if (!web_view_) {
 
266
    return 0.f;
 
267
  }
 
268
 
 
269
  return web_view_->GetLocationBarContentOffsetDip();
 
270
}
 
271
 
 
272
void WebView::CommonInit(OxideQFindController* find_controller) {
 
273
  content::WebContents* contents = web_view_->GetWebContents();
438
274
 
439
275
  CertificateErrorDispatcher::FromWebContents(contents)->set_client(this);
440
276
  FullscreenHelper::FromWebContents(contents)->set_client(this);
444
280
      contents);
445
281
  WebFrameTreeObserver::Observe(WebFrameTree::FromWebContents(contents));
446
282
 
447
 
  ContentsNativeViewData::CreateForWebContents(contents, native_view);
448
 
 
449
 
  CHECK_EQ(view_->GetRootFrame()->GetChildFrames().size(), 0U);
450
 
  WebFrame* root_frame = new WebFrame(view_->GetRootFrame());
451
 
  view_->GetRootFrame()->set_script_message_target_delegate(root_frame);
 
283
  CHECK_EQ(web_view_->GetRootFrame()->GetChildFrames().size(), 0U);
 
284
  WebFrame* root_frame = new WebFrame(web_view_->GetRootFrame());
 
285
  web_view_->GetRootFrame()->set_script_message_target_delegate(root_frame);
452
286
  client_->CreateWebFrame(root_frame);
453
287
}
454
288
 
455
289
void WebView::EnsurePreferences() {
456
 
  if (view_->GetWebPreferences()) {
 
290
  if (web_view_->GetWebPreferences()) {
457
291
    return;
458
292
  }
459
293
 
460
 
  OxideQWebPreferences* p = new OxideQWebPreferences(client_->GetApiHandle());
461
 
  view_->SetWebPreferences(
 
294
  OxideQWebPreferences* p = new OxideQWebPreferences(handle());
 
295
  web_view_->SetWebPreferences(
462
296
      OxideQWebPreferencesPrivate::get(p)->preferences());
463
297
}
464
298
 
465
 
void WebView::SetInputMethodEnabled(bool enabled) {
466
 
  client_->SetInputMethodEnabled(enabled);
467
 
}
468
 
 
469
 
blink::WebScreenInfo WebView::GetScreenInfo() const {
470
 
  QScreen* screen = client_->GetScreen();
471
 
  if (!screen) {
472
 
    screen = QGuiApplication::primaryScreen();
473
 
  }
474
 
 
475
 
  return GetWebScreenInfoFromQScreen(screen);
476
 
}
477
 
 
478
 
gfx::Rect WebView::GetViewBoundsPix() const {
479
 
  QRect bounds = client_->GetViewBoundsPix();
480
 
  return gfx::Rect(bounds.x(),
481
 
                   bounds.y(),
482
 
                   bounds.width(),
483
 
                   bounds.height());
484
 
}
485
 
 
486
 
bool WebView::IsVisible() const {
487
 
  return client_->IsVisible();
488
 
}
489
 
 
490
 
bool WebView::HasFocus() const {
491
 
  return client_->HasFocus();
492
 
}
493
 
 
494
299
oxide::JavaScriptDialog* WebView::CreateJavaScriptDialog(
495
300
    content::JavaScriptMessageType javascript_message_type) {
496
301
  JavaScriptDialogProxyClient::Type type;
635
440
}
636
441
 
637
442
void WebView::WebPreferencesDestroyed() {
638
 
  OxideQWebPreferences* p = new OxideQWebPreferences(client_->GetApiHandle());
639
 
  view_->SetWebPreferences(
 
443
  OxideQWebPreferences* p = new OxideQWebPreferences(handle());
 
444
  web_view_->SetWebPreferences(
640
445
      OxideQWebPreferencesPrivate::get(p)->preferences());
641
446
  client_->WebPreferencesReplaced();
642
447
}
643
448
 
644
 
void WebView::UnhandledKeyboardEvent(
645
 
    const content::NativeWebKeyboardEvent& event) {
646
 
  if (event.skip_in_browser) {
647
 
    return;
648
 
  }
649
 
 
650
 
  if (event.type != blink::WebInputEvent::RawKeyDown &&
651
 
      event.type != blink::WebInputEvent::KeyUp) {
652
 
    return;
653
 
  }
654
 
 
655
 
  if (!event.os_event) {
656
 
    return;
657
 
  }
658
 
  
659
 
  DCHECK(!event.os_event->isAccepted());
660
 
 
661
 
  client_->HandleUnhandledKeyboardEvent(event.os_event);
662
 
}
663
 
 
664
449
OXIDE_MAKE_ENUM_BITWISE_OPERATORS(FrameMetadataChangeFlags)
665
450
 
666
451
void WebView::FrameMetadataUpdated(const cc::CompositorFrameMetadata& old) {
667
452
  FrameMetadataChangeFlags flags = FRAME_METADATA_CHANGE_NONE;
668
453
 
669
454
  if (old.root_scroll_offset.x() !=
670
 
          view_->compositor_frame_metadata().root_scroll_offset.x() ||
 
455
          web_view_->compositor_frame_metadata().root_scroll_offset.x() ||
671
456
      old.root_scroll_offset.y() !=
672
 
          view_->compositor_frame_metadata().root_scroll_offset.y()) {
 
457
          web_view_->compositor_frame_metadata().root_scroll_offset.y()) {
673
458
    flags |= FRAME_METADATA_CHANGE_SCROLL_OFFSET;
674
459
  }
675
460
  if (old.root_layer_size.width() !=
676
 
          view_->compositor_frame_metadata().root_layer_size.width() ||
 
461
          web_view_->compositor_frame_metadata().root_layer_size.width() ||
677
462
      old.root_layer_size.height() !=
678
 
          view_->compositor_frame_metadata().root_layer_size.height()) {
 
463
          web_view_->compositor_frame_metadata().root_layer_size.height()) {
679
464
    flags |= FRAME_METADATA_CHANGE_CONTENT;
680
465
  }
681
466
  if (old.scrollable_viewport_size.width() !=
682
 
          view_->compositor_frame_metadata().scrollable_viewport_size.width() ||
 
467
          web_view_->compositor_frame_metadata().scrollable_viewport_size.width() ||
683
468
      old.scrollable_viewport_size.height() !=
684
 
          view_->compositor_frame_metadata().scrollable_viewport_size.height()) {
 
469
          web_view_->compositor_frame_metadata().scrollable_viewport_size.height()) {
685
470
    flags |= FRAME_METADATA_CHANGE_VIEWPORT;
686
471
  }
687
472
  if (old.location_bar_offset.y() !=
688
 
      view_->compositor_frame_metadata().location_bar_offset.y()) {
 
473
      web_view_->compositor_frame_metadata().location_bar_offset.y()) {
689
474
    flags |= FRAME_METADATA_CHANGE_CONTROLS_OFFSET;
690
475
  }
691
476
  if (old.location_bar_content_translation.y() !=
692
 
      view_->compositor_frame_metadata().location_bar_content_translation.y()) {
 
477
      web_view_->compositor_frame_metadata().location_bar_content_translation.y()) {
693
478
    flags |= FRAME_METADATA_CHANGE_CONTENT_OFFSET;
694
479
  }
695
480
  if (old.device_scale_factor !=
696
 
          view_->compositor_frame_metadata().device_scale_factor ||
 
481
          web_view_->compositor_frame_metadata().device_scale_factor ||
697
482
      old.page_scale_factor !=
698
 
          view_->compositor_frame_metadata().page_scale_factor) {
 
483
          web_view_->compositor_frame_metadata().page_scale_factor) {
699
484
    flags |= FRAME_METADATA_CHANGE_SCROLL_OFFSET;
700
485
    flags |= FRAME_METADATA_CHANGE_CONTENT;
701
486
    flags |= FRAME_METADATA_CHANGE_VIEWPORT;
765
550
  return request.action() == OxideQNavigationRequest::ActionAccept;
766
551
}
767
552
 
768
 
oxide::WebContextMenu* WebView::CreateContextMenu(
769
 
    content::RenderFrameHost* rfh,
770
 
    const content::ContextMenuParams& params) {
771
 
  WebContextMenu* menu = new WebContextMenu(rfh, params);
772
 
  menu->SetProxy(client_->CreateWebContextMenu(menu));
773
 
  return menu;
774
 
}
775
 
 
776
 
oxide::WebPopupMenu* WebView::CreatePopupMenu(content::RenderFrameHost* rfh) {
777
 
  WebPopupMenu* menu = new WebPopupMenu(rfh);
778
 
  menu->SetProxy(client_->CreateWebPopupMenu(menu));
779
 
  return menu;
780
 
}
781
 
 
782
553
oxide::WebView* WebView::CreateNewWebView(
783
554
    const gfx::Rect& initial_pos,
784
555
    WindowOpenDisposition disposition,
837
608
  return picker;
838
609
}
839
610
 
840
 
ui::TouchHandleDrawable* WebView::CreateTouchHandleDrawable() const {
841
 
  TouchHandleDrawable* drawable = new TouchHandleDrawable(this);
842
 
  drawable->SetProxy(client_->CreateTouchHandleDrawable());
843
 
  return drawable;
844
 
}
845
 
 
846
 
OXIDE_MAKE_ENUM_BITWISE_OPERATORS(EditCapabilityFlags)
847
 
 
848
 
void WebView::TouchSelectionChanged(bool active,
849
 
                                    const gfx::RectF& bounds) const {
850
 
  const float dpr = GetDeviceScaleFactor();
851
 
  QRectF rect(bounds.x() * dpr, bounds.y() * dpr,
852
 
              bounds.width() * dpr, bounds.height() * dpr);
853
 
  client_->TouchSelectionChanged(active, rect);
854
 
}
855
 
 
856
 
void WebView::SwapCompositorFrame() {
857
 
  compositor_frame_.reset();
858
 
  client_->ScheduleUpdate();
859
 
}
860
 
 
861
 
void WebView::EvictCurrentFrame() {
862
 
  compositor_frame_.reset();
863
 
  client_->EvictCurrentFrame();
864
 
}
865
 
 
866
 
oxide::InputMethodContext* WebView::GetInputMethodContext() const {
867
 
  return input_method_context_.get();
868
 
}
869
 
 
870
 
void WebView::UpdateCursor(const content::WebCursor& cursor) {
871
 
  content::WebCursor::CursorInfo cursor_info;
872
 
 
873
 
  cursor.GetCursorInfo(&cursor_info);
874
 
  if (cursor.IsCustom()) {
875
 
    QImage cursor_image = QImageFromSkBitmap(cursor_info.custom_image);
876
 
    if (cursor_image.isNull()) {
877
 
      return;
878
 
    }
879
 
 
880
 
    QPixmap cursor_pixmap = QPixmap::fromImage(cursor_image);
881
 
    client_->UpdateCursor(QCursor(cursor_pixmap));
882
 
  } else {
883
 
    client_->UpdateCursor(QCursorFromWebCursor(cursor_info.type));
884
 
  }
885
 
}
886
 
 
887
611
void WebView::SecurityStatusChanged(const oxide::SecurityStatus& old) {
888
612
  OxideQSecurityStatusPrivate::get(security_status_)->Update(old);
889
613
}
954
678
  frame->set_script_message_target_delegate(f);
955
679
  client_->CreateWebFrame(f);
956
680
 
 
681
  DCHECK(f->handle());
 
682
 
957
683
  WebFrame* parent = WebFrame::FromSharedWebFrame(frame->parent());
958
684
  parent->client()->ChildFramesChanged();
959
685
}
1000
726
}
1001
727
 
1002
728
QUrl WebView::url() const {
1003
 
  return QUrl(QString::fromStdString(view_->GetURL().spec()));
 
729
  return QUrl(QString::fromStdString(web_view_->GetURL().spec()));
1004
730
}
1005
731
 
1006
732
void WebView::setUrl(const QUrl& url) {
1007
 
  view_->SetURL(GURL(url.toString().toStdString()));
 
733
  web_view_->SetURL(GURL(url.toString().toStdString()));
1008
734
}
1009
735
 
1010
736
QString WebView::title() const {
1011
 
  return QString::fromStdString(view_->GetTitle());
 
737
  return QString::fromStdString(web_view_->GetTitle());
1012
738
}
1013
739
 
1014
740
QUrl WebView::favIconUrl() const {
1015
 
  return QUrl(QString::fromStdString(view_->GetFaviconURL().spec()));
 
741
  return QUrl(QString::fromStdString(web_view_->GetFaviconURL().spec()));
1016
742
}
1017
743
 
1018
744
bool WebView::canGoBack() const {
1019
 
  return view_->CanGoBack();
 
745
  return web_view_->CanGoBack();
1020
746
}
1021
747
 
1022
748
bool WebView::canGoForward() const {
1023
 
  return view_->CanGoForward();
 
749
  return web_view_->CanGoForward();
1024
750
}
1025
751
 
1026
752
bool WebView::incognito() const {
1027
 
  return view_->IsIncognito();
 
753
  return web_view_->IsIncognito();
1028
754
}
1029
755
 
1030
756
bool WebView::loading() const {
1031
 
  return view_->IsLoading();
 
757
  return web_view_->IsLoading();
1032
758
}
1033
759
 
1034
760
bool WebView::fullscreen() const {
1035
761
  return FullscreenHelper::FromWebContents(
1036
 
      view_->GetWebContents())->fullscreen_granted();
 
762
      web_view_->GetWebContents())->fullscreen_granted();
1037
763
}
1038
764
 
1039
765
void WebView::setFullscreen(bool fullscreen) {
1040
 
  FullscreenHelper::FromWebContents(view_->GetWebContents())
 
766
  FullscreenHelper::FromWebContents(web_view_->GetWebContents())
1041
767
      ->SetFullscreenGranted(fullscreen);
1042
768
}
1043
769
 
1044
 
WebFrameProxyHandle* WebView::rootFrame() const {
1045
 
  WebFrame* f = WebFrame::FromSharedWebFrame(view_->GetRootFrame());
 
770
QObject* WebView::rootFrame() const {
 
771
  WebFrame* f = WebFrame::FromSharedWebFrame(web_view_->GetRootFrame());
1046
772
  if (!f) {
1047
773
    return nullptr;
1048
774
  }
1050
776
  return f->handle();
1051
777
}
1052
778
 
1053
 
WebContextProxyHandle* WebView::context() const {
 
779
QObject* WebView::context() const {
1054
780
  WebContext* c = GetContext();
1055
781
  if (!c) {
1056
782
    return nullptr;
1059
785
  return c->handle();
1060
786
}
1061
787
 
1062
 
void WebView::wasResized() {
1063
 
  view_->WasResized();
1064
 
}
1065
 
 
1066
 
void WebView::screenUpdated() {
1067
 
  view_->ScreenUpdated();
1068
 
}
1069
 
 
1070
 
void WebView::visibilityChanged() {
1071
 
  view_->VisibilityChanged();
1072
 
}
1073
 
 
1074
 
void WebView::handleFocusEvent(QFocusEvent* event) {
1075
 
  input_method_context_->FocusChanged(event);
1076
 
  view_->FocusChanged();
1077
 
 
1078
 
  event->accept();
1079
 
}
1080
 
 
1081
 
void WebView::handleHoverEvent(QHoverEvent* event,
1082
 
                               const QPoint& window_pos,
1083
 
                               const QPoint& global_pos) {
1084
 
  view_->HandleMouseEvent(
1085
 
      MakeWebMouseEvent(event,
1086
 
                        window_pos,
1087
 
                        global_pos,
1088
 
                        GetDeviceScaleFactor(),
1089
 
                        view_->GetLocationBarContentOffsetDip()));
1090
 
  event->accept();
1091
 
}
1092
 
 
1093
 
void WebView::handleInputMethodEvent(QInputMethodEvent* event) {
1094
 
  input_method_context_->HandleEvent(event);
1095
 
  event->accept();
1096
 
}
1097
 
 
1098
 
void WebView::handleKeyEvent(QKeyEvent* event) {
1099
 
  content::NativeWebKeyboardEvent e(MakeNativeWebKeyboardEvent(event, false));
1100
 
  view_->HandleKeyEvent(e);
1101
 
 
1102
 
  // If the event is a printable character, send a corresponding Char event
1103
 
  if (event->type() == QEvent::KeyPress && e.text[0] != 0) {
1104
 
    view_->HandleKeyEvent(MakeNativeWebKeyboardEvent(event, true));
1105
 
  }
1106
 
 
1107
 
  event->accept();
1108
 
}
1109
 
 
1110
 
void WebView::handleMouseEvent(QMouseEvent* event) {
1111
 
  if (!(event->button() == Qt::LeftButton ||
1112
 
        event->button() == Qt::MidButton ||
1113
 
        event->button() == Qt::RightButton ||
1114
 
        event->button() == Qt::NoButton)) {
1115
 
    event->ignore();
1116
 
    return;
1117
 
  }
1118
 
 
1119
 
  view_->HandleMouseEvent(
1120
 
      MakeWebMouseEvent(event,
1121
 
                        GetDeviceScaleFactor(),
1122
 
                        view_->GetLocationBarContentOffsetDip()));
1123
 
  event->accept();
1124
 
}
1125
 
 
1126
 
void WebView::handleTouchEvent(QTouchEvent* event) {
1127
 
  ScopedVector<ui::TouchEvent> events;
1128
 
  touch_event_factory_.MakeEvents(event,
1129
 
                                  GetDeviceScaleFactor(),
1130
 
                                  view_->GetLocationBarContentOffsetDip(),
1131
 
                                  &events);
1132
 
 
1133
 
  for (size_t i = 0; i < events.size(); ++i) {
1134
 
    view_->HandleTouchEvent(*events[i]);
1135
 
  }
1136
 
 
1137
 
  event->accept();
1138
 
}
1139
 
 
1140
 
void WebView::handleTouchUngrabEvent() {
1141
 
  scoped_ptr<ui::TouchEvent> cancel_event(touch_event_factory_.Cancel());
1142
 
  view_->HandleTouchEvent(*cancel_event.get());
1143
 
}
1144
 
 
1145
 
void WebView::handleWheelEvent(QWheelEvent* event,
1146
 
                               const QPoint& window_pos) {
1147
 
  view_->HandleWheelEvent(
1148
 
      MakeWebMouseWheelEvent(event,
1149
 
                             window_pos,
1150
 
                             GetDeviceScaleFactor(),
1151
 
                             view_->GetLocationBarContentOffsetDip()));
1152
 
  event->accept();
1153
 
}
1154
 
 
1155
 
void WebView::handleDragEnterEvent(QDragEnterEvent* event) {
1156
 
  content::DropData drop_data;
1157
 
  gfx::Point location;
1158
 
  blink::WebDragOperationsMask allowed_ops = blink::WebDragOperationNone;
1159
 
  int key_modifiers = 0;
1160
 
 
1161
 
  GetDragEnterEventParams(event,
1162
 
                          GetDeviceScaleFactor(),
1163
 
                          &drop_data,
1164
 
                          &location,
1165
 
                          &allowed_ops,
1166
 
                          &key_modifiers);
1167
 
 
1168
 
  WebContentsView::FromWebContents(view_->GetWebContents())
1169
 
      ->HandleDragEnter(drop_data, location, allowed_ops, key_modifiers);
1170
 
 
1171
 
  event->accept();
1172
 
}
1173
 
 
1174
 
void WebView::handleDragMoveEvent(QDragMoveEvent* event) {
1175
 
  gfx::Point location;
1176
 
  int key_modifiers = 0;
1177
 
 
1178
 
  GetDropEventParams(event, GetDeviceScaleFactor(), &location, &key_modifiers);
1179
 
 
1180
 
  blink::WebDragOperation op =
1181
 
      WebContentsView::FromWebContents(view_->GetWebContents())
1182
 
        ->HandleDragMove(location, key_modifiers);
1183
 
 
1184
 
  Qt::DropAction action;
1185
 
  if ((action = ToQtDropAction(op)) != Qt::IgnoreAction) {
1186
 
    event->setDropAction(action);
1187
 
    event->accept();
1188
 
  } else {
1189
 
    event->ignore();
1190
 
  }
1191
 
}
1192
 
 
1193
 
void WebView::handleDragLeaveEvent(QDragLeaveEvent* event) {
1194
 
  WebContentsView::FromWebContents(view_->GetWebContents())->HandleDragLeave();
1195
 
}
1196
 
 
1197
 
void WebView::handleDropEvent(QDropEvent* event) {
1198
 
  gfx::Point location;
1199
 
  int key_modifiers = 0;
1200
 
 
1201
 
  GetDropEventParams(event, GetDeviceScaleFactor(), &location, &key_modifiers);
1202
 
 
1203
 
  blink::WebDragOperation op =
1204
 
      WebContentsView::FromWebContents(view_->GetWebContents())
1205
 
        ->HandleDrop(location, key_modifiers);
1206
 
 
1207
 
  Qt::DropAction action;
1208
 
  if ((action = ToQtDropAction(op)) != Qt::IgnoreAction) {
1209
 
    event->setDropAction(action);
1210
 
    event->accept();
1211
 
  } else {
1212
 
    event->ignore();
1213
 
  }
1214
 
}
1215
 
 
1216
 
QVariant WebView::inputMethodQuery(Qt::InputMethodQuery query) const {
1217
 
  return input_method_context_->Query(query);
1218
 
}
1219
 
 
1220
788
void WebView::goBack() {
1221
 
  view_->GoBack();
 
789
  web_view_->GoBack();
1222
790
}
1223
791
 
1224
792
void WebView::goForward() {
1225
 
  view_->GoForward();
 
793
  web_view_->GoForward();
1226
794
}
1227
795
 
1228
796
void WebView::stop() {
1229
 
  view_->Stop();
 
797
  web_view_->Stop();
1230
798
}
1231
799
 
1232
800
void WebView::reload() {
1233
 
  view_->Reload();
 
801
  web_view_->Reload();
1234
802
}
1235
803
 
1236
804
void WebView::loadHtml(const QString& html, const QUrl& base_url) {
1237
805
  QByteArray encoded_data = html.toUtf8().toPercentEncoding();
1238
 
  view_->LoadData(std::string(encoded_data.constData(), encoded_data.length()),
 
806
  web_view_->LoadData(std::string(encoded_data.constData(), encoded_data.length()),
1239
807
                  "text/html;charset=UTF-8",
1240
808
                  GURL(base_url.toString().toStdString()));
1241
809
}
1242
810
 
1243
 
QList<ScriptMessageHandlerProxyHandle*>& WebView::messageHandlers() {
 
811
QList<QObject*>& WebView::messageHandlers() {
1244
812
  return message_handlers_;
1245
813
}
1246
814
 
1247
815
int WebView::getNavigationEntryCount() const {
1248
 
  return view_->GetNavigationEntryCount();
 
816
  return web_view_->GetNavigationEntryCount();
1249
817
}
1250
818
 
1251
819
int WebView::getNavigationCurrentEntryIndex() const {
1252
 
  return view_->GetNavigationCurrentEntryIndex();
 
820
  return web_view_->GetNavigationCurrentEntryIndex();
1253
821
}
1254
822
 
1255
823
void WebView::setNavigationCurrentEntryIndex(int index) {
1256
 
  view_->SetNavigationCurrentEntryIndex(index);
 
824
  web_view_->SetNavigationCurrentEntryIndex(index);
1257
825
}
1258
826
 
1259
827
int WebView::getNavigationEntryUniqueID(int index) const {
1260
 
  return view_->GetNavigationEntryUniqueID(index);
 
828
  return web_view_->GetNavigationEntryUniqueID(index);
1261
829
}
1262
830
 
1263
831
QUrl WebView::getNavigationEntryUrl(int index) const {
1264
832
  return QUrl(QString::fromStdString(
1265
 
      view_->GetNavigationEntryUrl(index).spec()));
 
833
      web_view_->GetNavigationEntryUrl(index).spec()));
1266
834
}
1267
835
 
1268
836
QString WebView::getNavigationEntryTitle(int index) const {
1269
 
  return QString::fromStdString(view_->GetNavigationEntryTitle(index));
 
837
  return QString::fromStdString(web_view_->GetNavigationEntryTitle(index));
1270
838
}
1271
839
 
1272
840
QDateTime WebView::getNavigationEntryTimestamp(int index) const {
1273
841
  return QDateTime::fromMSecsSinceEpoch(
1274
 
      view_->GetNavigationEntryTimestamp(index).ToJsTime());
 
842
      web_view_->GetNavigationEntryTimestamp(index).ToJsTime());
1275
843
}
1276
844
 
1277
845
QByteArray WebView::currentState() const {
1278
846
  // XXX(chrisccoulson): Move the pickling in to oxide::WebView
1279
 
  std::vector<sessions::SerializedNavigationEntry> entries = view_->GetState();
 
847
  std::vector<sessions::SerializedNavigationEntry> entries = web_view_->GetState();
1280
848
  if (entries.size() == 0) {
1281
849
    return QByteArray();
1282
850
  }
1290
858
  for (i = entries.begin(); i != entries.end(); ++i) {
1291
859
    i->WriteToPickle(max_state_size, &pickle);
1292
860
  }
1293
 
  pickle.WriteInt(view_->GetNavigationCurrentEntryIndex());
 
861
  pickle.WriteInt(web_view_->GetNavigationCurrentEntryIndex());
1294
862
  return QByteArray(static_cast<const char*>(pickle.data()), pickle.size());
1295
863
}
1296
864
 
1297
865
OxideQWebPreferences* WebView::preferences() {
1298
866
  EnsurePreferences();
1299
 
  return static_cast<WebPreferences*>(view_->GetWebPreferences())->api_handle();
 
867
  return static_cast<WebPreferences*>(web_view_->GetWebPreferences())->api_handle();
1300
868
}
1301
869
 
1302
870
void WebView::setPreferences(OxideQWebPreferences* prefs) {
1303
871
  OxideQWebPreferences* old = nullptr;
1304
 
  if (WebPreferences* o = static_cast<WebPreferences *>(view_->GetWebPreferences())) {
 
872
  if (WebPreferences* o = static_cast<WebPreferences *>(web_view_->GetWebPreferences())) {
1305
873
    old = o->api_handle();
1306
874
  }
1307
875
 
1308
876
  if (!prefs) {
1309
 
    prefs = new OxideQWebPreferences(client_->GetApiHandle());
 
877
    prefs = new OxideQWebPreferences(handle());
1310
878
  } else if (!prefs->parent()) {
1311
 
    prefs->setParent(client_->GetApiHandle());
 
879
    prefs->setParent(handle());
1312
880
  }
1313
881
 
1314
 
  view_->SetWebPreferences(
 
882
  web_view_->SetWebPreferences(
1315
883
      OxideQWebPreferencesPrivate::get(prefs)->preferences());
1316
884
 
1317
885
  if (!old) {
1318
886
    return;
1319
887
  }
1320
888
 
1321
 
  if (old->parent() == client_->GetApiHandle()) {
 
889
  if (old->parent() == handle()) {
1322
890
    delete old;
1323
891
  }
1324
892
}
1325
893
 
1326
894
void WebView::updateWebPreferences() {
1327
 
  view_->UpdateWebPreferences();
 
895
  web_view_->UpdateWebPreferences();
1328
896
}
1329
897
 
1330
898
QPoint WebView::compositorFrameScrollOffsetPix() {
1331
 
  gfx::Point offset = view_->GetCompositorFrameScrollOffsetPix();
 
899
  gfx::Point offset = web_view_->GetCompositorFrameScrollOffsetPix();
1332
900
  return QPoint(offset.x(), offset.y());
1333
901
}
1334
902
 
1335
903
QSize WebView::compositorFrameContentSizePix() {
1336
 
  gfx::Size size = view_->GetCompositorFrameContentSizePix();
 
904
  gfx::Size size = web_view_->GetCompositorFrameContentSizePix();
1337
905
  return QSize(size.width(), size.height());
1338
906
}
1339
907
 
1340
908
QSize WebView::compositorFrameViewportSizePix() {
1341
 
  gfx::Size size = view_->GetCompositorFrameViewportSizePix();
 
909
  gfx::Size size = web_view_->GetCompositorFrameViewportSizePix();
1342
910
  return QSize(size.width(), size.height());
1343
911
}
1344
912
 
1345
 
QSharedPointer<CompositorFrameHandle> WebView::compositorFrameHandle() {
1346
 
  if (!compositor_frame_) {
1347
 
    compositor_frame_ =
1348
 
        QSharedPointer<CompositorFrameHandle>(new CompositorFrameHandleImpl(
1349
 
          view_->GetCompositorFrameHandle(),
1350
 
          view_->compositor_frame_metadata().device_scale_factor *
1351
 
            view_->compositor_frame_metadata().location_bar_content_translation.y()));
1352
 
  }
1353
 
 
1354
 
  return compositor_frame_;
1355
 
}
1356
 
 
1357
 
void WebView::didCommitCompositorFrame() {
1358
 
  view_->DidCommitCompositorFrame();
1359
 
}
1360
 
 
1361
913
void WebView::setCanTemporarilyDisplayInsecureContent(bool allow) {
1362
 
  view_->SetCanTemporarilyDisplayInsecureContent(allow);
 
914
  web_view_->SetCanTemporarilyDisplayInsecureContent(allow);
1363
915
}
1364
916
 
1365
917
void WebView::setCanTemporarilyRunInsecureContent(bool allow) {
1366
 
  view_->SetCanTemporarilyRunInsecureContent(allow);
 
918
  web_view_->SetCanTemporarilyRunInsecureContent(allow);
1367
919
}
1368
920
 
1369
921
ContentTypeFlags WebView::blockedContent() const {
1383
935
      "ContentTypeFlags and oxide::ContentType enums don't match: "
1384
936
      "CONTENT_TYPE_MIXED_SCRIPT");
1385
937
 
1386
 
  return static_cast<ContentTypeFlags>(view_->blocked_content());
 
938
  return static_cast<ContentTypeFlags>(web_view_->blocked_content());
1387
939
}
1388
940
 
1389
941
void WebView::prepareToClose() {
1390
 
  view_->PrepareToClose();
 
942
  web_view_->PrepareToClose();
1391
943
}
1392
944
 
1393
945
int WebView::locationBarHeight() const {
1394
 
  return view_->GetLocationBarHeightPix();
 
946
  return web_view_->GetLocationBarHeightPix();
1395
947
}
1396
948
 
1397
949
void WebView::setLocationBarHeight(int height) {
1398
 
  view_->SetLocationBarHeightPix(height);
 
950
  web_view_->SetLocationBarHeightPix(height);
1399
951
}
1400
952
 
1401
953
int WebView::locationBarOffsetPix() const {
1402
 
  return view_->GetLocationBarOffsetPix();
 
954
  return web_view_->GetLocationBarOffsetPix();
1403
955
}
1404
956
 
1405
957
int WebView::locationBarContentOffsetPix() const {
1406
 
  return view_->GetLocationBarContentOffsetPix();
 
958
  return web_view_->GetLocationBarContentOffsetPix();
1407
959
}
1408
960
 
1409
961
LocationBarMode WebView::locationBarMode() const {
1410
 
  switch (view_->location_bar_constraints()) {
 
962
  switch (web_view_->location_bar_constraints()) {
1411
963
    case blink::WebTopControlsShown:
1412
964
      return LOCATION_BAR_MODE_SHOWN;
1413
965
    case blink::WebTopControlsHidden:
1421
973
}
1422
974
 
1423
975
void WebView::setLocationBarMode(LocationBarMode mode) {
1424
 
  view_->SetLocationBarConstraints(
 
976
  web_view_->SetLocationBarConstraints(
1425
977
      LocationBarModeToBlinkTopControlsState(mode));
1426
978
}
1427
979
 
1428
980
bool WebView::locationBarAnimated() const {
1429
 
  return view_->location_bar_animated();
 
981
  return web_view_->location_bar_animated();
1430
982
}
1431
983
 
1432
984
void WebView::setLocationBarAnimated(bool animated) {
1433
 
  view_->set_location_bar_animated(animated);
 
985
  web_view_->set_location_bar_animated(animated);
1434
986
}
1435
987
 
1436
988
void WebView::locationBarShow(bool animate) {
1437
 
  view_->ShowLocationBar(animate);
 
989
  web_view_->ShowLocationBar(animate);
1438
990
}
1439
991
 
1440
992
void WebView::locationBarHide(bool animate) {
1441
 
  view_->HideLocationBar(animate);
 
993
  web_view_->HideLocationBar(animate);
1442
994
}
1443
995
 
1444
996
WebProcessStatus WebView::webProcessStatus() const {
1445
 
  base::TerminationStatus status = view_->GetWebContents()->GetCrashedStatus();
 
997
  base::TerminationStatus status = web_view_->GetWebContents()->GetCrashedStatus();
1446
998
  if (status == base::TERMINATION_STATUS_STILL_RUNNING) {
1447
999
    return WEB_PROCESS_RUNNING;
1448
1000
  } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
1455
1007
}
1456
1008
 
1457
1009
void WebView::executeEditingCommand(EditingCommands command) const {
1458
 
  content::WebContents* contents = view_->GetWebContents();
 
1010
  content::WebContents* contents = web_view_->GetWebContents();
1459
1011
 
1460
1012
  switch (command) {
1461
1013
    case EDITING_COMMAND_UNDO:
1478
1030
}
1479
1031
 
1480
1032
QUrl WebView::targetUrl() const {
1481
 
  return QUrl(QString::fromStdString(view_->target_url().spec()));
 
1033
  return QUrl(QString::fromStdString(web_view_->target_url().spec()));
1482
1034
}
1483
1035
 
1484
1036
EditCapabilityFlags WebView::editFlags() const {
1485
1037
  EditCapabilityFlags capabilities = NO_CAPABILITY;
1486
 
  int flags = view_->GetEditFlags();
 
1038
  blink::WebContextMenuData::EditFlags flags = web_view_->GetEditFlags();
1487
1039
  if (flags & blink::WebContextMenuData::CanUndo) {
1488
1040
    capabilities |= UNDO_CAPABILITY;
1489
1041
  }
1514
1066
  WebFrameTreeObserver::Observe(nullptr);
1515
1067
 
1516
1068
  std::deque<oxide::WebFrame*> frames;
1517
 
  WebFrameTree::FromWebContents(view_->GetWebContents())->ForEachFrame(
 
1069
  WebFrameTree::FromWebContents(web_view_->GetWebContents())->ForEachFrame(
1518
1070
      base::Bind(&TeardownFrameTreeForEachHelper, &frames));
1519
1071
  while (frames.size() > 0) {
1520
1072
    oxide::WebFrame* frame = frames.back();
1527
1079
}
1528
1080
 
1529
1081
WebView::WebView(WebViewProxyClient* client,
1530
 
                 QObject* native_view,
 
1082
                 ContentsViewProxyClient* view_client,
 
1083
                 QObject* handle,
1531
1084
                 OxideQFindController* find_controller,
1532
1085
                 OxideQSecurityStatus* security_status,
1533
1086
                 WebContext* context,
1534
1087
                 bool incognito,
1535
1088
                 const QByteArray& restore_state,
1536
1089
                 RestoreType restore_type)
1537
 
    : WebView(client, security_status) {
1538
 
  oxide::WebView::Params params;
1539
 
  params.client = this;
1540
 
  params.context = context->GetContext();
1541
 
  params.incognito = incognito;
 
1090
    : WebView(client, view_client, handle, security_status) {
 
1091
  oxide::WebView::CommonParams common_params;
 
1092
  common_params.client = this;
 
1093
  common_params.view_client = contents_view_.get();
 
1094
 
 
1095
  oxide::WebView::CreateParams create_params;
 
1096
  create_params.context = context->GetContext();
 
1097
  create_params.incognito = incognito;
1542
1098
 
1543
1099
  if (!restore_state.isEmpty()) {
1544
1100
    CreateRestoreEntriesFromRestoreState(restore_state,
1545
 
                                         &params.restore_entries,
1546
 
                                         &params.restore_index);
1547
 
    params.restore_type = ToNavigationControllerRestoreType(restore_type);
 
1101
                                         &create_params.restore_entries,
 
1102
                                         &create_params.restore_index);
 
1103
    create_params.restore_type =
 
1104
        ToNavigationControllerRestoreType(restore_type);
1548
1105
  }
1549
1106
 
1550
1107
  if (oxide::BrowserProcessMain::GetInstance()->GetProcessModel() ==
1553
1110
    DCHECK_EQ(context, WebContext::GetDefault());
1554
1111
  }
1555
1112
 
1556
 
  view_.reset(new oxide::WebView(params));
 
1113
  web_view_.reset(new oxide::WebView(common_params, create_params));
1557
1114
 
1558
 
  CommonInit(find_controller, native_view);
 
1115
  CommonInit(find_controller);
1559
1116
 
1560
1117
  EnsurePreferences();
1561
1118
}
1563
1120
// static
1564
1121
WebView* WebView::CreateFromNewViewRequest(
1565
1122
    WebViewProxyClient* client,
1566
 
    QObject* native_view,
 
1123
    ContentsViewProxyClient* view_client,
 
1124
    QObject* handle,
1567
1125
    OxideQFindController* find_controller,
1568
1126
    OxideQSecurityStatus* security_status,
1569
1127
    OxideQNewViewRequest* new_view_request) {
1573
1131
    return nullptr;
1574
1132
  }
1575
1133
 
1576
 
  WebView* new_view = new WebView(client, security_status);
1577
 
  new_view->view_.reset(new oxide::WebView(std::move(rd->contents), new_view));
1578
 
  rd->view = new_view->view_->AsWeakPtr();
1579
 
 
1580
 
  new_view->CommonInit(find_controller, native_view);
 
1134
  WebView* new_view = new WebView(client, view_client, handle, security_status);
 
1135
 
 
1136
  oxide::WebView::CommonParams params;
 
1137
  params.client = new_view;
 
1138
  params.view_client = new_view->contents_view_.get();
 
1139
  new_view->web_view_.reset(new oxide::WebView(params, std::move(rd->contents)));
 
1140
 
 
1141
  rd->view = new_view->web_view_->AsWeakPtr();
 
1142
 
 
1143
  new_view->CommonInit(find_controller);
1581
1144
 
1582
1145
  OxideQWebPreferences* p =
1583
1146
      static_cast<WebPreferences*>(
1584
 
        new_view->view_->GetWebPreferences())->api_handle();
 
1147
        new_view->web_view_->GetWebPreferences())->api_handle();
1585
1148
  if (!p->parent()) {
1586
 
    p->setParent(new_view->client_->GetApiHandle());
 
1149
    p->setParent(new_view->handle());
1587
1150
  }
1588
1151
 
1589
1152
  return new_view;
1590
1153
}
1591
1154
 
1592
1155
WebView::~WebView() {
1593
 
  content::WebContents* contents = view_->GetWebContents();
 
1156
  content::WebContents* contents = web_view_->GetWebContents();
1594
1157
  CertificateErrorDispatcher::FromWebContents(contents)->set_client(nullptr);
1595
1158
  FullscreenHelper::FromWebContents(contents)->set_client(nullptr);
1596
1159
  DCHECK(frame_tree_torn_down_);
1597
1160
 
1598
 
  input_method_context_->DetachClient();
1599
 
 
1600
1161
  oxide::PermissionRequestDispatcher::FromWebContents(
1601
1162
      contents)->set_client(nullptr);
1602
1163
}
1603
1164
 
1604
1165
// static
1605
 
WebView* WebView::FromProxyHandle(WebViewProxyHandle* handle) {
1606
 
  return static_cast<WebView*>(handle->proxy_.data());
1607
 
}
1608
 
 
1609
 
// static
1610
1166
WebView* WebView::FromView(oxide::WebView* view) {
1611
1167
  return static_cast<WebView*>(view->client());
1612
1168
}
1613
1169
 
1614
1170
WebContext* WebView::GetContext() const {
1615
 
  return WebContext::FromBrowserContext(view_->GetBrowserContext());
 
1171
  return WebContext::FromBrowserContext(web_view_->GetBrowserContext());
1616
1172
}
1617
1173
 
1618
1174
const oxide::SecurityStatus& WebView::GetSecurityStatus() const {
1619
 
  return view_->security_status();
 
1175
  return web_view_->security_status();
1620
1176
}
1621
1177
 
1622
1178
} // namespace qt