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

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

Issue 352523003: Have the Debugger extension api check that it has access to the tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 | « no previous file | no next file » | 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 <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/scoped_observer.h" 17 #include "base/scoped_observer.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/devtools/devtools_target_impl.h" 23 #include "chrome/browser/devtools/devtools_target_impl.h"
24 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h" 24 #include "chrome/browser/extensions/api/debugger/debugger_api_constants.h"
25 #include "chrome/browser/extensions/extension_service.h" 25 #include "chrome/browser/extensions/extension_service.h"
26 #include "chrome/browser/extensions/extension_tab_util.h" 26 #include "chrome/browser/extensions/extension_tab_util.h"
27 #include "chrome/browser/infobars/infobar_service.h" 27 #include "chrome/browser/infobars/infobar_service.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/sessions/session_id.h"
29 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 30 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
30 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
31 #include "components/infobars/core/confirm_infobar_delegate.h" 32 #include "components/infobars/core/confirm_infobar_delegate.h"
32 #include "components/infobars/core/infobar.h" 33 #include "components/infobars/core/infobar.h"
33 #include "content/public/browser/devtools_agent_host.h" 34 #include "content/public/browser/devtools_agent_host.h"
34 #include "content/public/browser/devtools_client_host.h" 35 #include "content/public/browser/devtools_client_host.h"
35 #include "content/public/browser/devtools_http_handler.h" 36 #include "content/public/browser/devtools_http_handler.h"
36 #include "content/public/browser/devtools_manager.h" 37 #include "content/public/browser/devtools_manager.h"
37 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
39 #include "content/public/browser/render_process_host.h" 40 #include "content/public/browser/render_process_host.h"
40 #include "content/public/browser/render_view_host.h" 41 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/render_widget_host.h" 42 #include "content/public/browser/render_widget_host.h"
42 #include "content/public/browser/web_contents.h" 43 #include "content/public/browser/web_contents.h"
43 #include "content/public/common/content_client.h" 44 #include "content/public/common/content_client.h"
44 #include "content/public/common/url_utils.h" 45 #include "content/public/common/url_utils.h"
45 #include "extensions/browser/event_router.h" 46 #include "extensions/browser/event_router.h"
46 #include "extensions/browser/extension_host.h" 47 #include "extensions/browser/extension_host.h"
47 #include "extensions/browser/extension_registry.h" 48 #include "extensions/browser/extension_registry.h"
48 #include "extensions/browser/extension_registry_observer.h" 49 #include "extensions/browser/extension_registry_observer.h"
49 #include "extensions/browser/extension_system.h" 50 #include "extensions/browser/extension_system.h"
50 #include "extensions/common/error_utils.h" 51 #include "extensions/common/error_utils.h"
51 #include "extensions/common/extension.h" 52 #include "extensions/common/extension.h"
53 #include "extensions/common/permissions/permissions_data.h"
52 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
53 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
54 56
55 using content::DevToolsAgentHost; 57 using content::DevToolsAgentHost;
56 using content::DevToolsClientHost; 58 using content::DevToolsClientHost;
57 using content::DevToolsHttpHandler; 59 using content::DevToolsHttpHandler;
58 using content::DevToolsManager; 60 using content::DevToolsManager;
59 using content::RenderProcessHost; 61 using content::RenderProcessHost;
60 using content::RenderViewHost; 62 using content::RenderViewHost;
61 using content::RenderWidgetHost; 63 using content::RenderWidgetHost;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 keys::kProtocolVersionNotSupportedError, 583 keys::kProtocolVersionNotSupportedError,
582 params->required_version); 584 params->required_version);
583 return false; 585 return false;
584 } 586 }
585 587
586 if (agent_host_->IsAttached()) { 588 if (agent_host_->IsAttached()) {
587 FormatErrorMessage(keys::kAlreadyAttachedError); 589 FormatErrorMessage(keys::kAlreadyAttachedError);
588 return false; 590 return false;
589 } 591 }
590 592
593 const Extension* extension = GetExtension();
594
591 infobars::InfoBar* infobar = NULL; 595 infobars::InfoBar* infobar = NULL;
592 if (!CommandLine::ForCurrentProcess()-> 596 if (!CommandLine::ForCurrentProcess()->
593 HasSwitch(switches::kSilentDebuggerExtensionAPI)) { 597 HasSwitch(switches::kSilentDebuggerExtensionAPI)) {
594 // Do not attach to the target if for any reason the infobar cannot be shown 598 // Do not attach to the target if for any reason the infobar cannot be shown
595 // for this WebContents instance. 599 // for this WebContents instance.
596 infobar = ExtensionDevToolsInfoBarDelegate::Create( 600 infobar = ExtensionDevToolsInfoBarDelegate::Create(
597 agent_host_->GetRenderViewHost(), GetExtension()->name()); 601 agent_host_->GetRenderViewHost(), extension->name());
not at google - send to devlin 2014/06/23 19:34:19 what is the lifetime/behaviour of constructing the
Devlin 2014/06/24 17:49:29 Done.
598 if (!infobar) { 602 if (!infobar) {
599 error_ = ErrorUtils::FormatErrorMessage( 603 error_ = ErrorUtils::FormatErrorMessage(
600 keys::kSilentDebuggingRequired, 604 keys::kSilentDebuggingRequired,
601 switches::kSilentDebuggerExtensionAPI); 605 switches::kSilentDebuggerExtensionAPI);
602 return false; 606 return false;
603 } 607 }
604 } 608 }
605 609
610 content::WebContents* web_contents =
611 content::WebContents::FromRenderViewHost(
612 agent_host_->GetRenderViewHost());
613 if (!web_contents) {
614 FormatErrorMessage(keys::kNoTargetError);
615 return false;
616 }
617
618 if (!extension->permissions_data()->CanAccessPage(
619 extension,
not at google - send to devlin 2014/06/23 19:34:19 tracing this down, it looks like this is backwards
Devlin 2014/06/24 17:49:29 I don't really like the idea of giving any extensi
620 web_contents->GetLastCommittedURL(),
621 web_contents->GetLastCommittedURL(),
622 SessionID::IdForTab(web_contents),
623 -1, // igore process id.
meacer 2014/06/23 19:29:07 igore -> ignore
Devlin 2014/06/24 17:49:29 Done.
624 &error_)) {
625 return false;
meacer 2014/06/23 19:29:07 You can print an error message here too.
Devlin 2014/06/24 17:49:29 Moot now (but |error_| would have been populated v
626 }
627
Devlin 2014/06/23 19:17:47 Ben, I think you were mentioning that we should al
not at google - send to devlin 2014/06/23 19:34:19 I think we should just do that as part of the low-
606 new ExtensionDevToolsClientHost(GetProfile(), 628 new ExtensionDevToolsClientHost(GetProfile(),
607 agent_host_.get(), 629 agent_host_.get(),
608 GetExtension()->id(), 630 extension->id(),
609 GetExtension()->name(), 631 extension->name(),
610 debuggee_, 632 debuggee_,
611 infobar); 633 infobar);
612 SendResponse(true); 634 SendResponse(true);
613 return true; 635 return true;
614 } 636 }
615 637
616 638
617 // DebuggerDetachFunction ----------------------------------------------------- 639 // DebuggerDetachFunction -----------------------------------------------------
618 640
619 DebuggerDetachFunction::DebuggerDetachFunction() { 641 DebuggerDetachFunction::DebuggerDetachFunction() {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 const std::vector<DevToolsTargetImpl*>& target_list) { 759 const std::vector<DevToolsTargetImpl*>& target_list) {
738 scoped_ptr<base::ListValue> result(new base::ListValue()); 760 scoped_ptr<base::ListValue> result(new base::ListValue());
739 for (size_t i = 0; i < target_list.size(); ++i) 761 for (size_t i = 0; i < target_list.size(); ++i)
740 result->Append(SerializeTarget(*target_list[i])); 762 result->Append(SerializeTarget(*target_list[i]));
741 STLDeleteContainerPointers(target_list.begin(), target_list.end()); 763 STLDeleteContainerPointers(target_list.begin(), target_list.end());
742 SetResult(result.release()); 764 SetResult(result.release());
743 SendResponse(true); 765 SendResponse(true);
744 } 766 }
745 767
746 } // namespace extensions 768 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698