| 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" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 scoped_refptr<base::RefCountedMemory> data; | 76 scoped_refptr<base::RefCountedMemory> data; |
| 77 if (top_sites->GetPageThumbnail(url, &data)) | 77 if (top_sites->GetPageThumbnail(url, &data)) |
| 78 return std::string( | 78 return std::string( |
| 79 reinterpret_cast<const char*>(data->front()), data->size()); | 79 reinterpret_cast<const char*>(data->front()), data->size()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 return std::string(); | 82 return std::string(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { | 85 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { |
| 86 if (BrowserList::empty()) | |
| 87 chrome::NewEmptyWindow(profile_); | |
| 88 | |
| 89 if (BrowserList::empty()) | |
| 90 return NULL; | |
| 91 | |
| 92 // TODO(gab): Do not hardcode HOST_DESKTOP_TYPE_NATIVE below once | 86 // TODO(gab): Do not hardcode HOST_DESKTOP_TYPE_NATIVE below once |
| 93 // chrome::NewEmptyWindow() above has been made multi-desktop friendly. | 87 // chrome::NewEmptyWindow() above has been made multi-desktop friendly. |
| 94 const chrome::BrowserListImpl* browser_list = | 88 const chrome::BrowserListImpl* browser_list = |
| 95 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); | 89 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 90 |
| 91 if (browser_list->empty()) |
| 92 chrome::NewEmptyWindow(profile_); |
| 93 |
| 94 if (browser_list->empty()) |
| 95 return NULL; |
| 96 |
| 96 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 97 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 97 browser_list->get(0), | 98 browser_list->get(0), |
| 98 GURL(chrome::kAboutBlankURL), | 99 GURL(chrome::kAboutBlankURL), |
| 99 content::PAGE_TRANSITION_LINK); | 100 content::PAGE_TRANSITION_LINK); |
| 100 return web_contents->GetRenderViewHost(); | 101 return web_contents->GetRenderViewHost(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 content::DevToolsHttpHandlerDelegate::TargetType | 104 content::DevToolsHttpHandlerDelegate::TargetType |
| 104 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { | 105 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { |
| 105 for (TabContentsIterator it; !it.done(); it.Next()) | 106 for (TabContentsIterator it; !it.done(); it.Next()) |
| 106 if (rvh == it->GetRenderViewHost()) | 107 if (rvh == it->GetRenderViewHost()) |
| 107 return kTargetTypeTab; | 108 return kTargetTypeTab; |
| 108 | 109 |
| 109 return kTargetTypeOther; | 110 return kTargetTypeOther; |
| 110 } | 111 } |
| OLD | NEW |