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/browser/ui/tab_contents/tab_contents_wrapper.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 48 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
49 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 49 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
51 #include "chrome/common/chrome_notification_types.h" | 51 #include "chrome/common/chrome_notification_types.h" |
52 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
53 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
54 #include "chrome/common/render_messages.h" | 54 #include "chrome/common/render_messages.h" |
55 #include "content/browser/renderer_host/render_view_host.h" | 55 #include "content/browser/renderer_host/render_view_host.h" |
56 #include "content/browser/tab_contents/tab_contents_view.h" | 56 #include "content/browser/tab_contents/tab_contents_view.h" |
57 #include "content/common/notification_service.h" | 57 #include "content/common/notification_service.h" |
58 #include "content/common/view_messages.h" | |
59 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
60 #include "grit/locale_settings.h" | 59 #include "grit/locale_settings.h" |
61 #include "grit/platform_locale_settings.h" | 60 #include "grit/platform_locale_settings.h" |
62 #include "ui/base/l10n/l10n_util.h" | 61 #include "ui/base/l10n/l10n_util.h" |
63 #include "webkit/glue/webpreferences.h" | 62 #include "webkit/glue/webpreferences.h" |
64 | 63 |
65 namespace { | 64 namespace { |
66 | 65 |
67 static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > | 66 static base::LazyInstance<PropertyAccessor<TabContentsWrapper*> > |
68 g_tab_contents_wrapper_property_accessor(base::LINKER_INITIALIZED); | 67 g_tab_contents_wrapper_property_accessor(base::LINKER_INITIALIZED); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 #endif | 596 #endif |
598 case chrome::NOTIFICATION_PREF_CHANGED: { | 597 case chrome::NOTIFICATION_PREF_CHANGED: { |
599 std::string* pref_name_in = Details<std::string>(details).ptr(); | 598 std::string* pref_name_in = Details<std::string>(details).ptr(); |
600 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); | 599 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); |
601 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { | 600 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { |
602 UpdateAlternateErrorPageURL(render_view_host()); | 601 UpdateAlternateErrorPageURL(render_view_host()); |
603 } else if ((*pref_name_in == prefs::kDefaultCharset) || | 602 } else if ((*pref_name_in == prefs::kDefaultCharset) || |
604 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { | 603 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { |
605 UpdateWebPreferences(); | 604 UpdateWebPreferences(); |
606 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { | 605 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { |
607 Send(new ViewMsg_SetZoomLevel( | 606 tab_contents()->render_view_host()->SetZoomLevel( |
608 routing_id(), tab_contents()->GetZoomLevel())); | 607 tab_contents()->GetZoomLevel()); |
609 } else if (*pref_name_in == prefs::kEnableReferrers) { | 608 } else if (*pref_name_in == prefs::kEnableReferrers) { |
610 UpdateRendererPreferences(); | 609 UpdateRendererPreferences(); |
611 } else if (*pref_name_in == prefs::kSafeBrowsingEnabled) { | 610 } else if (*pref_name_in == prefs::kSafeBrowsingEnabled) { |
612 UpdateSafebrowsingDetectionHost(); | 611 UpdateSafebrowsingDetectionHost(); |
613 } else { | 612 } else { |
614 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; | 613 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; |
615 } | 614 } |
616 break; | 615 break; |
617 } | 616 } |
618 default: | 617 default: |
(...skipping 24 matching lines...) Expand all Loading... |
643 PrefService* prefs = profile()->GetPrefs(); | 642 PrefService* prefs = profile()->GetPrefs(); |
644 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { | 643 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { |
645 url = google_util::AppendGoogleLocaleParam( | 644 url = google_util::AppendGoogleLocaleParam( |
646 GURL(google_util::kLinkDoctorBaseURL)); | 645 GURL(google_util::kLinkDoctorBaseURL)); |
647 url = google_util::AppendGoogleTLDParam(url); | 646 url = google_util::AppendGoogleTLDParam(url); |
648 } | 647 } |
649 return url; | 648 return url; |
650 } | 649 } |
651 | 650 |
652 void TabContentsWrapper::UpdateAlternateErrorPageURL(RenderViewHost* rvh) { | 651 void TabContentsWrapper::UpdateAlternateErrorPageURL(RenderViewHost* rvh) { |
653 rvh->Send(new ViewMsg_SetAltErrorPageURL( | 652 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); |
654 rvh->routing_id(), GetAlternateErrorPageURL())); | |
655 } | 653 } |
656 | 654 |
657 void TabContentsWrapper::UpdateWebPreferences() { | 655 void TabContentsWrapper::UpdateWebPreferences() { |
658 RenderViewHostDelegate* rvhd = tab_contents(); | 656 RenderViewHostDelegate* rvhd = tab_contents(); |
659 Send(new ViewMsg_UpdateWebPreferences(routing_id(), rvhd->GetWebkitPrefs())); | 657 tab_contents()->render_view_host()->UpdateWebkitPreferences( |
| 658 rvhd->GetWebkitPrefs()); |
660 } | 659 } |
661 | 660 |
662 void TabContentsWrapper::UpdateRendererPreferences() { | 661 void TabContentsWrapper::UpdateRendererPreferences() { |
663 renderer_preferences_util::UpdateFromSystemSettings( | 662 renderer_preferences_util::UpdateFromSystemSettings( |
664 tab_contents()->GetMutableRendererPrefs(), profile()); | 663 tab_contents()->GetMutableRendererPrefs(), profile()); |
665 render_view_host()->SyncRendererPrefs(); | 664 render_view_host()->SyncRendererPrefs(); |
666 } | 665 } |
667 | 666 |
668 void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { | 667 void TabContentsWrapper::UpdateSafebrowsingDetectionHost() { |
669 #if defined(ENABLE_SAFE_BROWSING) | 668 #if defined(ENABLE_SAFE_BROWSING) |
670 PrefService* prefs = profile()->GetPrefs(); | 669 PrefService* prefs = profile()->GetPrefs(); |
671 bool safe_browsing = prefs->GetBoolean(prefs::kSafeBrowsingEnabled); | 670 bool safe_browsing = prefs->GetBoolean(prefs::kSafeBrowsingEnabled); |
672 if (safe_browsing && | 671 if (safe_browsing && |
673 g_browser_process->safe_browsing_detection_service()) { | 672 g_browser_process->safe_browsing_detection_service()) { |
674 if (!safebrowsing_detection_host_.get()) { | 673 if (!safebrowsing_detection_host_.get()) { |
675 safebrowsing_detection_host_.reset( | 674 safebrowsing_detection_host_.reset( |
676 safe_browsing::ClientSideDetectionHost::Create(tab_contents())); | 675 safe_browsing::ClientSideDetectionHost::Create(tab_contents())); |
677 } | 676 } |
678 } else { | 677 } else { |
679 safebrowsing_detection_host_.reset(); | 678 safebrowsing_detection_host_.reset(); |
680 } | 679 } |
681 render_view_host()->Send( | 680 render_view_host()->Send( |
682 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(), | 681 new ChromeViewMsg_SetClientSidePhishingDetection(routing_id(), |
683 safe_browsing)); | 682 safe_browsing)); |
684 #endif | 683 #endif |
685 } | 684 } |
686 | 685 |
687 void TabContentsWrapper::ExitFullscreenMode() { | 686 void TabContentsWrapper::ExitFullscreenMode() { |
688 Send(new ViewMsg_ExitFullscreen(routing_id())); | 687 tab_contents()->render_view_host()->ExitFullscreen(); |
689 } | 688 } |
OLD | NEW |