~osomon/oxide/ensure-files-exist

« back to all changes in this revision

Viewing changes to shared/browser/oxide_web_view.h

  • Committer: Olivier Tilloy
  • Date: 2014-09-25 16:27:09 UTC
  • mfrom: (677.1.95 oxide)
  • Revision ID: olivier.tilloy@canonical.com-20140925162709-h8bai0f1nfaf7cfy
Merge the latest changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "base/memory/scoped_ptr.h"
31
31
#include "base/memory/weak_ptr.h"
32
32
#include "base/strings/string16.h"
 
33
#include "base/timer/timer.h"
33
34
#include "cc/output/compositor_frame_metadata.h"
34
35
#include "content/browser/renderer_host/event_with_latency_info.h"
35
36
#include "content/common/input/input_event_ack_state.h"
 
37
#include "content/public/browser/certificate_request_result_type.h"
36
38
#include "content/public/browser/notification_observer.h"
37
39
#include "content/public/browser/notification_registrar.h"
38
40
#include "content/public/browser/web_contents_observer.h"
39
41
#include "content/public/common/javascript_message_type.h"
 
42
#include "content/public/common/resource_type.h"
40
43
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
41
44
#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
42
45
#include "ui/base/ime/text_input_type.h"
45
48
 
46
49
#include "shared/browser/compositor/oxide_compositor_client.h"
47
50
#include "shared/browser/oxide_browser_context.h"
 
51
#include "shared/browser/oxide_content_types.h"
48
52
#include "shared/browser/oxide_gesture_provider.h"
49
53
#include "shared/browser/oxide_permission_request.h"
50
54
#include "shared/browser/oxide_script_message_target.h"
 
55
#include "shared/browser/oxide_security_status.h"
 
56
#include "shared/browser/oxide_security_types.h"
51
57
#include "shared/browser/oxide_web_preferences_observer.h"
52
58
#include "shared/browser/oxide_web_view_contents_helper_delegate.h"
53
59
#include "shared/common/oxide_message_enums.h"
67
73
class NativeWebKeyboardEvent;
68
74
class NotificationRegistrar;
69
75
struct OpenURLParams;
 
76
class RenderFrameHost;
70
77
class RenderViewHost;
71
78
class RenderWidgetHostImpl;
72
79
class WebContents;
80
87
class Size;
81
88
}
82
89
 
 
90
namespace net {
 
91
class SSLInfo;
 
92
}
 
93
 
83
94
namespace ui {
84
95
class GestureEvent;
85
96
class TouchEvent;
125
136
 
126
137
  static WebView* FromWebContents(const content::WebContents* web_contents);
127
138
  static WebView* FromRenderViewHost(content::RenderViewHost* rvh);
 
139
  static WebView* FromRenderFrameHost(content::RenderFrameHost* rfh);
128
140
 
129
141
  static std::set<WebView*> GetAllWebViewsFor(
130
142
      BrowserContext * browser_context);
156
168
  void WasResized();
157
169
  void VisibilityChanged();
158
170
  void FocusChanged();
 
171
  void InputPanelVisibilityChanged();
159
172
 
160
173
  BrowserContext* GetBrowserContext() const;
161
174
  content::WebContents* GetWebContents() const;
174
187
  WebPreferences* GetWebPreferences();
175
188
  void SetWebPreferences(WebPreferences* prefs);
176
189
 
177
 
  gfx::Size GetContainerSizePix() const;
178
 
  gfx::Rect GetContainerBoundsDip() const;
179
 
  gfx::Size GetContainerSizeDip() const;
 
190
  gfx::Size GetViewSizePix() const;
 
191
  gfx::Rect GetViewBoundsDip() const;
 
192
  gfx::Size GetViewSizeDip() const;
180
193
 
181
194
  const cc::CompositorFrameMetadata& compositor_frame_metadata() const {
182
195
    return compositor_frame_metadata_;
183
196
  }
184
197
 
185
 
