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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos call Created 8 years, 5 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
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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 int render_view_id; 548 int render_view_id;
549 bool incognito; 549 bool incognito;
550 CHECK_EQ(4U, args->GetSize()); 550 CHECK_EQ(4U, args->GetSize());
551 CHECK(args->GetString(0, &extension_id)); 551 CHECK(args->GetString(0, &extension_id));
552 CHECK(args->GetString(1, &render_process_id_str)); 552 CHECK(args->GetString(1, &render_process_id_str));
553 CHECK(args->GetString(2, &render_view_id_str)); 553 CHECK(args->GetString(2, &render_view_id_str));
554 CHECK(args->GetBoolean(3, &incognito)); 554 CHECK(args->GetBoolean(3, &incognito));
555 CHECK(base::StringToInt(render_process_id_str, &render_process_id)); 555 CHECK(base::StringToInt(render_process_id_str, &render_process_id));
556 CHECK(base::StringToInt(render_view_id_str, &render_view_id)); 556 CHECK(base::StringToInt(render_view_id_str, &render_view_id));
557 557
558 if (render_process_id == -1) { 558 const Extension* extension =
Matt Perry 2012/07/24 19:25:15 This change is incorrect. The render view might no
559 // This message is for a lazy background page. Start the page if necessary. 559 extension_service_->extensions()->GetByID(extension_id);
560 const Extension* extension = 560 DCHECK(extension);
561 extension_service_->extensions()->GetByID(extension_id);
562 DCHECK(extension);
563 561
564 Profile* profile = extension_service_->profile(); 562 Profile* profile = extension_service_->profile();
565 if (incognito) 563 if (incognito)
566 profile = profile->GetOffTheRecordProfile(); 564 profile = profile->GetOffTheRecordProfile();
567 565
568 ExtensionProcessManager* pm = profile->GetExtensionProcessManager(); 566 extensions::LazyBackgroundTaskQueue* queue =
569 extensions::LazyBackgroundTaskQueue* queue = 567 extensions::ExtensionSystem::Get(profile)->lazy_background_task_queue();
570 extensions::ExtensionSystem::Get(profile)->lazy_background_task_queue();
571 568
572 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); 569 queue->AddPendingTask(
573 if (host) { 570 profile, extension->id(),
574 InspectExtensionHost(host); 571 base::Bind(&ExtensionSettingsHandler::InspectExtensionHost,
575 } else { 572 base::Unretained(this)));
576 queue->AddPendingTask(
577 profile, extension->id(),
578 base::Bind(&ExtensionSettingsHandler::InspectExtensionHost,
579 base::Unretained(this)));
580 }
581
582 return;
583 }
584
585 RenderViewHost* host = RenderViewHost::FromID(render_process_id,
586 render_view_id);
587 if (!host) {
588 // This can happen if the host has gone away since the page was displayed.
589 return;
590 }
591
592 DevToolsWindow::OpenDevToolsWindow(host);
593 } 573 }
594 574
595 void ExtensionSettingsHandler::HandleReloadMessage(const ListValue* args) { 575 void ExtensionSettingsHandler::HandleReloadMessage(const ListValue* args) {
596 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args)); 576 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args));
597 CHECK(!extension_id.empty()); 577 CHECK(!extension_id.empty());
598 extension_service_->ReloadExtension(extension_id); 578 extension_service_->ReloadExtension(extension_id);
599 } 579 }
600 580
601 void ExtensionSettingsHandler::HandleEnableMessage(const ListValue* args) { 581 void ExtensionSettingsHandler::HandleEnableMessage(const ListValue* args) {
602 CHECK_EQ(2U, args->GetSize()); 582 CHECK_EQ(2U, args->GetSize());
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 return extension_uninstall_dialog_.get(); 854 return extension_uninstall_dialog_.get();
875 #else 855 #else
876 return NULL; 856 return NULL;
877 #endif // !defined(OS_ANDROID) 857 #endif // !defined(OS_ANDROID)
878 } 858 }
879 859
880 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) { 860 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) {
881 if (host) 861 if (host)
882 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); 862 DevToolsWindow::OpenDevToolsWindow(host->render_view_host());
883 } 863 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698