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