OLD | NEW |
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_list.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.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 "chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h" | |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 static const size_t kSuggestionsCount = 8; | 23 static const size_t kSuggestionsCount = 8; |
25 | 24 |
26 } // namespace | 25 } // namespace |
27 | 26 |
28 SuggestionsCombiner::SuggestionsCombiner( | 27 SuggestionsCombiner::SuggestionsCombiner( |
29 SuggestionsCombiner::Delegate* delegate, | 28 SuggestionsCombiner::Delegate* delegate, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 72 } |
74 | 73 |
75 void SuggestionsCombiner::SetSuggestionsCount(size_t suggestions_count) { | 74 void SuggestionsCombiner::SetSuggestionsCount(size_t suggestions_count) { |
76 suggestions_count_ = suggestions_count; | 75 suggestions_count_ = suggestions_count; |
77 } | 76 } |
78 | 77 |
79 // static | 78 // static |
80 SuggestionsCombiner* SuggestionsCombiner::Create( | 79 SuggestionsCombiner* SuggestionsCombiner::Create( |
81 SuggestionsCombiner::Delegate* delegate, Profile* profile) { | 80 SuggestionsCombiner::Delegate* delegate, Profile* profile) { |
82 SuggestionsCombiner* combiner = new SuggestionsCombiner(delegate, profile); | 81 SuggestionsCombiner* combiner = new SuggestionsCombiner(delegate, profile); |
83 combiner->AddSource(new SuggestionsSourceTopSites()); | |
84 | |
85 extensions::SuggestedLinksRegistry* registry = | 82 extensions::SuggestedLinksRegistry* registry = |
86 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile); | 83 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile); |
87 scoped_ptr<std::vector<std::string> > list = registry->GetExtensionIds(); | 84 scoped_ptr<std::vector<std::string> > list = registry->GetExtensionIds(); |
88 for (std::vector<std::string>::iterator it = list->begin(); | 85 for (std::vector<std::string>::iterator it = list->begin(); |
89 it != list->end(); ++it) { | 86 it != list->end(); ++it) { |
90 combiner->AddSource(new SuggestionsSourceDiscovery(*it)); | 87 combiner->AddSource(new SuggestionsSourceDiscovery(*it)); |
91 } | 88 } |
92 | 89 |
93 return combiner; | 90 return combiner; |
94 } | 91 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 continue; | 160 continue; |
164 | 161 |
165 for (int i = 0; i < browser->tab_count(); i++) { | 162 for (int i = 0; i < browser->tab_count(); i++) { |
166 const content::WebContents* tab = chrome::GetWebContentsAt(browser, i); | 163 const content::WebContents* tab = chrome::GetWebContentsAt(browser, i); |
167 if (tab->GetURL() == url) | 164 if (tab->GetURL() == url) |
168 return true; | 165 return true; |
169 } | 166 } |
170 } | 167 } |
171 return false; | 168 return false; |
172 } | 169 } |
OLD | NEW |