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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 10907243: Add "inspect background page" to platform app right-click menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment in test Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.h ('k') | 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 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 CHECK(args->GetBoolean(3, &incognito)); 559 CHECK(args->GetBoolean(3, &incognito));
560 CHECK(base::StringToInt(render_process_id_str, &render_process_id)); 560 CHECK(base::StringToInt(render_process_id_str, &render_process_id));
561 CHECK(base::StringToInt(render_view_id_str, &render_view_id)); 561 CHECK(base::StringToInt(render_view_id_str, &render_view_id));
562 562
563 if (render_process_id == -1) { 563 if (render_process_id == -1) {
564 // This message is for a lazy background page. Start the page if necessary. 564 // This message is for a lazy background page. Start the page if necessary.
565 const Extension* extension = 565 const Extension* extension =
566 extension_service_->extensions()->GetByID(extension_id); 566 extension_service_->extensions()->GetByID(extension_id);
567 DCHECK(extension); 567 DCHECK(extension);
568 568
569 Profile* profile = extension_service_->profile(); 569 ExtensionService* service = extension_service_;
570 if (incognito) 570 if (incognito)
571 profile = profile->GetOffTheRecordProfile(); 571 service = extensions::ExtensionSystem::Get(extension_service_->
572 profile()->GetOffTheRecordProfile())->extension_service();
572 573
573 ExtensionProcessManager* pm = profile->GetExtensionProcessManager(); 574 service->InspectBackgroundPage(extension);
574 extensions::LazyBackgroundTaskQueue* queue =
575 extensions::ExtensionSystem::Get(profile)->lazy_background_task_queue();
576
577 extensions::ExtensionHost* host =
578 pm->GetBackgroundHostForExtension(extension->id());
579 if (host) {
580 InspectExtensionHost(host);
581 } else {
582 queue->AddPendingTask(
583 profile, extension->id(),
584 base::Bind(&ExtensionSettingsHandler::InspectExtensionHost,
585 base::Unretained(this)));
586 }
587
588 return; 575 return;
589 } 576 }
590 577
591 RenderViewHost* host = RenderViewHost::FromID(render_process_id, 578 RenderViewHost* host = RenderViewHost::FromID(render_process_id,
592 render_view_id); 579 render_view_id);
593 if (!host) { 580 if (!host) {
594 // This can happen if the host has gone away since the page was displayed. 581 // This can happen if the host has gone away since the page was displayed.
595 return; 582 return;
596 } 583 }
597 584
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 web_ui()->GetWebContents()); 876 web_ui()->GetWebContents());
890 extension_uninstall_dialog_.reset( 877 extension_uninstall_dialog_.reset(
891 ExtensionUninstallDialog::Create(browser, this)); 878 ExtensionUninstallDialog::Create(browser, this));
892 } 879 }
893 return extension_uninstall_dialog_.get(); 880 return extension_uninstall_dialog_.get();
894 #else 881 #else
895 return NULL; 882 return NULL;
896 #endif // !defined(OS_ANDROID) 883 #endif // !defined(OS_ANDROID)
897 } 884 }
898 885
899 void ExtensionSettingsHandler::InspectExtensionHost(
900 extensions::ExtensionHost* host) {
901 if (host)
902 DevToolsWindow::OpenDevToolsWindow(host->render_view_host());
903 }
904
905 void ExtensionSettingsHandler::OnRequirementsChecked( 886 void ExtensionSettingsHandler::OnRequirementsChecked(
906 std::string extension_id, 887 std::string extension_id,
907 std::vector<std::string> requirement_errors) { 888 std::vector<std::string> requirement_errors) {
908 if (requirement_errors.empty()) { 889 if (requirement_errors.empty()) {
909 extension_service_->EnableExtension(extension_id); 890 extension_service_->EnableExtension(extension_id);
910 } else { 891 } else {
911 ExtensionErrorReporter::GetInstance()->ReportError( 892 ExtensionErrorReporter::GetInstance()->ReportError(
912 UTF8ToUTF16(JoinString(requirement_errors, ' ')), 893 UTF8ToUTF16(JoinString(requirement_errors, ' ')),
913 true /* be noisy */); 894 true /* be noisy */);
914 } 895 }
915 requirements_checker_.reset(); 896 requirements_checker_.reset();
916 } 897 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698