| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "grit/chromium_strings.h" | 49 #include "grit/chromium_strings.h" |
| 50 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
| 51 #include "grit/theme_resources.h" | 51 #include "grit/theme_resources.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/resource/resource_bundle.h" | 53 #include "ui/base/resource/resource_bundle.h" |
| 54 | 54 |
| 55 using content::RenderViewHost; | 55 using content::RenderViewHost; |
| 56 using content::WebContents; | 56 using content::WebContents; |
| 57 using extensions::ExtensionUpdater; | 57 using extensions::ExtensionUpdater; |
| 58 | 58 |
| 59 namespace { | |
| 60 | |
| 61 bool ShouldShowExtension(const Extension* extension) { | |
| 62 // Don't show themes since this page's UI isn't really useful for themes. | |
| 63 if (extension->is_theme()) | |
| 64 return false; | |
| 65 | |
| 66 // Don't show component extensions because they are only extensions as an | |
| 67 // implementation detail of Chrome. | |
| 68 if (extension->location() == Extension::COMPONENT && | |
| 69 !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 70 switches::kShowComponentExtensionOptions)) | |
| 71 return false; | |
| 72 | |
| 73 // Always show unpacked extensions and apps. | |
| 74 if (extension->location() == Extension::LOAD) | |
| 75 return true; | |
| 76 | |
| 77 // Unless they are unpacked, never show hosted apps. Note: We intentionally | |
| 78 // show packaged apps and platform apps because there are some pieces of | |
| 79 // functionality that are only available in chrome://extensions/ but which | |
| 80 // are needed for packaged and platform apps. For example, inspecting | |
| 81 // background pages. See http://crbug.com/116134. | |
| 82 if (extension->is_hosted_app()) | |
| 83 return false; | |
| 84 | |
| 85 return true; | |
| 86 } | |
| 87 | |
| 88 } // namespace | |
| 89 | |
| 90 /////////////////////////////////////////////////////////////////////////////// | 59 /////////////////////////////////////////////////////////////////////////////// |
| 91 // | 60 // |
| 92 // ExtensionSettingsHandler | 61 // ExtensionSettingsHandler |
| 93 // | 62 // |
| 94 /////////////////////////////////////////////////////////////////////////////// | 63 /////////////////////////////////////////////////////////////////////////////// |
| 95 | 64 |
| 96 ExtensionSettingsHandler::ExtensionSettingsHandler() | 65 ExtensionSettingsHandler::ExtensionSettingsHandler() |
| 97 : extension_service_(NULL), | 66 : extension_service_(NULL), |
| 98 ignore_notifications_(false), | 67 ignore_notifications_(false), |
| 99 deleting_rvh_(NULL), | 68 deleting_rvh_(NULL), |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 DictionaryValue results; | 429 DictionaryValue results; |
| 461 | 430 |
| 462 // Add the extensions to the results structure. | 431 // Add the extensions to the results structure. |
| 463 ListValue *extensions_list = new ListValue(); | 432 ListValue *extensions_list = new ListValue(); |
| 464 | 433 |
| 465 ExtensionWarningSet* warnings = extension_service_->extension_warnings(); | 434 ExtensionWarningSet* warnings = extension_service_->extension_warnings(); |
| 466 | 435 |
| 467 const ExtensionSet* extensions = extension_service_->extensions(); | 436 const ExtensionSet* extensions = extension_service_->extensions(); |
| 468 for (ExtensionSet::const_iterator extension = extensions->begin(); | 437 for (ExtensionSet::const_iterator extension = extensions->begin(); |
| 469 extension != extensions->end(); ++extension) { | 438 extension != extensions->end(); ++extension) { |
| 470 if (ShouldShowExtension(*extension)) { | 439 if ((*extension)->ShouldDisplayInExtensionSettings()) { |
| 471 extensions_list->Append(CreateExtensionDetailValue( | 440 extensions_list->Append(CreateExtensionDetailValue( |
| 472 *extension, | 441 *extension, |
| 473 GetInspectablePagesForExtension(*extension, true), | 442 GetInspectablePagesForExtension(*extension, true), |
| 474 warnings)); | 443 warnings)); |
| 475 } | 444 } |
| 476 } | 445 } |
| 477 extensions = extension_service_->disabled_extensions(); | 446 extensions = extension_service_->disabled_extensions(); |
| 478 for (ExtensionSet::const_iterator extension = extensions->begin(); | 447 for (ExtensionSet::const_iterator extension = extensions->begin(); |
| 479 extension != extensions->end(); ++extension) { | 448 extension != extensions->end(); ++extension) { |
| 480 if (ShouldShowExtension(*extension)) { | 449 if ((*extension)->ShouldDisplayInExtensionSettings()) { |
| 481 extensions_list->Append(CreateExtensionDetailValue( | 450 extensions_list->Append(CreateExtensionDetailValue( |
| 482 *extension, | 451 *extension, |
| 483 GetInspectablePagesForExtension(*extension, false), | 452 GetInspectablePagesForExtension(*extension, false), |
| 484 warnings)); | 453 warnings)); |
| 485 } | 454 } |
| 486 } | 455 } |
| 487 extensions = extension_service_->terminated_extensions(); | 456 extensions = extension_service_->terminated_extensions(); |
| 488 std::vector<ExtensionPage> empty_pages; | 457 std::vector<ExtensionPage> empty_pages; |
| 489 for (ExtensionSet::const_iterator extension = extensions->begin(); | 458 for (ExtensionSet::const_iterator extension = extensions->begin(); |
| 490 extension != extensions->end(); ++extension) { | 459 extension != extensions->end(); ++extension) { |
| 491 if (ShouldShowExtension(*extension)) { | 460 if ((*extension)->ShouldDisplayInExtensionSettings()) { |
| 492 extensions_list->Append(CreateExtensionDetailValue( | 461 extensions_list->Append(CreateExtensionDetailValue( |
| 493 *extension, | 462 *extension, |
| 494 empty_pages, // Terminated process has no active pages. | 463 empty_pages, // Terminated process has no active pages. |
| 495 warnings)); | 464 warnings)); |
| 496 } | 465 } |
| 497 } | 466 } |
| 498 results.Set("extensions", extensions_list); | 467 results.Set("extensions", extensions_list); |
| 499 | 468 |
| 500 Profile* profile = Profile::FromWebUI(web_ui()); | 469 Profile* profile = Profile::FromWebUI(web_ui()); |
| 501 bool developer_mode = | 470 bool developer_mode = |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 return extension_uninstall_dialog_.get(); | 810 return extension_uninstall_dialog_.get(); |
| 842 #else | 811 #else |
| 843 return NULL; | 812 return NULL; |
| 844 #endif // !defined(OS_ANDROID) | 813 #endif // !defined(OS_ANDROID) |
| 845 } | 814 } |
| 846 | 815 |
| 847 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) { | 816 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) { |
| 848 if (host) | 817 if (host) |
| 849 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); | 818 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); |
| 850 } | 819 } |
| OLD | NEW |