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

Side by Side Diff: chrome/browser/devtools/browser_list_tabcontents_provider.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
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/devtools/browser_list_tabcontents_provider.h" 5 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/history/top_sites.h" 8 #include "chrome/browser/history/top_sites.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/browser_iterator.h"
13 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
16 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
19 #include "grit/devtools_discovery_page_resources.h" 20 #include "grit/devtools_discovery_page_resources.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 23
23 using content::DevToolsHttpHandlerDelegate; 24 using content::DevToolsHttpHandlerDelegate;
24 using content::RenderViewHost; 25 using content::RenderViewHost;
25 26
26 BrowserListTabContentsProvider::BrowserListTabContentsProvider( 27 BrowserListTabContentsProvider::BrowserListTabContentsProvider(
27 Profile* profile) 28 Profile* profile)
28 : profile_(profile) { 29 : profile_(profile) {
29 } 30 }
30 31
31 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { 32 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() {
32 } 33 }
33 34
34 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { 35 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() {
35 std::set<Profile*> profiles; 36 std::set<Profile*> profiles;
36 for (BrowserList::const_iterator it = BrowserList::begin(), 37 for (chrome::BrowserIterator it; !it.done(); it.Next())
37 end = BrowserList::end(); it != end; ++it) {
38 profiles.insert((*it)->profile()); 38 profiles.insert((*it)->profile());
39 } 39
40 for (std::set<Profile*>::iterator it = profiles.begin(); 40 for (std::set<Profile*>::iterator it = profiles.begin();
41 it != profiles.end(); ++it) { 41 it != profiles.end(); ++it) {
42 history::TopSites* ts = (*it)->GetTopSites(); 42 history::TopSites* ts = (*it)->GetTopSites();
43 if (ts) { 43 if (ts) {
44 // TopSites updates itself after a delay. Ask TopSites to update itself 44 // TopSites updates itself after a delay. Ask TopSites to update itself
45 // when we're about to show the remote debugging landing page. 45 // when we're about to show the remote debugging landing page.
46 ts->SyncWithHistory(); 46 ts->SyncWithHistory();
47 } 47 }
48 } 48 }
49 return ResourceBundle::GetSharedInstance().GetRawDataResource( 49 return ResourceBundle::GetSharedInstance().GetRawDataResource(
50 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); 50 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string();
51 } 51 }
52 52
53 bool BrowserListTabContentsProvider::BundlesFrontendResources() { 53 bool BrowserListTabContentsProvider::BundlesFrontendResources() {
54 return true; 54 return true;
55 } 55 }
56 56
57 FilePath BrowserListTabContentsProvider::GetDebugFrontendDir() { 57 FilePath BrowserListTabContentsProvider::GetDebugFrontendDir() {
58 #if defined(DEBUG_DEVTOOLS) 58 #if defined(DEBUG_DEVTOOLS)
59 FilePath inspector_dir; 59 FilePath inspector_dir;
60 PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir); 60 PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir);
61 return inspector_dir; 61 return inspector_dir;
62 #else 62 #else
63 return FilePath(); 63 return FilePath();
64 #endif 64 #endif
65 } 65 }
66 66
67 std::string BrowserListTabContentsProvider::GetPageThumbnailData( 67 std::string BrowserListTabContentsProvider::GetPageThumbnailData(
68 const GURL& url) { 68 const GURL& url) {
69 for (BrowserList::const_iterator it = BrowserList::begin(), 69 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
70 end = BrowserList::end(); it != end; ++it) {
71 Profile* profile = (*it)->profile(); 70 Profile* profile = (*it)->profile();
72 history::TopSites* top_sites = profile->GetTopSites(); 71 history::TopSites* top_sites = profile->GetTopSites();
73 if (!top_sites) 72 if (!top_sites)
74 continue; 73 continue;
75 scoped_refptr<base::RefCountedMemory> data; 74 scoped_refptr<base::RefCountedMemory> data;
76 if (top_sites->GetPageThumbnail(url, &data)) 75 if (top_sites->GetPageThumbnail(url, &data))
77 return std::string( 76 return std::string(
78 reinterpret_cast<const char*>(data->front()), data->size()); 77 reinterpret_cast<const char*>(data->front()), data->size());
79 } 78 }
80 79
(...skipping 15 matching lines...) Expand all
96 } 95 }
97 96
98 content::DevToolsHttpHandlerDelegate::TargetType 97 content::DevToolsHttpHandlerDelegate::TargetType
99 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { 98 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) {
100 for (TabContentsIterator it; !it.done(); it.Next()) 99 for (TabContentsIterator it; !it.done(); it.Next())
101 if (rvh == it->GetRenderViewHost()) 100 if (rvh == it->GetRenderViewHost())
102 return kTargetTypeTab; 101 return kTargetTypeTab;
103 102
104 return kTargetTypeOther; 103 return kTargetTypeOther;
105 } 104 }
OLDNEW
« no previous file with comments | « chrome/browser/custom_home_pages_table_model.cc ('k') | chrome/browser/extensions/api/cookies/cookies_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698