  void ShowPopupMenu(const gfx::Rect& bounds,
 
198
  const SecurityStatus& security_status() const { return security_status_; }
 
199
 
 
200
  ContentType blocked_content() const { return blocked_content_; }
 
201
 
 
202
  void SetCanTemporarilyDisplayInsecureContent(bool allow);
 
203
  void SetCanTemporarilyRunInsecureContent(bool allow);
 
204
 
 
205
  void ShowPopupMenu(content::RenderFrameHost* render_frame_host,
 
206
                     const gfx::Rect& bounds,
186
207
                     int selected_item,
187
208
                     const std::vector<content::MenuItem>& items,
188
209
                     bool allow_multiple_selection);
189
210
  void HidePopupMenu();
190
211
 
191
212
  void RequestGeolocationPermission(
192
 
      int id,
193
213
      const GURL& origin,
194
 
      const base::Callback<void(bool)>& callback);
195
 
  void CancelGeolocationPermissionRequest(int id);
 
214
      const base::Callback<void(bool)>& callback,
 
215
      base::Closure* cancel_callback);
196
216
 
 
217
  void AllowCertificateError(content::RenderFrameHost* rfh,
 
218
                             int cert_error,
 
219
                             const net::SSLInfo& ssl_info,
 
220
                             const GURL& request_url,
 
221
                             content::ResourceType resource_type,
 
222
                             bool overridable,
 
223
                             bool strict_enforcement,
 
224
                             const base::Callback<void(bool)>& callback,
 
225
                             content::CertificateRequestResultType* result);
 
226
                             
197
227
  void UpdateWebPreferences();
198
228
 
199
229
  void HandleKeyEvent(const content::NativeWebKeyboardEvent& event);
239
269
  // ============================
240
270
 
241
271
  virtual blink::WebScreenInfo GetScreenInfo() const = 0;
242
 
  virtual gfx::Rect GetContainerBoundsPix() const = 0;
 
272
  virtual gfx::Rect GetViewBoundsPix() const = 0;
243
273
  virtual bool IsVisible() const = 0;
244
274
  virtual bool HasFocus() const = 0;
 
275
  virtual bool IsInputPanelVisible() const;
245
276
 
246
277
  virtual JavaScriptDialog* CreateJavaScriptDialog(
247
278
      content::JavaScriptMessageType javascript_message_type,
276
307
                          int error_code,
277
308
                          const base::string16& error_description);
278
309
 
 
310
  void OnDidBlockDisplayingInsecureContent();
 
311
  void OnDidBlockRunningInsecureContent();
 
312
 
 
313
  bool ShouldScrollFocusedEditableNodeIntoView();
 
314
  void MaybeResetAutoScrollTimer();
 
315
  void ScrollFocusedEditableNodeIntoView();
 
316
 
279
317
  // ScriptMessageTarget implementation
280
318
  virtual size_t GetScriptMessageHandlerCount() const OVERRIDE;
281
319
  virtual ScriptMessageHandler* GetScriptMessageHandlerAt(
299
337
 
300
338
  // WebViewContentsHelperDelegate implementation
301
339
  content::WebContents* OpenURL(const content::OpenURLParams& params) FINAL;
302
 
  void NavigationStateChanged(unsigned flags) FINAL;
 
340
  void NavigationStateChanged(content::InvalidateTypes flags) FINAL;
 
341
  void SSLStateChanged() FINAL;
303
342
  bool ShouldCreateWebContents(const GURL& target_url,
304
343
                               WindowOpenDisposition disposition,
305
344
                               bool user_gesture) FINAL;
334
373
  void DidCommitProvisionalLoadForFrame(
335
374
      content::RenderFrameHost* render_frame_host,
336
375
      const GURL& url,
337
 
      content::PageTransition transition_type) FINAL;
 
376
      ui::PageTransition transition_type) FINAL;
338
377
 
339
378
  void DidFailProvisionalLoad(
340
379
      content::RenderFrameHost* render_frame_host,
342
381
      int error_code,
343
382
      const base::string16& error_description) FINAL;
344
383
 
 
384
  void DidNavigateMainFrame(
 
385
      const content::LoadCommittedDetails& details,
 
386
      const content::FrameNavigateParams& params) FINAL;
 
387
 
345
388
  void DidFinishLoad(content::RenderFrameHost* render_frame_host,
346
389
                     const GURL& validated_url) FINAL;
347
390
  void DidFailLoad(content::RenderFrameHost* render_frame_host,
352
395
  void NavigationEntryCommitted(
353
396
      const content::LoadCommittedDetails& load_details) FINAL;
354
397
 
 
398
  void DidStartLoading(content::RenderViewHost* render_view_host) FINAL;
 
399
  void DidStopLoading(content::RenderViewHost* render_view_host) FINAL;
 
400
 
355
401
  void FrameDetached(content::RenderFrameHost* render_frame_host) FINAL;
356
402
 
357
403
  void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL;
359
405
  void DidUpdateFaviconURL(
360
406
      const std::vector<content::FaviconURL>& candidates) FINAL;
361
407
 
 
408
  bool OnMessageReceived(const IPC::Message& msg,
 
409
                         content::RenderFrameHost* render_frame_host) FINAL;
 
410
 
362
411
  // Override in sub-classes
363
412
  virtual void OnURLChanged();
364
413
  virtual void OnTitleChanged();
365
414
  virtual void OnIconChanged(const GURL& icon);
366
415
  virtual void OnCommandsUpdated();
367
416
 
 
417
  virtual void OnLoadingChanged();
368
418
  virtual void OnLoadProgressChanged(double progress);
369
419
 
370
420
  virtual void OnLoadStarted(const GURL& validated_url,
371
421
                             bool is_error_frame);
 
422
  virtual void OnLoadCommitted(const GURL& url);
372
423
  virtual void OnLoadStopped(const GURL& validated_url);
373
424
  virtual void OnLoadFailed(const GURL& validated_url,
374
425
                            int error_code,
389
440
  virtual void OnWebPreferencesDestroyed();
390
441
 
391
442
  virtual void OnRequestGeolocationPermission(
392
 
      scoped_ptr<GeolocationPermissionRequest> request);
 
443
      const GURL& origin,
 
444
      const GURL& embedder,
 
445
      scoped_ptr<SimplePermissionRequest> request);
393
446
 
394
447
  virtual void OnUnhandledKeyboardEvent(
395
448
      const content::NativeWebKeyboardEvent& event);
409
462
                                      bool user_gesture);
410
463
 
411
464
  virtual WebFrame* CreateWebFrame(content::FrameTreeNode* node) = 0;
412
 
