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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 989843002: [Extensions] Make chrome://extensions use developerPrivate for inspect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/saved_files_service.h" 8 #include "apps/saved_files_service.h"
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const char kSupervisedUserError[] = 93 const char kSupervisedUserError[] =
94 "Supervised users cannot modify extension settings."; 94 "Supervised users cannot modify extension settings.";
95 const char kCannotModifyPolicyExtensionError[] = 95 const char kCannotModifyPolicyExtensionError[] =
96 "Cannot modify the extension by policy."; 96 "Cannot modify the extension by policy.";
97 const char kRequiresUserGestureError[] = 97 const char kRequiresUserGestureError[] =
98 "This action requires a user gesture."; 98 "This action requires a user gesture.";
99 const char kCouldNotShowSelectFileDialogError[] = 99 const char kCouldNotShowSelectFileDialogError[] =
100 "Could not show a file chooser."; 100 "Could not show a file chooser.";
101 const char kFileSelectionCanceled[] = 101 const char kFileSelectionCanceled[] =
102 "File selection was canceled."; 102 "File selection was canceled.";
103 const char kInvalidRenderViewIdError[] = "Invalid render process id.";
104 const char kInvalidRenderProcessIdError[] = "Invalid render process id.";
not at google - send to devlin 2015/03/09 18:26:38 These say the same thing, though I don't know if I
Devlin 2015/03/09 19:13:57 Done.
105 const char kNoSuchRendererError[] = "No such renderer.";
103 106
104 const char kUnpackedAppsFolder[] = "apps_target"; 107 const char kUnpackedAppsFolder[] = "apps_target";
105 108
106 ExtensionService* GetExtensionService(content::BrowserContext* context) { 109 ExtensionService* GetExtensionService(content::BrowserContext* context) {
107 return ExtensionSystem::Get(context)->extension_service(); 110 return ExtensionSystem::Get(context)->extension_service();
108 } 111 }
109 112
110 ExtensionUpdater* GetExtensionUpdater(Profile* profile) { 113 ExtensionUpdater* GetExtensionUpdater(Profile* profile) {
111 return GetExtensionService(profile)->updater(); 114 return GetExtensionService(profile)->updater();
112 } 115 }
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 SendResponse(true); 832 SendResponse(true);
830 Release(); 833 Release();
831 } 834 }
832 835
833 DeveloperPrivateShowPermissionsDialogFunction:: 836 DeveloperPrivateShowPermissionsDialogFunction::
834 DeveloperPrivateShowPermissionsDialogFunction() {} 837 DeveloperPrivateShowPermissionsDialogFunction() {}
835 838
836 DeveloperPrivateShowPermissionsDialogFunction:: 839 DeveloperPrivateShowPermissionsDialogFunction::
837 ~DeveloperPrivateShowPermissionsDialogFunction() {} 840 ~DeveloperPrivateShowPermissionsDialogFunction() {}
838 841
839 bool DeveloperPrivateInspectFunction::RunSync() { 842 ExtensionFunction::ResponseAction DeveloperPrivateInspectFunction::Run() {
840 scoped_ptr<developer::Inspect::Params> params( 843 scoped_ptr<developer::Inspect::Params> params(
841 developer::Inspect::Params::Create(*args_)); 844 developer::Inspect::Params::Create(*args_));
842 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); 845 EXTENSION_FUNCTION_VALIDATE(params);
843 const developer::InspectOptions& options = params->options; 846 const developer::InspectOptions& options = params->options;
844 847
845 int render_process_id; 848 // TODO(devlin): These should clearly not be strings.
not at google - send to devlin 2015/03/09 18:26:38 Hmm well what you could do is change the IDL to be
Devlin 2015/03/09 19:13:57 Nifty. Done.
846 base::StringToInt(options.render_process_id, &render_process_id); 849 int render_process_id = 0;
850 if (!base::StringToInt(options.render_process_id, &render_process_id))
851 return RespondNow(Error(kInvalidRenderProcessIdError));
852 int render_view_id = 0;
853 if (!base::StringToInt(options.render_view_id, &render_view_id))
854 return RespondNow(Error(kInvalidRenderViewIdError));
847 855
848 if (render_process_id == -1) { 856 if (render_process_id == -1) {
849 // This is a lazy background page. Identify if it is a normal 857 // This is a lazy background page.
850 // or incognito background page.
851 const Extension* extension = ExtensionRegistry::Get( 858 const Extension* extension = ExtensionRegistry::Get(
852 GetProfile())->enabled_extensions().GetByID(options.extension_id); 859 browser_context())->enabled_extensions().GetByID(options.extension_id);
not at google - send to devlin 2015/03/09 18:26:38 GetExtensionById, or a version of that which only
Devlin 2015/03/09 19:13:57 Hmm... the point is to be briefer than ExtensionRe
not at google - send to devlin 2015/03/09 21:13:17 to be consistent with ExtensionRegistry, which tak
853 DCHECK(extension); 860 if (!extension)
854 // Wakes up the background page and opens the inspect window. 861 return RespondNow(Error(kNoSuchExtensionError));
855 devtools_util::InspectBackgroundPage(extension, GetProfile()); 862
856 return false; 863 Profile* profile = Profile::FromBrowserContext(browser_context());
864 if (options.incognito)
865 profile = profile->GetOffTheRecordProfile();
866
867 // Wakes up the background page and opens the inspect window.
868 devtools_util::InspectBackgroundPage(extension, profile);
869 return RespondNow(NoArguments());
857 } 870 }
858 871
859 int render_view_id;
860 base::StringToInt(options.render_view_id, &render_view_id);
861 content::RenderViewHost* host = content::RenderViewHost::FromID( 872 content::RenderViewHost* host = content::RenderViewHost::FromID(
862 render_process_id, render_view_id); 873 render_process_id, render_view_id);
863 874
864 if (!host || !content::WebContents::FromRenderViewHost(host)) { 875 if (!host || !content::WebContents::FromRenderViewHost(host))
865 // This can happen if the host has gone away since the page was displayed. 876 return RespondNow(Error(kNoSuchRendererError));
866 return false;
867 }
868 877
869 DevToolsWindow::OpenDevToolsWindow( 878 DevToolsWindow::OpenDevToolsWindow(
870 content::WebContents::FromRenderViewHost(host)); 879 content::WebContents::FromRenderViewHost(host));
871 return true; 880 return RespondNow(NoArguments());
872 } 881 }
873 882
874 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {} 883 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {}
875 884
876 DeveloperPrivateLoadUnpackedFunction::DeveloperPrivateLoadUnpackedFunction() 885 DeveloperPrivateLoadUnpackedFunction::DeveloperPrivateLoadUnpackedFunction()
877 : fail_quietly_(false) { 886 : fail_quietly_(false) {
878 } 887 }
879 888
880 ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { 889 ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() {
881 scoped_ptr<developer_private::LoadUnpacked::Params> params( 890 scoped_ptr<developer_private::LoadUnpacked::Params> params(
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0u, &dict)); 1379 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0u, &dict));
1371 1380
1372 error_ui_util::HandleOpenDevTools(dict); 1381 error_ui_util::HandleOpenDevTools(dict);
1373 1382
1374 return true; 1383 return true;
1375 } 1384 }
1376 1385
1377 } // namespace api 1386 } // namespace api
1378 1387
1379 } // namespace extensions 1388 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698