Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/alternate_nav_url_fetcher.cc

Issue 545012: Merge the intranet redirect blacklist to 249. Contains the following two cha... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/alternate_nav_url_fetcher.h" 5 #include "chrome/browser/alternate_nav_url_fetcher.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/tab_contents/navigation_controller.h" 10 #include "chrome/browser/tab_contents/navigation_controller.h"
11 #include "chrome/browser/tab_contents/navigation_entry.h" 11 #include "chrome/browser/tab_contents/navigation_entry.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
16 #include "net/base/registry_controlled_domain.h"
16 17
17 AlternateNavURLFetcher::AlternateNavURLFetcher( 18 AlternateNavURLFetcher::AlternateNavURLFetcher(
18 const GURL& alternate_nav_url) 19 const GURL& alternate_nav_url)
19 : LinkInfoBarDelegate(NULL), 20 : LinkInfoBarDelegate(NULL),
20 alternate_nav_url_(alternate_nav_url), 21 alternate_nav_url_(alternate_nav_url),
21 controller_(NULL), 22 controller_(NULL),
22 state_(NOT_STARTED), 23 state_(NOT_STARTED),
23 navigated_to_entry_(false), 24 navigated_to_entry_(false),
24 infobar_contents_(NULL) { 25 infobar_contents_(NULL) {
25 registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING, 26 registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const URLRequestStatus& status, 79 const URLRequestStatus& status,
79 int response_code, 80 int response_code,
80 const ResponseCookies& cookies, 81 const ResponseCookies& cookies,
81 const std::string& data) { 82 const std::string& data) {
82 DCHECK(fetcher_.get() == source); 83 DCHECK(fetcher_.get() == source);
83 if (status.is_success() && 84 if (status.is_success() &&
84 // HTTP 2xx, 401, and 407 all indicate that the target address exists. 85 // HTTP 2xx, 401, and 407 all indicate that the target address exists.
85 (((response_code / 100) == 2) || 86 (((response_code / 100) == 2) ||
86 (response_code == 401) || (response_code == 407))) { 87 (response_code == 401) || (response_code == 407))) {
87 state_ = SUCCEEDED; 88 state_ = SUCCEEDED;
89
90 // The following TLD+1s are used as destinations by ISPs/DNS providers/etc.
91 // who return provider-controlled pages to arbitrary user navigation
92 // attempts. Because this can result in infobars on large fractions of user
93 // searches, we don't show automatic infobars for these. Note that users
94 // can still choose to explicitly navigate to or search for pages in these
95 // domains, and can still get infobars for cases that wind up on other
96 // domains (e.g. legit intranet sites), we're just trying to avoid
97 // erroneously harassing the user with our own UI prompts.
98 const char* kBlacklistedSites[] = {
99 // NOTE: Use complete URLs, because GURL() doesn't do fixup!
100 "http://comcast.com/",
101 "http://opendns.com/",
102 "http://verizon.net/",
103 };
104 for (size_t i = 0; i < arraysize(kBlacklistedSites); ++i) {
105 if (net::RegistryControlledDomainService::SameDomainOrHost(
106 url, GURL(kBlacklistedSites[i]))) {
107 state_ = FAILED;
108 break;
109 }
110 }
88 } else { 111 } else {
89 state_ = FAILED; 112 state_ = FAILED;
90 } 113 }
114
91 ShowInfobarIfPossible(); 115 ShowInfobarIfPossible();
92 } 116 }
93 117
94 std::wstring AlternateNavURLFetcher::GetMessageTextWithOffset( 118 std::wstring AlternateNavURLFetcher::GetMessageTextWithOffset(
95 size_t* link_offset) const { 119 size_t* link_offset) const {
96 const std::wstring label = l10n_util::GetStringF( 120 const std::wstring label = l10n_util::GetStringF(
97 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, std::wstring(), link_offset); 121 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, std::wstring(), link_offset);
98 DCHECK(*link_offset != std::wstring::npos); 122 DCHECK(*link_offset != std::wstring::npos);
99 return label; 123 return label;
100 } 124 }
(...skipping 29 matching lines...) Expand all
130 if (state_ == FAILED) 154 if (state_ == FAILED)
131 delete this; 155 delete this;
132 return; 156 return;
133 } 157 }
134 158
135 infobar_contents_ = controller_->tab_contents(); 159 infobar_contents_ = controller_->tab_contents();
136 StoreActiveEntryUniqueID(infobar_contents_); 160 StoreActiveEntryUniqueID(infobar_contents_);
137 // We will be deleted when the InfoBar is destroyed. (See InfoBarClosed). 161 // We will be deleted when the InfoBar is destroyed. (See InfoBarClosed).
138 infobar_contents_->AddInfoBar(this); 162 infobar_contents_->AddInfoBar(this);
139 } 163 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698