| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 WebParsedFeaturePolicy(), client, nullptr)); | 183 WebParsedFeaturePolicy(), client, nullptr)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 WebViewHelper::WebViewHelper(SettingOverrider* setting_overrider) | 186 WebViewHelper::WebViewHelper(SettingOverrider* setting_overrider) |
| 187 : web_view_(nullptr), setting_overrider_(setting_overrider) {} | 187 : web_view_(nullptr), setting_overrider_(setting_overrider) {} |
| 188 | 188 |
| 189 WebViewHelper::~WebViewHelper() { | 189 WebViewHelper::~WebViewHelper() { |
| 190 Reset(); | 190 Reset(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 WebViewImpl* WebViewHelper::InitializeWithOpener( | 193 WebViewBase* WebViewHelper::InitializeWithOpener( |
| 194 WebFrame* opener, | 194 WebFrame* opener, |
| 195 bool enable_javascript, | 195 bool enable_javascript, |
| 196 TestWebFrameClient* web_frame_client, | 196 TestWebFrameClient* web_frame_client, |
| 197 TestWebViewClient* web_view_client, | 197 TestWebViewClient* web_view_client, |
| 198 TestWebWidgetClient* web_widget_client, | 198 TestWebWidgetClient* web_widget_client, |
| 199 void (*update_settings_func)(WebSettings*)) { | 199 void (*update_settings_func)(WebSettings*)) { |
| 200 Reset(); | 200 Reset(); |
| 201 | 201 |
| 202 if (!web_frame_client) | 202 if (!web_frame_client) |
| 203 web_frame_client = DefaultWebFrameClient(); | 203 web_frame_client = DefaultWebFrameClient(); |
| 204 if (!web_view_client) | 204 if (!web_view_client) |
| 205 web_view_client = DefaultWebViewClient(); | 205 web_view_client = DefaultWebViewClient(); |
| 206 if (!web_widget_client) | 206 if (!web_widget_client) |
| 207 web_widget_client = web_view_client->WidgetClient(); | 207 web_widget_client = web_view_client->WidgetClient(); |
| 208 web_view_ = | 208 web_view_ = |
| 209 WebViewImpl::Create(web_view_client, kWebPageVisibilityStateVisible); | 209 WebViewBase::Create(web_view_client, kWebPageVisibilityStateVisible); |
| 210 web_view_->GetSettings()->SetJavaScriptEnabled(enable_javascript); | 210 web_view_->GetSettings()->SetJavaScriptEnabled(enable_javascript); |
| 211 web_view_->GetSettings()->SetPluginsEnabled(true); | 211 web_view_->GetSettings()->SetPluginsEnabled(true); |
| 212 // Enable (mocked) network loads of image URLs, as this simplifies | 212 // Enable (mocked) network loads of image URLs, as this simplifies |
| 213 // the completion of resource loads upon test shutdown & helps avoid | 213 // the completion of resource loads upon test shutdown & helps avoid |
| 214 // dormant loads trigger Resource leaks for image loads. | 214 // dormant loads trigger Resource leaks for image loads. |
| 215 // | 215 // |
| 216 // Consequently, all external image resources must be mocked. | 216 // Consequently, all external image resources must be mocked. |
| 217 web_view_->GetSettings()->SetLoadsImagesAutomatically(true); | 217 web_view_->GetSettings()->SetLoadsImagesAutomatically(true); |
| 218 if (update_settings_func) | 218 if (update_settings_func) |
| 219 update_settings_func(web_view_->GetSettings()); | 219 update_settings_func(web_view_->GetSettings()); |
| 220 if (setting_overrider_) | 220 if (setting_overrider_) |
| 221 setting_overrider_->OverrideSettings(web_view_->GetSettings()); | 221 setting_overrider_->OverrideSettings(web_view_->GetSettings()); |
| 222 web_view_->SetDeviceScaleFactor( | 222 web_view_->SetDeviceScaleFactor( |
| 223 web_view_client->GetScreenInfo().device_scale_factor); | 223 web_view_client->GetScreenInfo().device_scale_factor); |
| 224 web_view_->SetDefaultPageScaleLimits(1, 4); | 224 web_view_->SetDefaultPageScaleLimits(1, 4); |
| 225 WebLocalFrame* frame = WebLocalFrameImpl::Create( | 225 WebLocalFrame* frame = WebLocalFrameImpl::Create( |
| 226 WebTreeScopeType::kDocument, web_frame_client, | 226 WebTreeScopeType::kDocument, web_frame_client, |
| 227 web_frame_client->GetInterfaceProvider(), nullptr, opener); | 227 web_frame_client->GetInterfaceProvider(), nullptr, opener); |
| 228 web_view_->SetMainFrame(frame); | 228 web_view_->SetMainFrame(frame); |
| 229 web_frame_client->SetFrame(frame); | 229 web_frame_client->SetFrame(frame); |
| 230 // TODO(dcheng): The main frame widget currently has a special case. | 230 // TODO(dcheng): The main frame widget currently has a special case. |
| 231 // Eliminate this once WebView is no longer a WebWidget. | 231 // Eliminate this once WebView is no longer a WebWidget. |
| 232 blink::WebFrameWidget::Create(web_widget_client, web_view_, frame); | 232 blink::WebFrameWidget::Create(web_widget_client, web_view_, frame); |
| 233 | 233 |
| 234 test_web_view_client_ = web_view_client; | 234 test_web_view_client_ = web_view_client; |
| 235 | 235 |
| 236 return web_view_; | 236 return web_view_; |
| 237 } | 237 } |
| 238 | 238 |
| 239 WebViewImpl* WebViewHelper::Initialize( | 239 WebViewBase* WebViewHelper::Initialize( |
| 240 bool enable_javascript, | 240 bool enable_javascript, |
| 241 TestWebFrameClient* web_frame_client, | 241 TestWebFrameClient* web_frame_client, |
| 242 TestWebViewClient* web_view_client, | 242 TestWebViewClient* web_view_client, |
| 243 TestWebWidgetClient* web_widget_client, | 243 TestWebWidgetClient* web_widget_client, |
| 244 void (*update_settings_func)(WebSettings*)) { | 244 void (*update_settings_func)(WebSettings*)) { |
| 245 return InitializeWithOpener(nullptr, enable_javascript, web_frame_client, | 245 return InitializeWithOpener(nullptr, enable_javascript, web_frame_client, |
| 246 web_view_client, web_widget_client, | 246 web_view_client, web_widget_client, |
| 247 update_settings_func); | 247 update_settings_func); |
| 248 } | 248 } |
| 249 | 249 |
| 250 WebViewImpl* WebViewHelper::InitializeAndLoad( | 250 WebViewBase* WebViewHelper::InitializeAndLoad( |
| 251 const std::string& url, | 251 const std::string& url, |
| 252 bool enable_javascript, | 252 bool enable_javascript, |
| 253 TestWebFrameClient* web_frame_client, | 253 TestWebFrameClient* web_frame_client, |
| 254 TestWebViewClient* web_view_client, | 254 TestWebViewClient* web_view_client, |
| 255 TestWebWidgetClient* web_widget_client, | 255 TestWebWidgetClient* web_widget_client, |
| 256 void (*update_settings_func)(WebSettings*)) { | 256 void (*update_settings_func)(WebSettings*)) { |
| 257 Initialize(enable_javascript, web_frame_client, web_view_client, | 257 Initialize(enable_javascript, web_frame_client, web_view_client, |
| 258 web_widget_client, update_settings_func); | 258 web_widget_client, update_settings_func); |
| 259 | 259 |
| 260 LoadFrame(WebView()->MainFrame(), url); | 260 LoadFrame(WebView()->MainFrame(), url); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 test_web_view_client_->ScheduleAnimation(); | 353 test_web_view_client_->ScheduleAnimation(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void TestWebViewWidgetClient::DidMeaningfulLayout( | 356 void TestWebViewWidgetClient::DidMeaningfulLayout( |
| 357 WebMeaningfulLayout layout_type) { | 357 WebMeaningfulLayout layout_type) { |
| 358 test_web_view_client_->DidMeaningfulLayout(layout_type); | 358 test_web_view_client_->DidMeaningfulLayout(layout_type); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace FrameTestHelpers | 361 } // namespace FrameTestHelpers |
| 362 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |