// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" #include "base/path_service.h" #include "chrome/browser/history/top_sites_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" #include "chrome/common/chrome_paths.h" #include "components/history/core/browser/top_sites.h" #include "grit/browser_resources.h" #include "ui/base/resource/resource_bundle.h" BrowserListTabContentsProvider::BrowserListTabContentsProvider( chrome::HostDesktopType host_desktop_type) : host_desktop_type_(host_desktop_type) { } BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { } std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { std::set profiles; for (chrome::BrowserIterator it; !it.done(); it.Next()) profiles.insert((*it)->profile()); for (std::set::iterator it = profiles.begin(); it != profiles.end(); ++it) { scoped_refptr ts = TopSitesFactory::GetForProfile(*it); if (ts) { // TopSites updates itself after a delay. Ask TopSites to update itself // when we're about to show the remote debugging landing page. ts->SyncWithHistory(); } } return ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); } bool BrowserListTabContentsProvider::BundlesFrontendResources() { return true; } base::FilePath BrowserListTabContentsProvider::GetDebugFrontendDir() { #if defined(DEBUG_DEVTOOLS) base::FilePath inspector_dir; PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir); return inspector_dir; #else return base::FilePath(); #endif }