| 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_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" | 16 #include "chrome/browser/ui/host_desktop.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
| 21 #include "grit/devtools_discovery_page_resources.h" | 21 #include "grit/devtools_discovery_page_resources.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 24 | 24 |
| 25 using content::DevToolsHttpHandlerDelegate; | 25 using content::DevToolsHttpHandlerDelegate; |
| 26 using content::RenderViewHost; | 26 using content::RenderViewHost; |
| 27 | 27 |
| 28 BrowserListTabContentsProvider::BrowserListTabContentsProvider( | 28 BrowserListTabContentsProvider::BrowserListTabContentsProvider( |
| 29 Profile* profile) | 29 Profile* profile, |
| 30 : profile_(profile) { | 30 chrome::HostDesktopType host_desktop_type) |
| 31 : profile_(profile), host_desktop_type_(host_desktop_type) { |
| 31 } | 32 } |
| 32 | 33 |
| 33 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { | 34 BrowserListTabContentsProvider::~BrowserListTabContentsProvider() { |
| 34 } | 35 } |
| 35 | 36 |
| 36 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { | 37 std::string BrowserListTabContentsProvider::GetDiscoveryPageHTML() { |
| 37 std::set<Profile*> profiles; | 38 std::set<Profile*> profiles; |
| 38 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 39 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
| 39 profiles.insert((*it)->profile()); | 40 profiles.insert((*it)->profile()); |
| 40 | 41 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 scoped_refptr<base::RefCountedMemory> data; | 76 scoped_refptr<base::RefCountedMemory> data; |
| 76 if (top_sites->GetPageThumbnail(url, &data)) | 77 if (top_sites->GetPageThumbnail(url, &data)) |
| 77 return std::string( | 78 return std::string( |
| 78 reinterpret_cast<const char*>(data->front()), data->size()); | 79 reinterpret_cast<const char*>(data->front()), data->size()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 return std::string(); | 82 return std::string(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { | 85 RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { |
| 85 // TODO(gab): Do not hardcode HOST_DESKTOP_TYPE_NATIVE below once | |
| 86 // chrome::NewEmptyWindow() above has been made multi-desktop friendly. | |
| 87 const BrowserList* browser_list = | 86 const BrowserList* browser_list = |
| 88 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); | 87 BrowserList::GetInstance(host_desktop_type_); |
| 89 | 88 |
| 90 if (browser_list->empty()) | 89 if (browser_list->empty()) |
| 91 chrome::NewEmptyWindowDeprecated(profile_); | 90 chrome::NewEmptyWindow(profile_, host_desktop_type_); |
| 92 | 91 |
| 93 if (browser_list->empty()) | 92 if (browser_list->empty()) |
| 94 return NULL; | 93 return NULL; |
| 95 | 94 |
| 96 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( | 95 content::WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 97 browser_list->get(0), | 96 browser_list->get(0), |
| 98 GURL(chrome::kAboutBlankURL), | 97 GURL(chrome::kAboutBlankURL), |
| 99 content::PAGE_TRANSITION_LINK); | 98 content::PAGE_TRANSITION_LINK); |
| 100 return web_contents->GetRenderViewHost(); | 99 return web_contents->GetRenderViewHost(); |
| 101 } | 100 } |
| 102 | 101 |
| 103 content::DevToolsHttpHandlerDelegate::TargetType | 102 content::DevToolsHttpHandlerDelegate::TargetType |
| 104 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { | 103 BrowserListTabContentsProvider::GetTargetType(content::RenderViewHost* rvh) { |
| 105 for (TabContentsIterator it; !it.done(); it.Next()) | 104 for (TabContentsIterator it; !it.done(); it.Next()) |
| 106 if (rvh == it->GetRenderViewHost()) | 105 if (rvh == it->GetRenderViewHost()) |
| 107 return kTargetTypeTab; | 106 return kTargetTypeTab; |
| 108 | 107 |
| 109 return kTargetTypeOther; | 108 return kTargetTypeOther; |
| 110 } | 109 } |
| OLD | NEW |