Chromium Code Reviews| 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 "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_iterator.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/browser_list_impl.h" | |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/browser/ui/host_desktop.h" | |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 17 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 18 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 20 #include "grit/devtools_discovery_page_resources.h" | 22 #include "grit/devtools_discovery_page_resources.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 23 | 25 |
| 24 using content::DevToolsHttpHandlerDelegate; | 26 using content::DevToolsHttpHandlerDelegate; |
| 25 using content::RenderViewHost; | 27 using content::RenderViewHost; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 return std::string(); | 82 return std::string(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { | 85 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { |
| 84 if (BrowserList::empty()) | 86 if (BrowserList::empty()) |
| 85 chrome::NewEmptyWindow(profile_); | 87 chrome::NewEmptyWindow(profile_); |
| 86 | 88 |
| 87 if (BrowserList::empty()) | 89 if (BrowserList::empty()) |
| 88 return NULL; | 90 return NULL; |
| 89 | 91 |
| 92 // TODO(gab): Do not hardcode HOST_DESKTOP_TYPE_NATIVE below once | |
| 93 // chrome::NewEmptyWindow() above has been made multi-desktop friendly. | |
| 94 const chrome::BrowserListImpl* browser_list = | |
| 95 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); | |
| 90 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 96 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 91 *BrowserList::begin(), | 97 browser_list->get(0), |
|
pfeldman
2013/02/07 20:12:49
Will it tolerate 0 in case of empty list?
gab
2013/02/07 20:31:45
This is no different than the previous code which
| |
| 92 GURL(chrome::kAboutBlankURL), | 98 GURL(chrome::kAboutBlankURL), |
| 93 content::PAGE_TRANSITION_LINK); | 99 content::PAGE_TRANSITION_LINK); |
| 94 return web_contents->GetRenderViewHost(); | 100 return web_contents->GetRenderViewHost(); |
| 95 } | 101 } |
| 96 | 102 |
| 97 content::DevToolsHttpHandlerDelegate::TargetType | 103 content::DevToolsHttpHandlerDelegate::TargetType |
| 98 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { | 104 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { |
| 99 for (TabContentsIterator it; !it.done(); it.Next()) | 105 for (TabContentsIterator it; !it.done(); it.Next()) |
| 100 if (rvh == it->GetRenderViewHost()) | 106 if (rvh == it->GetRenderViewHost()) |
| 101 return kTargetTypeTab; | 107 return kTargetTypeTab; |
| 102 | 108 |
| 103 return kTargetTypeOther; | 109 return kTargetTypeOther; |
| 104 } | 110 } |
| OLD | NEW |