OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
8 // For GdkScreen | 8 // For GdkScreen |
9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
10 #endif // defined(OS_CHROMEOS) | 10 #endif // defined(OS_CHROMEOS) |
(...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 // Download the OpenSearch description document. If this is successful a | 2789 // Download the OpenSearch description document. If this is successful a |
2790 // new keyword will be created when done. | 2790 // new keyword will be created when done. |
2791 profile()->GetTemplateURLFetcher()->ScheduleDownload( | 2791 profile()->GetTemplateURLFetcher()->ScheduleDownload( |
2792 keyword, | 2792 keyword, |
2793 url, | 2793 url, |
2794 base_entry->favicon().url(), | 2794 base_entry->favicon().url(), |
2795 this, | 2795 this, |
2796 autodetected); | 2796 autodetected); |
2797 } | 2797 } |
2798 | 2798 |
2799 // Indicates if the two inputs have the same security origin. | |
2800 // |requested_origin| should only be a security origin (no path, etc.). | |
2801 // It is ok if |template_url| is NULL. | |
2802 static bool IsSameOrigin(const GURL& requested_origin, | |
2803 const TemplateURL* template_url) { | |
2804 DCHECK(requested_origin == requested_origin.GetOrigin()); | |
2805 return template_url && requested_origin == | |
2806 TemplateURLModel::GenerateSearchURL(template_url).GetOrigin(); | |
2807 } | |
2808 | |
2809 ViewHostMsg_GetSearchProviderInstallState_Params | |
2810 TabContents::GetSearchProviderInstallState(const GURL& requested_host) { | |
2811 // Get the last committed entry since that is the page executing the | |
2812 // javascript as opposed to a page being navigated to. We don't want | |
2813 // to trust the page to tell us the url to avoid using potentially | |
2814 // compromised information. | |
2815 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | |
2816 GURL page_origin = entry ? entry->virtual_url().GetOrigin() : GURL(); | |
2817 GURL requested_origin = requested_host.GetOrigin(); | |
2818 // Do the security check before any others to avoid information leaks. | |
2819 if (page_origin != requested_origin) | |
2820 return ViewHostMsg_GetSearchProviderInstallState_Params::Denied(); | |
2821 | |
2822 // In incognito mode, no search information is exposed. (This check must be | |
2823 // done after the security check or else a web site can detect that the | |
2824 // user is in incognito mode just by doing a cross origin request.) | |
2825 if (profile()->IsOffTheRecord()) | |
2826 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
2827 | |
2828 TemplateURLModel* url_model = profile()->GetTemplateURLModel(); | |
2829 if (!url_model) | |
2830 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
2831 if (!url_model->loaded()) | |
2832 url_model->Load(); | |
2833 | |
2834 // First check to see if the url is the default search provider. | |
2835 if (IsSameOrigin(requested_origin, url_model->GetDefaultSearchProvider())) { | |
2836 return ViewHostMsg_GetSearchProviderInstallState_Params:: | |
2837 InstalledAsDefault(); | |
2838 } | |
2839 | |
2840 // Is the url any search provider? | |
2841 std::vector<const TemplateURL*> urls = url_model->GetTemplateURLs(); | |
2842 for (std::vector<const TemplateURL*>::iterator i = urls.begin(); | |
2843 i != urls.end(); ++i) { | |
2844 const TemplateURL* template_url = (*i); | |
2845 if (IsSameOrigin(requested_origin, template_url)) { | |
2846 return ViewHostMsg_GetSearchProviderInstallState_Params:: | |
2847 InstallButNotDefault(); | |
2848 } | |
2849 } | |
2850 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
2851 } | |
2852 | |
2853 GURL TabContents::GetAlternateErrorPageURL() const { | 2799 GURL TabContents::GetAlternateErrorPageURL() const { |
2854 GURL url; | 2800 GURL url; |
2855 // Disable alternate error pages when in OffTheRecord/Incognito mode. | 2801 // Disable alternate error pages when in OffTheRecord/Incognito mode. |
2856 if (profile()->IsOffTheRecord()) | 2802 if (profile()->IsOffTheRecord()) |
2857 return url; | 2803 return url; |
2858 | 2804 |
2859 PrefService* prefs = profile()->GetPrefs(); | 2805 PrefService* prefs = profile()->GetPrefs(); |
2860 DCHECK(prefs); | 2806 DCHECK(prefs); |
2861 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { | 2807 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { |
2862 url = google_util::AppendGoogleLocaleParam( | 2808 url = google_util::AppendGoogleLocaleParam( |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | 3269 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); |
3324 } | 3270 } |
3325 | 3271 |
3326 Profile* TabContents::GetProfileForPasswordManager() { | 3272 Profile* TabContents::GetProfileForPasswordManager() { |
3327 return profile(); | 3273 return profile(); |
3328 } | 3274 } |
3329 | 3275 |
3330 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | 3276 bool TabContents::DidLastPageLoadEncounterSSLErrors() { |
3331 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | 3277 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); |
3332 } | 3278 } |
OLD | NEW |