  virtual WebPopupMenu* CreatePopupMenu(content::RenderViewHost* rvh);
 
465
  virtual WebPopupMenu* CreatePopupMenu(content::RenderFrameHost* rfh);
413
466
 
414
467
  virtual WebView* CreateNewWebView(const gfx::Rect& initial_pos,
415
468
                                    WindowOpenDisposition disposition);
423
476
  virtual void OnFocusedNodeChanged();
424
477
  virtual void OnSelectionBoundsChanged();
425
478
 
 
479
  virtual void OnSecurityStatusChanged(const SecurityStatus& old);
 
480
  virtual bool OnCertificateError(
 
481
      bool is_main_frame,
 
482
      CertError cert_error,
 
483
      const scoped_refptr<net::X509Certificate>& cert,
 
484
      const GURL& request_url,
 
485
      content::ResourceType resource_type,
 
486
      bool strict_enforcement,
 
487
      scoped_ptr<SimplePermissionRequest> request);
 
488
  virtual void OnContentBlocked();
 
489
 
426
490
  scoped_ptr<content::WebContentsImpl> web_contents_;
427
491
  WebViewContentsHelper* web_contents_helper_;
428
492
 
445
509
  base::WeakPtr<WebPopupMenu> active_popup_menu_;
446
510
  base::WeakPtr<FilePicker> active_file_picker_;
447
511
 
448
 
  PermissionRequestManager geolocation_permission_requests_;
 
512
  PermissionRequestManager permission_request_manager_;
 
513
 
 
514
  ContentType blocked_content_;
449
515
 
450
516
  cc::CompositorFrameMetadata compositor_frame_metadata_;
451
517
 
 
518
  SecurityStatus security_status_;
 
519
 
 
520
  // Usually we would scroll the focused editable node in to view after any
 
521
  // resize if the input method is onscreen. However, this interacts badly
 
522
  // with the browser header bar, which resizes the view when its visibility
 
523
  // changes. To work around this, we don't scroll the focused node into
 
524
  // view on a resize if it has already been scrolled once and the input
 
525
  // method hasn't been hidden. This is reset if the input method goes
 
526
  // offscreen or the focused node changes. To do this, we add a delay to
 
527
  // ensure that we only do the scroll once any transitions are finished
 
528
  // See https://bugs.launchpad.net/oxide/+bug/1301681/comments/3
 
529
  //
 
530
  // We should be able to get rid of this once we have a solution for
 
531
  // https://launchpad.net/bugs/1370366
 
532
  bool did_scroll_focused_editable_node_into_view_;
 
533
  base::Timer auto_scroll_timer_;
 
534
 
452
535
  DISALLOW_COPY_AND_ASSIGN(WebView);
453
536
};
454
537