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" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
17 #include "chrome/browser/ui/browser_iterator.h" | 17 #include "chrome/browser/ui/browser_iterator.h" |
18 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
20 #include "chrome/browser/ui/host_desktop.h" | 20 #include "chrome/browser/ui/host_desktop.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
25 #include "grit/devtools_discovery_page_resources.h" | 26 #include "grit/devtools_discovery_page_resources.h" |
26 #include "net/socket/tcp_listen_socket.h" | 27 #include "net/socket/tcp_listen_socket.h" |
27 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
29 | 30 |
30 using content::DevToolsHttpHandlerDelegate; | 31 using content::DevToolsHttpHandlerDelegate; |
31 using content::RenderViewHost; | 32 using content::RenderViewHost; |
32 | 33 |
33 BrowserListTabContentsProvider::BrowserListTabContentsProvider( | 34 BrowserListTabContentsProvider::BrowserListTabContentsProvider( |
34 Profile* profile, | 35 Profile* profile, |
35 chrome::HostDesktopType host_desktop_type) | 36 chrome::HostDesktopType host_desktop_type) |
36 : profile_(profile), host_desktop_type_(host_desktop_type) { | 37 : profile_(profile->GetOriginalProfile()), |
Tim Song
2013/05/20 22:48:41
If the profile being passed in here is an incognit
achuithb
2013/05/20 23:10:00
Yup, that's here:
https://code.google.com/p/chromi
| |
38 host_desktop_type_(host_desktop_type) { | |
37 } | 39 } |
38 | 40 |
39 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { | 41 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { |
40 } | 42 } |
41 | 43 |
42 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { | 44 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { |
43 std::set<Profile*> profiles; | 45 std::set<Profile*> profiles; |
44 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 46 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
45 profiles.insert((*it)->profile()); | 47 profiles.insert((*it)->profile()); |
46 | 48 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 reinterpret_cast<const char*>(data->front()), data->size()); | 86 reinterpret_cast<const char*>(data->front()), data->size()); |
85 } | 87 } |
86 | 88 |
87 return std::string(); | 89 return std::string(); |
88 } | 90 } |
89 | 91 |
90 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { | 92 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { |
91 const BrowserList* browser_list = | 93 const BrowserList* browser_list = |
92 BrowserList::GetInstance(host_desktop_type_); | 94 BrowserList::GetInstance(host_desktop_type_); |
93 | 95 |
94 if (browser_list->empty()) | 96 if (browser_list->empty()) { |
95 chrome::NewEmptyWindow(profile_, host_desktop_type_); | 97 chrome::NewEmptyWindow(profile_, host_desktop_type_); |
96 | 98 return browser_list->empty() ? NULL : |
97 if (browser_list->empty()) | 99 browser_list->get(0)->tab_strip_model()->GetActiveWebContents()-> |
98 return NULL; | 100 GetRenderViewHost(); |
Tim Song
2013/05/20 22:48:41
This is good, as we don't want two tabs being open
achuithb
2013/05/20 23:10:00
That code only kicks in when a tab is closed. This
| |
101 } | |
99 | 102 |
100 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 103 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
101 browser_list->get(0), | 104 browser_list->get(0), |
102 GURL(content::kAboutBlankURL), | 105 GURL(content::kAboutBlankURL), |
103 content::PAGE_TRANSITION_LINK); | 106 content::PAGE_TRANSITION_LINK); |
104 return web_contents->GetRenderViewHost(); | 107 return web_contents->GetRenderViewHost(); |
105 } | 108 } |
106 | 109 |
107 content::DevToolsHttpHandlerDelegate::TargetType | 110 content::DevToolsHttpHandlerDelegate::TargetType |
108 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { | 111 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate); | 152 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate); |
150 } | 153 } |
151 #else | 154 #else |
152 scoped_refptr<net::StreamListenSocket> | 155 scoped_refptr<net::StreamListenSocket> |
153 BrowserListTabContentsProvider::CreateSocketForTethering( | 156 BrowserListTabContentsProvider::CreateSocketForTethering( |
154 net::StreamListenSocket::Delegate* delegate, | 157 net::StreamListenSocket::Delegate* delegate, |
155 std::string* name) { | 158 std::string* name) { |
156 return NULL; | 159 return NULL; |
157 } | 160 } |
158 #endif // defined(DEBUG_DEVTOOLS) | 161 #endif // defined(DEBUG_DEVTOOLS) |
OLD | NEW |