Chromium Code Reviews| 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 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2704 // Download the OpenSearch description document. If this is successful a | 2704 // Download the OpenSearch description document. If this is successful a |
| 2705 // new keyword will be created when done. | 2705 // new keyword will be created when done. |
| 2706 profile()->GetTemplateURLFetcher()->ScheduleDownload( | 2706 profile()->GetTemplateURLFetcher()->ScheduleDownload( |
| 2707 keyword, | 2707 keyword, |
| 2708 url, | 2708 url, |
| 2709 base_entry->favicon().url(), | 2709 base_entry->favicon().url(), |
| 2710 this, | 2710 this, |
| 2711 autodetected); | 2711 autodetected); |
| 2712 } | 2712 } |
| 2713 | 2713 |
| 2714 // Indicates if the two inputs have the same security origin. | |
| 2715 // |requested_origin| should only be a security origin (no path, etc.). | |
| 2716 // It is ok if |template_url| is NULL. | |
| 2717 static bool IsSameOrigin(const GURL& requested_origin, | |
| 2718 const TemplateURL* template_url) { | |
| 2719 DCHECK(requested_origin == requested_origin.GetOrigin()); | |
| 2720 return template_url && requested_origin == | |
| 2721 TemplateURLModel::GenerateSearchURL(template_url).GetOrigin(); | |
| 2722 } | |
| 2723 | |
| 2724 ViewHostMsg_GetSearchProviderInstallState_Params | |
| 2725 TabContents::GetSearchProviderInstallState(const GURL& requested_host) { | |
| 2726 // Get the last committed entry since that is the page executing the | |
| 2727 // javascript as opposed to a page being navigated to. We don't want | |
| 2728 // to trust the page to tell us the url to avoid using potentially | |
| 2729 // compromised information. | |
| 2730 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | |
| 2731 GURL page_origin = entry ? entry->virtual_url().GetOrigin() : GURL::EmptyGURL( ); | |
|
sky
2010/07/15 23:24:49
> 80, also, use GURL() here instead of EmptyGURL()
| |
| 2732 GURL requested_origin = requested_host.GetOrigin(); | |
| 2733 // Do the security check before any others to avoid information leaks. | |
| 2734 if (page_origin != requested_origin) | |
| 2735 return ViewHostMsg_GetSearchProviderInstallState_Params::Denied(); | |
| 2736 | |
| 2737 // In incognito mode, no search information is exposed. (This check must be | |
| 2738 // done after the security check or else a web site can detect that the | |
| 2739 // user is in incognito mode just by doing a cross origin request.) | |
| 2740 if (profile()->IsOffTheRecord()) | |
| 2741 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
| 2742 | |
| 2743 | |
|
sky
2010/07/15 23:24:49
nit: nuke this line.
| |
| 2744 TemplateURLModel* url_model = profile()->GetTemplateURLModel(); | |
| 2745 if (!url_model) | |
| 2746 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
| 2747 if (!url_model->loaded()) | |
| 2748 url_model->Load(); | |
| 2749 | |
| 2750 // First check to see if the url is the default search provider. | |
| 2751 if (IsSameOrigin(requested_origin, url_model->GetDefaultSearchProvider())) | |
| 2752 return ViewHostMsg_GetSearchProviderInstallState_Params::InstalledAsDefault( ); | |
|
sky
2010/07/15 23:24:49
> 80
| |
| 2753 | |
| 2754 // Is the url any search provider? | |
| 2755 std::vector<const TemplateURL*> urls = url_model->GetTemplateURLs(); | |
| 2756 for (std::vector<const TemplateURL*>::iterator i = urls.begin(); | |
| 2757 i != urls.end(); ++i) { | |
| 2758 const TemplateURL* template_url = (*i); | |
| 2759 if (IsSameOrigin(requested_origin, template_url)) { | |
| 2760 return ViewHostMsg_GetSearchProviderInstallState_Params:: | |
| 2761 InstallButNotDefault(); | |
| 2762 } | |
| 2763 } | |
| 2764 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled(); | |
| 2765 } | |
| 2766 | |
| 2714 GURL TabContents::GetAlternateErrorPageURL() const { | 2767 GURL TabContents::GetAlternateErrorPageURL() const { |
| 2715 GURL url; | 2768 GURL url; |
| 2716 // Disable alternate error pages when in OffTheRecord/Incognito mode. | 2769 // Disable alternate error pages when in OffTheRecord/Incognito mode. |
| 2717 if (profile()->IsOffTheRecord()) | 2770 if (profile()->IsOffTheRecord()) |
| 2718 return url; | 2771 return url; |
| 2719 | 2772 |
| 2720 PrefService* prefs = profile()->GetPrefs(); | 2773 PrefService* prefs = profile()->GetPrefs(); |
| 2721 DCHECK(prefs); | 2774 DCHECK(prefs); |
| 2722 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { | 2775 if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { |
| 2723 url = google_util::AppendGoogleLocaleParam( | 2776 url = google_util::AppendGoogleLocaleParam( |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3157 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | 3210 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); |
| 3158 } | 3211 } |
| 3159 | 3212 |
| 3160 Profile* TabContents::GetProfileForPasswordManager() { | 3213 Profile* TabContents::GetProfileForPasswordManager() { |
| 3161 return profile(); | 3214 return profile(); |
| 3162 } | 3215 } |
| 3163 | 3216 |
| 3164 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | 3217 bool TabContents::DidLastPageLoadEncounterSSLErrors() { |
| 3165 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | 3218 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); |
| 3166 } | 3219 } |
| OLD | NEW |