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"
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"
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);
129
141
static std::set<WebView*> GetAllWebViewsFor(
130
142
BrowserContext * browser_context);
174
187
WebPreferences* GetWebPreferences();
175
188
void SetWebPreferences(WebPreferences* prefs);
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;
181
194
const cc::CompositorFrameMetadata& compositor_frame_metadata() const {
182
195
return compositor_frame_metadata_;
185
void ShowPopupMenu(const gfx::Rect& bounds,
198
const SecurityStatus& security_status() const { return security_status_; }
200
ContentType blocked_content() const { return blocked_content_; }
202
void SetCanTemporarilyDisplayInsecureContent(bool allow);
203
void SetCanTemporarilyRunInsecureContent(bool allow);
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();
191
212
void RequestGeolocationPermission(
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);
217
void AllowCertificateError(content::RenderFrameHost* rfh,
219
const net::SSLInfo& ssl_info,
220
const GURL& request_url,
221
content::ResourceType resource_type,
223
bool strict_enforcement,
224
const base::Callback<void(bool)>& callback,
225
content::CertificateRequestResultType* result);
197
227
void UpdateWebPreferences();
199
229
void HandleKeyEvent(const content::NativeWebKeyboardEvent& event);
239
269
// ============================
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;
246
277
virtual JavaScriptDialog* CreateJavaScriptDialog(
247
278
content::JavaScriptMessageType javascript_message_type,
277
308
const base::string16& error_description);
310
void OnDidBlockDisplayingInsecureContent();
311
void OnDidBlockRunningInsecureContent();
313
bool ShouldScrollFocusedEditableNodeIntoView();
314
void MaybeResetAutoScrollTimer();
315
void ScrollFocusedEditableNodeIntoView();
279
317
// ScriptMessageTarget implementation
280
318
virtual size_t GetScriptMessageHandlerCount() const OVERRIDE;
281
319
virtual ScriptMessageHandler* GetScriptMessageHandlerAt(
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,
337
content::PageTransition transition_type) FINAL;
376
ui::PageTransition transition_type) FINAL;
339
378
void DidFailProvisionalLoad(
340
379
content::RenderFrameHost* render_frame_host,
343
382
const base::string16& error_description) FINAL;
384
void DidNavigateMainFrame(
385
const content::LoadCommittedDetails& details,
386
const content::FrameNavigateParams& params) FINAL;
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;
398
void DidStartLoading(content::RenderViewHost* render_view_host) FINAL;
399
void DidStopLoading(content::RenderViewHost* render_view_host) FINAL;
355
401
void FrameDetached(content::RenderFrameHost* render_frame_host) FINAL;
357
403
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL;
359
405
void DidUpdateFaviconURL(
360
406
const std::vector<content::FaviconURL>& candidates) FINAL;
408
bool OnMessageReceived(const IPC::Message& msg,
409
content::RenderFrameHost* render_frame_host) FINAL;
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();
417
virtual void OnLoadingChanged();
368
418
virtual void OnLoadProgressChanged(double progress);
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,
389
440
virtual void OnWebPreferencesDestroyed();
391
442
virtual void OnRequestGeolocationPermission(
392
scoped_ptr<GeolocationPermissionRequest> request);
444
const GURL& embedder,
445
scoped_ptr<SimplePermissionRequest> request);
394
447
virtual void OnUnhandledKeyboardEvent(
395
448
const content::NativeWebKeyboardEvent& event);
409
462
bool user_gesture);
411
464
virtual WebFrame* CreateWebFrame(content::FrameTreeNode* node) = 0;
412
virtual WebPopupMenu* CreatePopupMenu(content::RenderViewHost* rvh);
465
virtual WebPopupMenu* CreatePopupMenu(content::RenderFrameHost* rfh);
414
467
virtual WebView* CreateNewWebView(const gfx::Rect& initial_pos,
415
468
WindowOpenDisposition disposition);
423
476
virtual void OnFocusedNodeChanged();
424
477
virtual void OnSelectionBoundsChanged();
479
virtual void OnSecurityStatusChanged(const SecurityStatus& old);
480
virtual bool OnCertificateError(
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();
426
490
scoped_ptr<content::WebContentsImpl> web_contents_;
427
491
WebViewContentsHelper* web_contents_helper_;
445
509
base::WeakPtr<WebPopupMenu> active_popup_menu_;
446
510
base::WeakPtr<FilePicker> active_file_picker_;
448
PermissionRequestManager geolocation_permission_requests_;
512
PermissionRequestManager permission_request_manager_;
514
ContentType blocked_content_;
450
516
cc::CompositorFrameMetadata compositor_frame_metadata_;
518
SecurityStatus security_status_;
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
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_;
452
535
DISALLOW_COPY_AND_ASSIGN(WebView);