Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/extensions/api/debugger/debugger_api.cc

Issue 2263843002: DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 3 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/devtools/devtools_window.cc ('k') | chrome/browser/resources/inspect/inspect.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Implements the Chrome Extensions Debugger API. 5 // Implements the Chrome Extensions Debugger API.
6 6
7 #include "chrome/browser/extensions/api/debugger/debugger_api.h" 7 #include "chrome/browser/extensions/api/debugger/debugger_api.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <utility> 14 #include <utility>
15 15
16 #include "base/callback_helpers.h" 16 #include "base/callback_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/json/json_reader.h" 18 #include "base/json/json_reader.h"
19 #include "base/json/json_writer.h" 19 #include "base/json/json_writer.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/singleton.h" 22 #include "base/memory/singleton.h"
23 #include "base/scoped_observer.h" 23 #include "base/scoped_observer.h"
24 #include "base/stl_util.h" 24 #include "base/stl_util.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/values.h" 27 #include "base/values.h"
28 #include "chrome/browser/chrome_notification_types.h" 28 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
29 #include "chrome/browser/devtools/devtools_target_impl.h" 30 #include "chrome/browser/devtools/devtools_target_impl.h"
30 #include "chrome/browser/devtools/global_confirm_info_bar.h" 31 #include "chrome/browser/devtools/global_confirm_info_bar.h"
31 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h" 32 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h"
32 #include "chrome/browser/extensions/extension_service.h" 33 #include "chrome/browser/extensions/extension_service.h"
33 #include "chrome/browser/extensions/extension_tab_util.h" 34 #include "chrome/browser/extensions/extension_tab_util.h"
34 #include "chrome/browser/infobars/infobar_service.h" 35 #include "chrome/browser/infobars/infobar_service.h"
35 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/ui/browser.h" 37 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 38 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
38 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // DebuggerGetTargetsFunction ------------------------------------------------- 667 // DebuggerGetTargetsFunction -------------------------------------------------
667 668
668 namespace { 669 namespace {
669 670
670 const char kTargetIdField[] = "id"; 671 const char kTargetIdField[] = "id";
671 const char kTargetTypeField[] = "type"; 672 const char kTargetTypeField[] = "type";
672 const char kTargetTitleField[] = "title"; 673 const char kTargetTitleField[] = "title";
673 const char kTargetAttachedField[] = "attached"; 674 const char kTargetAttachedField[] = "attached";
674 const char kTargetUrlField[] = "url"; 675 const char kTargetUrlField[] = "url";
675 const char kTargetFaviconUrlField[] = "faviconUrl"; 676 const char kTargetFaviconUrlField[] = "faviconUrl";
676 const char kTargetTypePage[] = "page";
677 const char kTargetTypeBackgroundPage[] = "background_page";
678 const char kTargetTypeWorker[] = "worker";
679 const char kTargetTypeOther[] = "other";
680 const char kTargetTabIdField[] = "tabId"; 677 const char kTargetTabIdField[] = "tabId";
681 const char kTargetExtensionIdField[] = "extensionId"; 678 const char kTargetExtensionIdField[] = "extensionId";
679 const char kTargetTypeWorker[] = "worker";
682 680
683 base::Value* SerializeTarget(const DevToolsTargetImpl& target) { 681 base::Value* SerializeTarget(const DevToolsTargetImpl& target) {
684 base::DictionaryValue* dictionary = new base::DictionaryValue(); 682 base::DictionaryValue* dictionary = new base::DictionaryValue();
683 scoped_refptr<DevToolsAgentHost> host = target.GetAgentHost();
684 dictionary->SetString(kTargetIdField, host->GetId());
685 dictionary->SetString(kTargetTitleField, host->GetTitle());
686 dictionary->SetBoolean(kTargetAttachedField, host->IsAttached());
687 dictionary->SetString(kTargetUrlField, host->GetURL().spec());
685 688
686 dictionary->SetString(kTargetIdField, target.GetId()); 689 std::string type = host->GetType();
687 dictionary->SetString(kTargetTitleField, target.GetTitle()); 690 if (type == DevToolsAgentHost::kTypePage) {
688 dictionary->SetBoolean(kTargetAttachedField, target.IsAttached()); 691 int tab_id =
689 dictionary->SetString(kTargetUrlField, target.GetURL().spec()); 692 extensions::ExtensionTabUtil::GetTabId(host->GetWebContents());
693 dictionary->SetInteger(kTargetTabIdField, tab_id);
694 } else if (type == ChromeDevToolsManagerDelegate::kTypeBackgroundPage) {
695 dictionary->SetString(kTargetExtensionIdField, host->GetURL().host());
696 }
690 697
691 std::string type = target.GetType(); 698 if (type == DevToolsAgentHost::kTypeServiceWorker ||
692 if (type == kTargetTypePage) { 699 type == DevToolsAgentHost::kTypeSharedWorker) {
693 dictionary->SetInteger(kTargetTabIdField, target.GetTabId()); 700 type = kTargetTypeWorker;
694 } else if (type == kTargetTypeBackgroundPage) {
695 dictionary->SetString(kTargetExtensionIdField, target.GetExtensionId());
696 } else if (type != kTargetTypeWorker) {
697 // DevToolsTargetImpl may support more types than the debugger API.
698 type = kTargetTypeOther;
699 } 701 }
702
700 dictionary->SetString(kTargetTypeField, type); 703 dictionary->SetString(kTargetTypeField, type);
701 704
702 GURL favicon_url = target.GetFaviconURL(); 705 GURL favicon_url = host->GetFaviconURL();
703 if (favicon_url.is_valid()) 706 if (favicon_url.is_valid())
704 dictionary->SetString(kTargetFaviconUrlField, favicon_url.spec()); 707 dictionary->SetString(kTargetFaviconUrlField, favicon_url.spec());
705 708
706 return dictionary; 709 return dictionary;
707 } 710 }
708 711
709 } // namespace 712 } // namespace
710 713
711 DebuggerGetTargetsFunction::DebuggerGetTargetsFunction() { 714 DebuggerGetTargetsFunction::DebuggerGetTargetsFunction() {
712 } 715 }
(...skipping 14 matching lines...) Expand all
727 const std::vector<DevToolsTargetImpl*>& target_list) { 730 const std::vector<DevToolsTargetImpl*>& target_list) {
728 std::unique_ptr<base::ListValue> result(new base::ListValue()); 731 std::unique_ptr<base::ListValue> result(new base::ListValue());
729 for (size_t i = 0; i < target_list.size(); ++i) 732 for (size_t i = 0; i < target_list.size(); ++i)
730 result->Append(SerializeTarget(*target_list[i])); 733 result->Append(SerializeTarget(*target_list[i]));
731 base::STLDeleteContainerPointers(target_list.begin(), target_list.end()); 734 base::STLDeleteContainerPointers(target_list.begin(), target_list.end());
732 SetResult(std::move(result)); 735 SetResult(std::move(result));
733 SendResponse(true); 736 SendResponse(true);
734 } 737 }
735 738
736 } // namespace extensions 739 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_window.cc ('k') | chrome/browser/resources/inspect/inspect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698