| 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/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 "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/history/top_sites.h" | 12 #include "chrome/browser/history/top_sites.h" |
| 13 #include "chrome/browser/profiles/profile.h" | |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_iterator.h" | 16 #include "chrome/browser/ui/browser_iterator.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/host_desktop.h" | 19 #include "chrome/browser/ui/host_desktop.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 22 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 23 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 25 #include "grit/devtools_discovery_page_resources.h" | 24 #include "grit/devtools_discovery_page_resources.h" |
| 26 #include "net/socket/tcp_listen_socket.h" | 25 #include "net/socket/tcp_listen_socket.h" |
| 27 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 29 | 28 |
| 30 using content::DevToolsHttpHandlerDelegate; | 29 using content::DevToolsHttpHandlerDelegate; |
| 31 using content::RenderViewHost; | 30 using content::RenderViewHost; |
| 32 | 31 |
| 33 BrowserListTabContentsProvider::BrowserListTabContentsProvider( | 32 BrowserListTabContentsProvider::BrowserListTabContentsProvider( |
| 34 Profile* profile, | |
| 35 chrome::HostDesktopType host_desktop_type) | 33 chrome::HostDesktopType host_desktop_type) |
| 36 : profile_(profile), host_desktop_type_(host_desktop_type) { | 34 : host_desktop_type_(host_desktop_type) { |
| 37 } | 35 } |
| 38 | 36 |
| 39 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { | 37 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { |
| 40 } | 38 } |
| 41 | 39 |
| 42 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { | 40 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { |
| 43 std::set<Profile*> profiles; | 41 std::set<Profile*> profiles; |
| 44 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 42 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
| 45 profiles.insert((*it)->profile()); | 43 profiles.insert((*it)->profile()); |
| 46 | 44 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 | 84 |
| 87 return std::string(); | 85 return std::string(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { | 88 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { |
| 91 const BrowserList* browser_list = | 89 const BrowserList* browser_list = |
| 92 BrowserList::GetInstance(host_desktop_type_); | 90 BrowserList::GetInstance(host_desktop_type_); |
| 93 | 91 |
| 94 if (browser_list->empty()) | 92 if (browser_list->empty()) |
| 95 chrome::NewEmptyWindow(profile_, host_desktop_type_); | 93 chrome::NewEmptyWindow(ProfileManager::GetLastUsedProfile(), |
| 94 host_desktop_type_); |
| 96 | 95 |
| 97 if (browser_list->empty()) | 96 if (browser_list->empty()) |
| 98 return NULL; | 97 return NULL; |
| 99 | 98 |
| 100 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 99 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 101 browser_list->get(0), | 100 browser_list->get(0), |
| 102 GURL(content::kAboutBlankURL), | 101 GURL(content::kAboutBlankURL), |
| 103 content::PAGE_TRANSITION_LINK); | 102 content::PAGE_TRANSITION_LINK); |
| 104 return web_contents->GetRenderViewHost(); | 103 return web_contents->GetRenderViewHost(); |
| 105 } | 104 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate); | 148 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate); |
| 150 } | 149 } |
| 151 #else | 150 #else |
| 152 scoped_refptr<net::StreamListenSocket> | 151 scoped_refptr<net::StreamListenSocket> |
| 153 BrowserListTabContentsProvider::CreateSocketForTethering( | 152 BrowserListTabContentsProvider::CreateSocketForTethering( |
| 154 net::StreamListenSocket::Delegate* delegate, | 153 net::StreamListenSocket::Delegate* delegate, |
| 155 std::string* name) { | 154 std::string* name) { |
| 156 return NULL; | 155 return NULL; |
| 157 } | 156 } |
| 158 #endif // defined(DEBUG_DEVTOOLS) | 157 #endif // defined(DEBUG_DEVTOOLS) |
| OLD | NEW |