OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> |
9 | 10 |
10 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/debug/alias.h" | 16 #include "base/debug/alias.h" |
16 #include "base/debug/crash_logging.h" | 17 #include "base/debug/crash_logging.h" |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
18 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
19 #include "base/json/json_writer.h" | 20 #include "base/json/json_writer.h" |
20 #include "base/lazy_instance.h" | 21 #include "base/lazy_instance.h" |
21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/ptr_util.h" |
22 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
24 #include "base/process/kill.h" | 25 #include "base/process/kill.h" |
25 #include "base/process/process.h" | 26 #include "base/process/process.h" |
26 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
27 #include "base/strings/string_piece.h" | 28 #include "base/strings/string_piece.h" |
28 #include "base/strings/string_split.h" | 29 #include "base/strings/string_split.h" |
29 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
30 #include "base/strings/sys_string_conversions.h" | 31 #include "base/strings/sys_string_conversions.h" |
31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 CHECK(params.swapped_out); | 716 CHECK(params.swapped_out); |
716 RenderFrameProxy::CreateFrameProxy( | 717 RenderFrameProxy::CreateFrameProxy( |
717 params.proxy_routing_id, GetRoutingID(), params.opener_frame_route_id, | 718 params.proxy_routing_id, GetRoutingID(), params.opener_frame_route_id, |
718 MSG_ROUTING_NONE, params.replicated_frame_state); | 719 MSG_ROUTING_NONE, params.replicated_frame_state); |
719 } | 720 } |
720 | 721 |
721 if (main_render_frame_) | 722 if (main_render_frame_) |
722 main_render_frame_->Initialize(); | 723 main_render_frame_->Initialize(); |
723 | 724 |
724 #if defined(OS_ANDROID) | 725 #if defined(OS_ANDROID) |
725 content_detectors_.push_back(make_scoped_ptr(new AddressDetector())); | 726 content_detectors_.push_back(base::WrapUnique(new AddressDetector())); |
726 const std::string& contry_iso = | 727 const std::string& contry_iso = |
727 params.renderer_preferences.network_contry_iso; | 728 params.renderer_preferences.network_contry_iso; |
728 if (!contry_iso.empty()) { | 729 if (!contry_iso.empty()) { |
729 content_detectors_.push_back( | 730 content_detectors_.push_back( |
730 make_scoped_ptr(new PhoneNumberDetector(contry_iso))); | 731 base::WrapUnique(new PhoneNumberDetector(contry_iso))); |
731 } | 732 } |
732 content_detectors_.push_back(make_scoped_ptr(new EmailDetector())); | 733 content_detectors_.push_back(base::WrapUnique(new EmailDetector())); |
733 #endif | 734 #endif |
734 | 735 |
735 RenderThread::Get()->AddRoute(GetRoutingID(), this); | 736 RenderThread::Get()->AddRoute(GetRoutingID(), this); |
736 // Take a reference on behalf of the RenderThread. This will be balanced | 737 // Take a reference on behalf of the RenderThread. This will be balanced |
737 // when we receive ViewMsg_Close in the RenderWidget (which RenderView | 738 // when we receive ViewMsg_Close in the RenderWidget (which RenderView |
738 // inherits from). | 739 // inherits from). |
739 AddRef(); | 740 AddRef(); |
740 if (RenderThreadImpl::current()) { | 741 if (RenderThreadImpl::current()) { |
741 RenderThreadImpl::current()->WidgetCreated(); | 742 RenderThreadImpl::current()->WidgetCreated(); |
742 if (is_hidden_) | 743 if (is_hidden_) |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 ApplyWebPreferences(prefs, web_view); | 1486 ApplyWebPreferences(prefs, web_view); |
1486 } | 1487 } |
1487 | 1488 |
1488 void RenderViewImpl::OnForceRedraw(int id) { | 1489 void RenderViewImpl::OnForceRedraw(int id) { |
1489 ui::LatencyInfo latency_info; | 1490 ui::LatencyInfo latency_info; |
1490 if (id) { | 1491 if (id) { |
1491 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 1492 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
1492 0, | 1493 0, |
1493 id); | 1494 id); |
1494 } | 1495 } |
1495 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; | 1496 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
1496 if (RenderWidgetCompositor* rwc = compositor()) { | 1497 if (RenderWidgetCompositor* rwc = compositor()) { |
1497 latency_info_swap_promise_monitor = | 1498 latency_info_swap_promise_monitor = |
1498 rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info); | 1499 rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info); |
1499 } | 1500 } |
1500 ScheduleCompositeWithForcedRedraw(); | 1501 ScheduleCompositeWithForcedRedraw(); |
1501 } | 1502 } |
1502 | 1503 |
1503 // blink::WebViewClient ------------------------------------------------------ | 1504 // blink::WebViewClient ------------------------------------------------------ |
1504 | 1505 |
1505 WebView* RenderViewImpl::createView(WebLocalFrame* creator, | 1506 WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2939 // programming error (there are many ways to DoS the user so it's not | 2940 // programming error (there are many ways to DoS the user so it's not |
2940 // considered a "real" security check), either in JS requesting many file | 2941 // considered a "real" security check), either in JS requesting many file |
2941 // choosers to pop up, or in a plugin. | 2942 // choosers to pop up, or in a plugin. |
2942 // | 2943 // |
2943 // TODO(brettw) we might possibly want to require a user gesture to open | 2944 // TODO(brettw) we might possibly want to require a user gesture to open |
2944 // a file picker, which will address this issue in a better way. | 2945 // a file picker, which will address this issue in a better way. |
2945 return false; | 2946 return false; |
2946 } | 2947 } |
2947 | 2948 |
2948 file_chooser_completions_.push_back( | 2949 file_chooser_completions_.push_back( |
2949 make_scoped_ptr(new PendingFileChooser(params, completion))); | 2950 base::WrapUnique(new PendingFileChooser(params, completion))); |
2950 if (file_chooser_completions_.size() == 1) { | 2951 if (file_chooser_completions_.size() == 1) { |
2951 // Actually show the browse dialog when this is the first request. | 2952 // Actually show the browse dialog when this is the first request. |
2952 Send(new ViewHostMsg_RunFileChooser(GetRoutingID(), params)); | 2953 Send(new ViewHostMsg_RunFileChooser(GetRoutingID(), params)); |
2953 } | 2954 } |
2954 return true; | 2955 return true; |
2955 } | 2956 } |
2956 | 2957 |
2957 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { | 2958 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
2958 if (!speech_recognition_dispatcher_) | 2959 if (!speech_recognition_dispatcher_) |
2959 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); | 2960 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 bool handled = false; | 3142 bool handled = false; |
3142 switch (renderer_preferences_.tap_multiple_targets_strategy) { | 3143 switch (renderer_preferences_.tap_multiple_targets_strategy) { |
3143 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: | 3144 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
3144 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); | 3145 handled = webview()->zoomToMultipleTargetsRect(zoom_rect); |
3145 break; | 3146 break; |
3146 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { | 3147 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { |
3147 gfx::Size canvas_size = | 3148 gfx::Size canvas_size = |
3148 gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale); | 3149 gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale); |
3149 cc::SharedBitmapManager* manager = | 3150 cc::SharedBitmapManager* manager = |
3150 RenderThreadImpl::current()->shared_bitmap_manager(); | 3151 RenderThreadImpl::current()->shared_bitmap_manager(); |
3151 scoped_ptr<cc::SharedBitmap> shared_bitmap = | 3152 std::unique_ptr<cc::SharedBitmap> shared_bitmap = |
3152 manager->AllocateSharedBitmap(canvas_size); | 3153 manager->AllocateSharedBitmap(canvas_size); |
3153 CHECK(!!shared_bitmap); | 3154 CHECK(!!shared_bitmap); |
3154 { | 3155 { |
3155 SkBitmap bitmap; | 3156 SkBitmap bitmap; |
3156 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), | 3157 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), |
3157 canvas_size.height()); | 3158 canvas_size.height()); |
3158 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); | 3159 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); |
3159 SkCanvas canvas(bitmap); | 3160 SkCanvas canvas(bitmap); |
3160 | 3161 |
3161 // TODO(trchen): Cleanup the device scale factor mess. | 3162 // TODO(trchen): Cleanup the device scale factor mess. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3299 if (IsUseZoomForDSFEnabled()) { | 3300 if (IsUseZoomForDSFEnabled()) { |
3300 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3301 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3301 } else { | 3302 } else { |
3302 webview()->setDeviceScaleFactor(device_scale_factor_); | 3303 webview()->setDeviceScaleFactor(device_scale_factor_); |
3303 } | 3304 } |
3304 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3305 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3305 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3306 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3306 } | 3307 } |
3307 | 3308 |
3308 } // namespace content | 3309 } // namespace content |
OLD | NEW |