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

Side by Side Diff: chrome/browser/ui/search/instant_page.cc

Issue 17114002: Field trial removing tiles from NTP if URL is already open - for 1993 clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Consolidated GetOpenURLs and addressed comments Created 7 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_page.h" 5 #include "chrome/browser/ui/search/instant_page.h"
6 6
7 #include "apps/app_launcher.h" 7 #include "apps/app_launcher.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/history/most_visited_tiles_experiment.h"
11 #include "chrome/browser/history/top_sites.h"
10 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search/instant_service.h" 13 #include "chrome/browser/search/instant_service.h"
12 #include "chrome/browser/search/instant_service_factory.h" 14 #include "chrome/browser/search/instant_service_factory.h"
13 #include "chrome/browser/search/search.h" 15 #include "chrome/browser/search/search.h"
16 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/search/instant_tab.h" 17 #include "chrome/browser/ui/search/instant_tab.h"
15 #include "chrome/browser/ui/search/search_model.h" 18 #include "chrome/browser/ui/search/search_model.h"
16 #include "chrome/browser/ui/search/search_tab_helper.h" 19 #include "chrome/browser/ui/search/search_tab_helper.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h"
17 #include "chrome/common/render_messages.h" 22 #include "chrome/common/render_messages.h"
18 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
19 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
21 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/frame_navigate_params.h" 30 #include "content/public/common/frame_navigate_params.h"
26 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (is_main_frame) 185 if (is_main_frame)
181 delegate_->InstantPageLoadFailed(contents()); 186 delegate_->InstantPageLoadFailed(contents());
182 } 187 }
183 188
184 void InstantPage::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { 189 void InstantPage::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) {
185 sender()->SendThemeBackgroundInfo(theme_info); 190 sender()->SendThemeBackgroundInfo(theme_info);
186 } 191 }
187 192
188 void InstantPage::MostVisitedItemsChanged( 193 void InstantPage::MostVisitedItemsChanged(
189 const std::vector<InstantMostVisitedItem>& items) { 194 const std::vector<InstantMostVisitedItem>& items) {
190 sender()->SendMostVisitedItems(items); 195 std::vector<InstantMostVisitedItem> items_copy(items);
196 MaybeRemoveMostVisitedItems(&items_copy);
197
198 sender()->SendMostVisitedItems(items_copy);
191 199
192 content::NotificationService::current()->Notify( 200 content::NotificationService::current()->Notify(
193 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, 201 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS,
194 content::Source<InstantPage>(this), 202 content::Source<InstantPage>(this),
195 content::NotificationService::NoDetails()); 203 content::NotificationService::NoDetails());
196 } 204 }
197 205
198 void InstantPage::ModelChanged(const SearchModel::State& old_state, 206 void InstantPage::ModelChanged(const SearchModel::State& old_state,
199 const SearchModel::State& new_state) { 207 const SearchModel::State& new_state) {
200 if (old_state.instant_support != new_state.instant_support) 208 if (old_state.instant_support != new_state.instant_support)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 delegate_->UndoAllMostVisitedDeletions(); 284 delegate_->UndoAllMostVisitedDeletions();
277 } 285 }
278 286
279 void InstantPage::ClearContents() { 287 void InstantPage::ClearContents() {
280 if (contents()) 288 if (contents())
281 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); 289 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this);
282 290
283 sender()->SetContents(NULL); 291 sender()->SetContents(NULL);
284 Observe(NULL); 292 Observe(NULL);
285 } 293 }
294
295 void InstantPage::MaybeRemoveMostVisitedItems(
296 std::vector<InstantMostVisitedItem>* items) {
297 // The code below uses APIs not available on Android and the experiment should
298 // not run there.
299 #if !defined(OS_ANDROID)
300 if (!history::MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled()) {
301 return;
302 }
Alexei Svitkine (slow) 2013/07/24 18:37:36 No need for {}'s.
annark1 2013/07/24 20:43:31 Done.
303
304 TabStripModel* tab_strip_model = chrome::FindBrowserWithProfile(
305 profile_,
306 chrome::GetActiveDesktop())->tab_strip_model();
307 history::TopSites* top_sites = profile_->GetTopSites();
Alexei Svitkine (slow) 2013/07/24 18:37:36 I still think this whole thing can be a shared fun
Alexei Svitkine (slow) 2013/07/24 19:17:12 Nevermind, I see it's calling subtly different met
annark1 2013/07/24 20:43:31 ok. On 2013/07/24 19:17:12, Alexei Svitkine wrote:
308 if (!tab_strip_model || !top_sites) {
309 NOTREACHED();
310 return;
311 }
312
313 std::set<std::string> open_urls;
314 chrome::GetOpenUrls(*tab_strip_model, *top_sites, &open_urls);
315 history::MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs(
316 open_urls, items);
317
318 #endif
319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698