| 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 "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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 #include "grit/components_strings.h" | 101 #include "grit/components_strings.h" |
| 102 #include "grit/theme_resources.h" | 102 #include "grit/theme_resources.h" |
| 103 #include "ui/base/l10n/l10n_util.h" | 103 #include "ui/base/l10n/l10n_util.h" |
| 104 | 104 |
| 105 using base::DictionaryValue; | 105 using base::DictionaryValue; |
| 106 using base::ListValue; | 106 using base::ListValue; |
| 107 using content::RenderViewHost; | 107 using content::RenderViewHost; |
| 108 using content::WebContents; | 108 using content::WebContents; |
| 109 | 109 |
| 110 namespace { | 110 namespace { |
| 111 |
| 111 const char kAppsDeveloperToolsExtensionId[] = | 112 const char kAppsDeveloperToolsExtensionId[] = |
| 112 "ohmmkhmmmpcnpikjeljgnaoabkaalbgc"; | 113 "ohmmkhmmmpcnpikjeljgnaoabkaalbgc"; |
| 114 |
| 115 // Returns true if the extensions page should display the new-style extension |
| 116 // info dialog. If false, display the old permissions dialog. |
| 117 bool ShouldDisplayExtensionInfoDialog() { |
| 118 #if defined(OS_MACOSX) |
| 119 return false; |
| 120 #else |
| 121 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 122 extensions::switches::kDisableExtensionInfoDialog); |
| 123 #endif |
| 113 } | 124 } |
| 114 | 125 |
| 126 } // namespace |
| 127 |
| 115 namespace extensions { | 128 namespace extensions { |
| 116 | 129 |
| 117 ExtensionPage::ExtensionPage(const GURL& url, | 130 ExtensionPage::ExtensionPage(const GURL& url, |
| 118 int render_process_id, | 131 int render_process_id, |
| 119 int render_view_id, | 132 int render_view_id, |
| 120 bool incognito, | 133 bool incognito, |
| 121 bool generated_background_page) | 134 bool generated_background_page) |
| 122 : url(url), | 135 : url(url), |
| 123 render_process_id(render_process_id), | 136 render_process_id(render_process_id), |
| 124 render_view_id(render_view_id), | 137 render_view_id(render_view_id), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 Manifest::IsUnpackedLocation(extension->location())); | 296 Manifest::IsUnpackedLocation(extension->location())); |
| 284 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); | 297 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); |
| 285 extension_data->SetBoolean("is_platform_app", extension->is_platform_app()); | 298 extension_data->SetBoolean("is_platform_app", extension->is_platform_app()); |
| 286 extension_data->SetBoolean("homepageProvided", | 299 extension_data->SetBoolean("homepageProvided", |
| 287 ManifestURL::SpecifiedHomepageURL(extension)); | 300 ManifestURL::SpecifiedHomepageURL(extension)); |
| 288 extension_data->SetBoolean("optionsOpenInTab", | 301 extension_data->SetBoolean("optionsOpenInTab", |
| 289 OptionsPageInfo::ShouldOpenInTab(extension)); | 302 OptionsPageInfo::ShouldOpenInTab(extension)); |
| 290 extension_data->SetString("optionsPageHref", | 303 extension_data->SetString("optionsPageHref", |
| 291 OptionsPageInfo::GetOptionsPage(extension).spec()); | 304 OptionsPageInfo::GetOptionsPage(extension).spec()); |
| 292 extension_data->SetBoolean("enableExtensionInfoDialog", | 305 extension_data->SetBoolean("enableExtensionInfoDialog", |
| 293 CommandLine::ForCurrentProcess()->HasSwitch( | 306 ShouldDisplayExtensionInfoDialog()); |
| 294 switches::kEnableExtensionInfoDialog)); | |
| 295 | 307 |
| 296 // Add dependent extensions. | 308 // Add dependent extensions. |
| 297 base::ListValue* dependents_list = new base::ListValue; | 309 base::ListValue* dependents_list = new base::ListValue; |
| 298 if (extension->is_shared_module()) { | 310 if (extension->is_shared_module()) { |
| 299 scoped_ptr<ExtensionSet> dependent_extensions = | 311 scoped_ptr<ExtensionSet> dependent_extensions = |
| 300 extension_service_->shared_module_service()->GetDependentExtensions( | 312 extension_service_->shared_module_service()->GetDependentExtensions( |
| 301 extension); | 313 extension); |
| 302 for (ExtensionSet::const_iterator i = dependent_extensions->begin(); | 314 for (ExtensionSet::const_iterator i = dependent_extensions->begin(); |
| 303 i != dependent_extensions->end(); | 315 i != dependent_extensions->end(); |
| 304 i++) { | 316 i++) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 source->AddString("extensionSettingsReloadTerminated", | 545 source->AddString("extensionSettingsReloadTerminated", |
| 534 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_TERMINATED)); | 546 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_TERMINATED)); |
| 535 source->AddString("extensionSettingsRepairCorrupted", | 547 source->AddString("extensionSettingsRepairCorrupted", |
| 536 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REPAIR_CORRUPTED)); | 548 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REPAIR_CORRUPTED)); |
| 537 source->AddString("extensionSettingsLaunch", | 549 source->AddString("extensionSettingsLaunch", |
| 538 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LAUNCH)); | 550 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LAUNCH)); |
| 539 source->AddString("extensionSettingsReloadUnpacked", | 551 source->AddString("extensionSettingsReloadUnpacked", |
| 540 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED)); | 552 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED)); |
| 541 source->AddString("extensionSettingsOptions", | 553 source->AddString("extensionSettingsOptions", |
| 542 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); | 554 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); |
| 543 if (CommandLine::ForCurrentProcess()->HasSwitch( | 555 if (ShouldDisplayExtensionInfoDialog()) { |
| 544 switches::kEnableExtensionInfoDialog)) { | |
| 545 source->AddString("extensionSettingsPermissions", | 556 source->AddString("extensionSettingsPermissions", |
| 546 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK)); | 557 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK)); |
| 547 } else { | 558 } else { |
| 548 source->AddString( | 559 source->AddString( |
| 549 "extensionSettingsPermissions", | 560 "extensionSettingsPermissions", |
| 550 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); | 561 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); |
| 551 } | 562 } |
| 552 source->AddString("extensionSettingsVisitWebsite", | 563 source->AddString("extensionSettingsVisitWebsite", |
| 553 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); | 564 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); |
| 554 source->AddString("extensionSettingsVisitWebStore", | 565 source->AddString("extensionSettingsVisitWebStore", |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 if (!extension) | 1206 if (!extension) |
| 1196 return; | 1207 return; |
| 1197 | 1208 |
| 1198 if (!extension_id_prompting_.empty()) | 1209 if (!extension_id_prompting_.empty()) |
| 1199 return; // Only one prompt at a time. | 1210 return; // Only one prompt at a time. |
| 1200 | 1211 |
| 1201 extension_id_prompting_ = extension->id(); | 1212 extension_id_prompting_ = extension->id(); |
| 1202 | 1213 |
| 1203 // Show the new-style extensions dialog when the flag is set. The flag cannot | 1214 // Show the new-style extensions dialog when the flag is set. The flag cannot |
| 1204 // be set on Mac platforms. | 1215 // be set on Mac platforms. |
| 1205 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1216 if (ShouldDisplayExtensionInfoDialog()) { |
| 1206 switches::kEnableExtensionInfoDialog)) { | |
| 1207 UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches", | 1217 UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches", |
| 1208 AppInfoLaunchSource::FROM_EXTENSIONS_PAGE, | 1218 AppInfoLaunchSource::FROM_EXTENSIONS_PAGE, |
| 1209 AppInfoLaunchSource::NUM_LAUNCH_SOURCES); | 1219 AppInfoLaunchSource::NUM_LAUNCH_SOURCES); |
| 1210 | 1220 |
| 1211 // Display the dialog at a size similar to the app list. | 1221 // Display the dialog at a size similar to the app list. |
| 1212 const int kAppInfoDialogWidth = 380; | 1222 const int kAppInfoDialogWidth = 380; |
| 1213 const int kAppInfoDialogHeight = 490; | 1223 const int kAppInfoDialogHeight = 490; |
| 1214 ShowAppInfoInNativeDialog( | 1224 ShowAppInfoInNativeDialog( |
| 1215 web_contents()->GetTopLevelNativeWindow(), | 1225 web_contents()->GetTopLevelNativeWindow(), |
| 1216 gfx::Size(kAppInfoDialogWidth, kAppInfoDialogHeight), | 1226 gfx::Size(kAppInfoDialogWidth, kAppInfoDialogHeight), |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 extension_service_->EnableExtension(extension_id); | 1512 extension_service_->EnableExtension(extension_id); |
| 1503 } else { | 1513 } else { |
| 1504 ExtensionErrorReporter::GetInstance()->ReportError( | 1514 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1505 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1515 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1506 true); // Be noisy. | 1516 true); // Be noisy. |
| 1507 } | 1517 } |
| 1508 requirements_checker_.reset(); | 1518 requirements_checker_.reset(); |
| 1509 } | 1519 } |
| 1510 | 1520 |
| 1511 } // namespace extensions | 1521 } // namespace extensions |
| OLD | NEW |