Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 void InstantController::UndoAllMostVisitedDeletions() { | 1069 void InstantController::UndoAllMostVisitedDeletions() { |
| 1070 history::TopSites* top_sites = browser_->profile()->GetTopSites(); | 1070 history::TopSites* top_sites = browser_->profile()->GetTopSites(); |
| 1071 if (!top_sites) | 1071 if (!top_sites) |
| 1072 return; | 1072 return; |
| 1073 | 1073 |
| 1074 top_sites->ClearBlacklistedURLs(); | 1074 top_sites->ClearBlacklistedURLs(); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 void InstantController::InstantPageLoadFailed(content::WebContents* contents) { | |
|
samarth
2013/05/01 06:26:47
Please keep the functions in the same order as in
David Black
2013/05/02 00:49:45
Done.
| |
| 1078 GURL local_fallback_url = chrome::GetLocalInstantURL(browser_->profile()); | |
| 1079 | |
| 1080 if (instant_tab_ && IsContentsFrom(instant_tab(), contents)) { | |
| 1081 if (instant_tab_->IsLocal()) | |
| 1082 return; | |
| 1083 SearchTabHelper::FromWebContents(contents)->RedirectingToLocal(); | |
|
samarth
2013/05/01 06:26:47
It't not clear to me why this is necessary. Do yo
David Black
2013/05/02 00:49:45
Fixed as we discussed in person.
| |
| 1084 RedirectToLocalNTP(contents); | |
|
samarth
2013/05/01 06:26:47
I can try this tomorrow but what if you have a sea
David Black
2013/05/02 00:49:45
Good point. Changed to fall back only if the URL
| |
| 1085 } | |
| 1086 | |
| 1087 if (ntp_ && IsContentsFrom(ntp(), contents)) { | |
| 1088 if (ntp_->IsLocal()) | |
| 1089 return; | |
| 1090 ResetNTP(false, true); | |
|
samarth
2013/05/01 06:26:47
No, this will lead to an infinite loop of reloadin
David Black
2013/05/02 00:49:45
Will not cause an infinite loop - second param is
| |
| 1091 } | |
| 1092 | |
| 1093 if (overlay_ && IsContentsFrom(overlay(), contents)) { | |
| 1094 if (overlay_->IsLocal()) | |
| 1095 return; | |
| 1096 CreateOverlay(local_fallback_url.spec(), contents); | |
|
samarth
2013/05/01 06:26:47
Update already handles the fallback, so you just n
David Black
2013/05/02 00:49:45
Update is too late - they've already typed a chara
| |
| 1097 } | |
| 1098 } | |
| 1099 | |
| 1077 void InstantController::Observe(int type, | 1100 void InstantController::Observe(int type, |
| 1078 const content::NotificationSource& source, | 1101 const content::NotificationSource& source, |
| 1079 const content::NotificationDetails& details) { | 1102 const content::NotificationDetails& details) { |
| 1080 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED); | 1103 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED); |
| 1081 RequestMostVisitedItems(); | 1104 RequestMostVisitedItems(); |
| 1082 } | 1105 } |
| 1083 | 1106 |
| 1084 // TODO(shishir): We assume that the WebContent's current RenderViewHost is the | 1107 // TODO(shishir): We assume that the WebContent's current RenderViewHost is the |
| 1085 // RenderViewHost being created which is not always true. Fix this. | 1108 // RenderViewHost being created which is not always true. Fix this. |
| 1086 void InstantController::InstantPageRenderViewCreated( | 1109 void InstantController::InstantPageRenderViewCreated( |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1712 if (browser_->GetActiveWebContents()) | 1735 if (browser_->GetActiveWebContents()) |
| 1713 return true; | 1736 return true; |
| 1714 | 1737 |
| 1715 return chrome::IsAggressiveLocalNTPFallbackEnabled(); | 1738 return chrome::IsAggressiveLocalNTPFallbackEnabled(); |
| 1716 } | 1739 } |
| 1717 | 1740 |
| 1718 bool InstantController::UsingLocalPage() const { | 1741 bool InstantController::UsingLocalPage() const { |
| 1719 return (instant_tab_ && instant_tab_->IsLocal()) || | 1742 return (instant_tab_ && instant_tab_->IsLocal()) || |
| 1720 (!instant_tab_ && overlay_ && overlay_->IsLocal()); | 1743 (!instant_tab_ && overlay_ && overlay_->IsLocal()); |
| 1721 } | 1744 } |
| 1745 | |
| 1746 void InstantController::RedirectToLocalNTP(content::WebContents* contents) { | |
| 1747 contents->GetController().LoadURL( | |
| 1748 chrome::GetLocalInstantURL(browser_->profile()), | |
| 1749 content::Referrer(), | |
| 1750 content::PAGE_TRANSITION_SERVER_REDIRECT, | |
| 1751 std::string()); // No extra headers. | |
| 1752 // TODO(dcblack): Remove extraneous history entry. | |
| 1753 } | |
| OLD | NEW |