| 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 "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 5 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| 9 #include "android_webview/common/aw_switches.h" | 9 #include "android_webview/common/aw_switches.h" |
| 10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "content/public/browser/android/content_view_core.h" | 15 #include "content/public/browser/android/content_view_core.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
| 21 | 21 |
| 22 namespace android_webview { | 22 namespace android_webview { |
| 23 | 23 |
| 24 AwRenderViewHostExt::AwRenderViewHostExt( | 24 AwRenderViewHostExt::AwRenderViewHostExt( |
| 25 AwRenderViewHostExtClient* client, content::WebContents* contents) | 25 AwRenderViewHostExtClient* client, content::WebContents* contents) |
| 26 : content::WebContentsObserver(contents), | 26 : content::WebContentsObserver(contents), |
| 27 client_(client), | 27 client_(client), |
| 28 background_color_(SK_ColorWHITE), |
| 28 has_new_hit_test_data_(false) { | 29 has_new_hit_test_data_(false) { |
| 29 DCHECK(client_); | 30 DCHECK(client_); |
| 30 } | 31 } |
| 31 | 32 |
| 32 AwRenderViewHostExt::~AwRenderViewHostExt() {} | 33 AwRenderViewHostExt::~AwRenderViewHostExt() {} |
| 33 | 34 |
| 34 void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) { | 35 void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) { |
| 35 DCHECK(CalledOnValidThread()); | 36 DCHECK(CalledOnValidThread()); |
| 36 if (!web_contents()->GetRenderViewHost()) { | 37 if (!web_contents()->GetRenderViewHost()) { |
| 37 result.Run(false); | 38 result.Run(false); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 DCHECK(CalledOnValidThread()); | 79 DCHECK(CalledOnValidThread()); |
| 79 Send(new AwViewMsg_ResetScrollAndScaleState(web_contents()->GetRoutingID())); | 80 Send(new AwViewMsg_ResetScrollAndScaleState(web_contents()->GetRoutingID())); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void AwRenderViewHostExt::SetInitialPageScale(double page_scale_factor) { | 83 void AwRenderViewHostExt::SetInitialPageScale(double page_scale_factor) { |
| 83 DCHECK(CalledOnValidThread()); | 84 DCHECK(CalledOnValidThread()); |
| 84 Send(new AwViewMsg_SetInitialPageScale(web_contents()->GetRoutingID(), | 85 Send(new AwViewMsg_SetInitialPageScale(web_contents()->GetRoutingID(), |
| 85 page_scale_factor)); | 86 page_scale_factor)); |
| 86 } | 87 } |
| 87 | 88 |
| 89 void AwRenderViewHostExt::SetBackgroundColor(SkColor c) { |
| 90 if (background_color_ == c) |
| 91 return; |
| 92 background_color_ = c; |
| 93 if (web_contents()->GetRenderViewHost()) { |
| 94 Send(new AwViewMsg_SetBackgroundColor(web_contents()->GetRoutingID(), |
| 95 background_color_)); |
| 96 } |
| 97 } |
| 98 |
| 99 void AwRenderViewHostExt::RenderViewCreated( |
| 100 content::RenderViewHost* render_view_host) { |
| 101 Send(new AwViewMsg_SetBackgroundColor(web_contents()->GetRoutingID(), |
| 102 background_color_)); |
| 103 } |
| 104 |
| 88 void AwRenderViewHostExt::RenderProcessGone(base::TerminationStatus status) { | 105 void AwRenderViewHostExt::RenderProcessGone(base::TerminationStatus status) { |
| 89 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
| 90 for (std::map<int, DocumentHasImagesResult>::iterator pending_req = | 107 for (std::map<int, DocumentHasImagesResult>::iterator pending_req = |
| 91 pending_document_has_images_requests_.begin(); | 108 pending_document_has_images_requests_.begin(); |
| 92 pending_req != pending_document_has_images_requests_.end(); | 109 pending_req != pending_document_has_images_requests_.end(); |
| 93 ++pending_req) { | 110 ++pending_req) { |
| 94 pending_req->second.Run(false); | 111 pending_req->second.Run(false); |
| 95 } | 112 } |
| 96 } | 113 } |
| 97 | 114 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 DCHECK(CalledOnValidThread()); | 154 DCHECK(CalledOnValidThread()); |
| 138 last_hit_test_data_ = hit_test_data; | 155 last_hit_test_data_ = hit_test_data; |
| 139 has_new_hit_test_data_ = true; | 156 has_new_hit_test_data_ = true; |
| 140 } | 157 } |
| 141 | 158 |
| 142 void AwRenderViewHostExt::OnPageScaleFactorChanged(float page_scale_factor) { | 159 void AwRenderViewHostExt::OnPageScaleFactorChanged(float page_scale_factor) { |
| 143 client_->OnWebLayoutPageScaleFactorChanged(page_scale_factor); | 160 client_->OnWebLayoutPageScaleFactorChanged(page_scale_factor); |
| 144 } | 161 } |
| 145 | 162 |
| 146 } // namespace android_webview | 163 } // namespace android_webview |
| OLD | NEW |