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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/devtools/devtools_window.h" | 15 #include "chrome/browser/devtools/devtools_window.h" |
| 16 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 16 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/file_select_helper.h" | 19 #include "chrome/browser/file_select_helper.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sessions/session_tab_helper.h" | 23 #include "chrome/browser/sessions/session_tab_helper.h" |
| 24 #include "chrome/browser/themes/theme_service.h" | 24 #include "chrome/browser/themes/theme_service.h" |
| 25 #include "chrome/browser/themes/theme_service_factory.h" | 25 #include "chrome/browser/themes/theme_service_factory.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_iterator.h" |
| 28 #include "chrome/browser/ui/browser_list_impl.h" | 28 #include "chrome/browser/ui/browser_list_impl.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/host_desktop.h" | |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/extensions/manifest_url_handler.h" | 34 #include "chrome/common/extensions/manifest_url_handler.h" |
| 34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
| 36 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 37 #include "content/public/browser/child_process_security_policy.h" | 38 #include "content/public/browser/child_process_security_policy.h" |
| 38 #include "content/public/browser/devtools_agent_host.h" | 39 #include "content/public/browser/devtools_agent_host.h" |
| 39 #include "content/public/browser/devtools_client_host.h" | 40 #include "content/public/browser/devtools_client_host.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 browser_->tab_strip_model()->AddWebContents( | 409 browser_->tab_strip_model()->AddWebContents( |
| 409 web_contents_, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 410 web_contents_, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 410 TabStripModel::ADD_ACTIVE); | 411 TabStripModel::ADD_ACTIVE); |
| 411 } | 412 } |
| 412 | 413 |
| 413 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, | 414 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, |
| 414 int* tab) { | 415 int* tab) { |
| 415 if (!inspected_web_contents_) | 416 if (!inspected_web_contents_) |
| 416 return false; | 417 return false; |
| 417 | 418 |
| 418 bool found = FindInspectedBrowserAndTabIndexFromBrowserList( | 419 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 419 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE), | 420 int tab_index = it->tab_strip_model()->GetIndexOfWebContents( |
| 420 browser, | |
| 421 tab); | |
| 422 // On Windows 8 we can have the desktop environment and the ASH environment | |
| 423 // active concurrently. If we fail to find the inspected web contents in the | |
| 424 // native browser list, then we should look in the ASH browser list. | |
| 425 #if defined(OS_WIN) && defined(USE_AURA) | |
| 426 if (!found) { | |
| 427 found = FindInspectedBrowserAndTabIndexFromBrowserList( | |
| 428 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH), | |
| 429 browser, | |
| 430 tab); | |
| 431 } | |
| 432 #endif | |
| 433 return found; | |
| 434 } | |
| 435 | |
| 436 bool DevToolsWindow::FindInspectedBrowserAndTabIndexFromBrowserList( | |
| 437 chrome::BrowserListImpl* browser_list, | |
| 438 Browser** browser, | |
| 439 int* tab) { | |
| 440 if (!inspected_web_contents_) | |
| 441 return false; | |
| 442 | |
| 443 for (chrome::BrowserListImpl::const_iterator it = browser_list->begin(); | |
| 444 it != browser_list->end(); ++it) { | |
| 445 int tab_index = (*it)->tab_strip_model()->GetIndexOfWebContents( | |
| 446 inspected_web_contents_); | 421 inspected_web_contents_); |
| 447 if (tab_index != TabStripModel::kNoTab) { | 422 if (tab_index != TabStripModel::kNoTab) { |
| 448 *browser = *it; | 423 *browser = *it; |
| 449 *tab = tab_index; | 424 *tab = tab_index; |
| 450 return true; | 425 return true; |
| 451 } | 426 } |
| 452 } | 427 } |
| 453 return false; | 428 return false; |
| 454 } | 429 } |
| 455 | 430 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 | 800 |
| 826 void DevToolsWindow::OpenInNewTab(const std::string& url) { | 801 void DevToolsWindow::OpenInNewTab(const std::string& url) { |
| 827 OpenURLParams params(GURL(url), | 802 OpenURLParams params(GURL(url), |
| 828 content::Referrer(), | 803 content::Referrer(), |
| 829 NEW_FOREGROUND_TAB, | 804 NEW_FOREGROUND_TAB, |
| 830 content::PAGE_TRANSITION_LINK, | 805 content::PAGE_TRANSITION_LINK, |
| 831 false /* is_renderer_initiated */); | 806 false /* is_renderer_initiated */); |
| 832 if (inspected_web_contents_) { | 807 if (inspected_web_contents_) { |
| 833 inspected_web_contents_->OpenURL(params); | 808 inspected_web_contents_->OpenURL(params); |
| 834 } else { | 809 } else { |
| 835 for (BrowserList::const_iterator it = BrowserList::begin(); | 810 chrome::HostDesktopType host_desktop_type; |
|
pfeldman
2013/02/09 10:15:53
I am not sure I follow the code below.
Note that
gab
2013/02/09 17:38:05
Right, this code does the same thing as the previo
| |
| 836 it != BrowserList::end(); ++it) { | 811 if (browser_) { |
| 812 host_desktop_type = browser_->host_desktop_type(); | |
| 813 } else { | |
| 814 // There should always be a browser when there are no inspected web | |
| 815 // contents. | |
| 816 NOTREACHED(); | |
| 817 host_desktop_type = chrome::GetActiveDesktop(); | |
| 818 } | |
| 819 | |
| 820 const chrome::BrowserListImpl* browser_list = | |
| 821 chrome::BrowserListImpl::GetInstance(host_desktop_type); | |
| 822 for (chrome::BrowserListImpl::const_iterator it = browser_list->begin(); | |
| 823 it != browser_list->end(); ++it) { | |
| 837 if ((*it)->type() == Browser::TYPE_TABBED) { | 824 if ((*it)->type() == Browser::TYPE_TABBED) { |
| 838 (*it)->OpenURL(params); | 825 (*it)->OpenURL(params); |
| 839 break; | 826 break; |
| 840 } | 827 } |
| 841 } | 828 } |
| 842 } | 829 } |
| 843 } | 830 } |
| 844 | 831 |
| 845 void DevToolsWindow::SaveToFile(const std::string& url, | 832 void DevToolsWindow::SaveToFile(const std::string& url, |
| 846 const std::string& content, | 833 const std::string& content, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 | 981 |
| 995 // static | 982 // static |
| 996 DevToolsDockSide DevToolsWindow::SideFromString( | 983 DevToolsDockSide DevToolsWindow::SideFromString( |
| 997 const std::string& dock_side) { | 984 const std::string& dock_side) { |
| 998 if (dock_side == kDockSideRight) | 985 if (dock_side == kDockSideRight) |
| 999 return DEVTOOLS_DOCK_SIDE_RIGHT; | 986 return DEVTOOLS_DOCK_SIDE_RIGHT; |
| 1000 if (dock_side == kDockSideBottom) | 987 if (dock_side == kDockSideBottom) |
| 1001 return DEVTOOLS_DOCK_SIDE_BOTTOM; | 988 return DEVTOOLS_DOCK_SIDE_BOTTOM; |
| 1002 return DEVTOOLS_DOCK_SIDE_UNDOCKED; | 989 return DEVTOOLS_DOCK_SIDE_UNDOCKED; |
| 1003 } | 990 } |
| OLD | NEW |