OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/chrome_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback_old.h" |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 13 #include "base/string_util.h" |
12 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/icon_messages.h" | 16 #include "chrome/common/icon_messages.h" |
15 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
16 #include "chrome/common/thumbnail_score.h" | 18 #include "chrome/common/thumbnail_score.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 TranslateHelper* translate_helper) | 221 TranslateHelper* translate_helper) |
220 : content::RenderViewObserver(render_view), | 222 : content::RenderViewObserver(render_view), |
221 chrome_render_process_observer_(chrome_render_process_observer), | 223 chrome_render_process_observer_(chrome_render_process_observer), |
222 extension_dispatcher_(extension_dispatcher), | 224 extension_dispatcher_(extension_dispatcher), |
223 content_settings_(content_settings), | 225 content_settings_(content_settings), |
224 translate_helper_(translate_helper), | 226 translate_helper_(translate_helper), |
225 phishing_classifier_(NULL), | 227 phishing_classifier_(NULL), |
226 last_indexed_page_id_(-1), | 228 last_indexed_page_id_(-1), |
227 allow_displaying_insecure_content_(false), | 229 allow_displaying_insecure_content_(false), |
228 allow_running_insecure_content_(false), | 230 allow_running_insecure_content_(false), |
229 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)) { | 231 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
230 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 232 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
231 if (command_line.HasSwitch(switches::kDomAutomationController)) { | 233 if (command_line.HasSwitch(switches::kDomAutomationController)) { |
232 int old_bindings = render_view->GetEnabledBindings(); | 234 int old_bindings = render_view->GetEnabledBindings(); |
233 render_view->SetEnabledBindings( | 235 render_view->SetEnabledBindings( |
234 old_bindings |= content::BINDINGS_POLICY_DOM_AUTOMATION); | 236 old_bindings |= content::BINDINGS_POLICY_DOM_AUTOMATION); |
235 } | 237 } |
236 render_view->GetWebView()->setPermissionClient(this); | 238 render_view->GetWebView()->setPermissionClient(this); |
237 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection)) | 239 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection)) |
238 OnSetClientSidePhishingDetection(true); | 240 OnSetClientSidePhishingDetection(true); |
239 } | 241 } |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 render_view()->EvaluateScript(webui_javascript_->frame_xpath, | 615 render_view()->EvaluateScript(webui_javascript_->frame_xpath, |
614 webui_javascript_->jscript, | 616 webui_javascript_->jscript, |
615 webui_javascript_->id, | 617 webui_javascript_->id, |
616 webui_javascript_->notify_result); | 618 webui_javascript_->notify_result); |
617 } | 619 } |
618 } | 620 } |
619 | 621 |
620 void ChromeRenderViewObserver::DidStopLoading() { | 622 void ChromeRenderViewObserver::DidStopLoading() { |
621 MessageLoop::current()->PostDelayedTask( | 623 MessageLoop::current()->PostDelayedTask( |
622 FROM_HERE, | 624 FROM_HERE, |
623 page_info_method_factory_.NewRunnableMethod( | 625 base::Bind(&ChromeRenderViewObserver::CapturePageInfo, |
624 &ChromeRenderViewObserver::CapturePageInfo, | 626 weak_factory_.GetWeakPtr(), render_view()->GetPageId(), false), |
625 render_view()->GetPageId(), | |
626 false), | |
627 render_view()->GetContentStateImmediately() ? 0 : kDelayForCaptureMs); | 627 render_view()->GetContentStateImmediately() ? 0 : kDelayForCaptureMs); |
628 | 628 |
629 WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); | 629 WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); |
630 GURL osd_url = main_frame->document().openSearchDescriptionURL(); | 630 GURL osd_url = main_frame->document().openSearchDescriptionURL(); |
631 if (!osd_url.is_empty()) { | 631 if (!osd_url.is_empty()) { |
632 Send(new ChromeViewHostMsg_PageHasOSDD( | 632 Send(new ChromeViewHostMsg_PageHasOSDD( |
633 routing_id(), render_view()->GetPageId(), osd_url, | 633 routing_id(), render_view()->GetPageId(), osd_url, |
634 search_provider::AUTODETECTED_PROVIDER)); | 634 search_provider::AUTODETECTED_PROVIDER)); |
635 } | 635 } |
636 | 636 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 routing_id(), render_view()->GetPageId(), urls)); | 671 routing_id(), render_view()->GetPageId(), urls)); |
672 } | 672 } |
673 | 673 |
674 void ChromeRenderViewObserver::DidCommitProvisionalLoad( | 674 void ChromeRenderViewObserver::DidCommitProvisionalLoad( |
675 WebFrame* frame, bool is_new_navigation) { | 675 WebFrame* frame, bool is_new_navigation) { |
676 if (!is_new_navigation) | 676 if (!is_new_navigation) |
677 return; | 677 return; |
678 | 678 |
679 MessageLoop::current()->PostDelayedTask( | 679 MessageLoop::current()->PostDelayedTask( |
680 FROM_HERE, | 680 FROM_HERE, |
681 page_info_method_factory_.NewRunnableMethod( | 681 base::Bind(&ChromeRenderViewObserver::CapturePageInfo, |
682 &ChromeRenderViewObserver::CapturePageInfo, | 682 weak_factory_.GetWeakPtr(), render_view()->GetPageId(), true), |
683 render_view()->GetPageId(), | |
684 true), | |
685 kDelayForForcedCaptureMs); | 683 kDelayForForcedCaptureMs); |
686 } | 684 } |
687 | 685 |
688 void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { | 686 void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { |
689 if (render_view()->GetEnabledBindings() & | 687 if (render_view()->GetEnabledBindings() & |
690 content::BINDINGS_POLICY_DOM_AUTOMATION) { | 688 content::BINDINGS_POLICY_DOM_AUTOMATION) { |
691 BindDOMAutomationController(frame); | 689 BindDOMAutomationController(frame); |
692 } | 690 } |
693 | 691 |
694 if (render_view()->GetEnabledBindings() & | 692 if (render_view()->GetEnabledBindings() & |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 reinterpret_cast<const unsigned char*>(&data[0]); | 1032 reinterpret_cast<const unsigned char*>(&data[0]); |
1035 | 1033 |
1036 return decoder.Decode(src_data, data.size()); | 1034 return decoder.Decode(src_data, data.size()); |
1037 } | 1035 } |
1038 return SkBitmap(); | 1036 return SkBitmap(); |
1039 } | 1037 } |
1040 | 1038 |
1041 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1039 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1042 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1040 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1043 } | 1041 } |
OLD | NEW |