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

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_combiner.cc

Issue 12114034: Swap BrowserList::const_iterator for the multi-desktop aware BrowserIterator in many scenarios. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « chrome/browser/ui/uma_browsing_activity_observer.cc ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/webui/ntp/suggestions_combiner.h" 5 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/api/discovery/suggested_links_registry.h" 10 #include "chrome/browser/extensions/api/discovery/suggested_links_registry.h"
11 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h" 11 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_iterator.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" 16 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h"
17 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" 17 #include "chrome/browser/ui/webui/ntp/suggestions_source.h"
18 #include "chrome/browser/ui/webui/ntp/suggestions_source_discovery.h" 18 #include "chrome/browser/ui/webui/ntp/suggestions_source_discovery.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 namespace { 21 namespace {
22 22
23 static const size_t kSuggestionsCount = 8; 23 static const size_t kSuggestionsCount = 8;
24 24
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (debug_enabled_) { 145 if (debug_enabled_) {
146 std::string url_string; 146 std::string url_string;
147 if (page_value->GetString("url", &url_string)) { 147 if (page_value->GetString("url", &url_string)) {
148 GURL url(url_string); 148 GURL url(url_string);
149 page_value->SetBoolean("already_open", IsUrlAlreadyOpen(url)); 149 page_value->SetBoolean("already_open", IsUrlAlreadyOpen(url));
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 bool SuggestionsCombiner::IsUrlAlreadyOpen(const GURL &url) { 154 bool SuggestionsCombiner::IsUrlAlreadyOpen(const GURL &url) {
155 for (BrowserList::const_iterator it = BrowserList::begin(); 155 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
156 it != BrowserList::end(); ++it) {
157 const Browser* browser = *it; 156 const Browser* browser = *it;
158 if (browser->profile()->IsOffTheRecord() || 157 if (browser->profile()->IsOffTheRecord() ||
159 !browser->profile()->IsSameProfile(profile_)) 158 !browser->profile()->IsSameProfile(profile_))
160 continue; 159 continue;
161 160
162 for (int i = 0; i < browser->tab_strip_model()->count(); i++) { 161 for (int i = 0; i < browser->tab_strip_model()->count(); i++) {
163 const content::WebContents* tab = 162 const content::WebContents* tab =
164 browser->tab_strip_model()->GetWebContentsAt(i); 163 browser->tab_strip_model()->GetWebContentsAt(i);
165 if (tab->GetURL() == url) 164 if (tab->GetURL() == url)
166 return true; 165 return true;
167 } 166 }
168 } 167 }
169 return false; 168 return false;
170 } 169 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/uma_browsing_activity_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698