Chromium Code Reviews| 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 bool display_extension_info_dialog = false; | |
| 119 #if !defined(OS_MACOSX) | |
| 120 display_extension_info_dialog = !CommandLine::ForCurrentProcess()->HasSwitch( | |
|
Lei Zhang
2014/10/22 20:03:40
nit: base::CommandLine
| |
| 121 extensions::switches::kDisableExtensionInfoDialog); | |
| 122 #endif | |
| 123 return display_extension_info_dialog; | |
| 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 source->AddString("extensionSettingsReloadTerminated", | 543 source->AddString("extensionSettingsReloadTerminated", |
| 531 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_TERMINATED)); | 544 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_TERMINATED)); |
| 532 source->AddString("extensionSettingsRepairCorrupted", | 545 source->AddString("extensionSettingsRepairCorrupted", |
| 533 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REPAIR_CORRUPTED)); | 546 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REPAIR_CORRUPTED)); |
| 534 source->AddString("extensionSettingsLaunch", | 547 source->AddString("extensionSettingsLaunch", |
| 535 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LAUNCH)); | 548 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LAUNCH)); |
| 536 source->AddString("extensionSettingsReloadUnpacked", | 549 source->AddString("extensionSettingsReloadUnpacked", |
| 537 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED)); | 550 l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED)); |
| 538 source->AddString("extensionSettingsOptions", | 551 source->AddString("extensionSettingsOptions", |
| 539 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); | 552 l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK)); |
| 540 if (CommandLine::ForCurrentProcess()->HasSwitch( | 553 if (ShouldDisplayExtensionInfoDialog()) { |
| 541 switches::kEnableExtensionInfoDialog)) { | |
| 542 source->AddString("extensionSettingsPermissions", | 554 source->AddString("extensionSettingsPermissions", |
| 543 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK)); | 555 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK)); |
| 544 } else { | 556 } else { |
| 545 source->AddString( | 557 source->AddString( |
| 546 "extensionSettingsPermissions", | 558 "extensionSettingsPermissions", |
| 547 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); | 559 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK)); |
| 548 } | 560 } |
| 549 source->AddString("extensionSettingsVisitWebsite", | 561 source->AddString("extensionSettingsVisitWebsite", |
| 550 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); | 562 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); |
| 551 source->AddString("extensionSettingsVisitWebStore", | 563 source->AddString("extensionSettingsVisitWebStore", |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1192 if (!extension) | 1204 if (!extension) |
| 1193 return; | 1205 return; |
| 1194 | 1206 |
| 1195 if (!extension_id_prompting_.empty()) | 1207 if (!extension_id_prompting_.empty()) |
| 1196 return; // Only one prompt at a time. | 1208 return; // Only one prompt at a time. |
| 1197 | 1209 |
| 1198 extension_id_prompting_ = extension->id(); | 1210 extension_id_prompting_ = extension->id(); |
| 1199 | 1211 |
| 1200 // Show the new-style extensions dialog when the flag is set. The flag cannot | 1212 // Show the new-style extensions dialog when the flag is set. The flag cannot |
| 1201 // be set on Mac platforms. | 1213 // be set on Mac platforms. |
| 1202 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1214 if (ShouldDisplayExtensionInfoDialog()) { |
| 1203 switches::kEnableExtensionInfoDialog)) { | |
| 1204 UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches", | 1215 UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches", |
| 1205 AppInfoLaunchSource::FROM_EXTENSIONS_PAGE, | 1216 AppInfoLaunchSource::FROM_EXTENSIONS_PAGE, |
| 1206 AppInfoLaunchSource::NUM_LAUNCH_SOURCES); | 1217 AppInfoLaunchSource::NUM_LAUNCH_SOURCES); |
| 1207 | 1218 |
| 1208 // Display the dialog at a size similar to the app list. | 1219 // Display the dialog at a size similar to the app list. |
| 1209 const int kAppInfoDialogWidth = 380; | 1220 const int kAppInfoDialogWidth = 380; |
| 1210 const int kAppInfoDialogHeight = 490; | 1221 const int kAppInfoDialogHeight = 490; |
| 1211 ShowAppInfoInNativeDialog( | 1222 ShowAppInfoInNativeDialog( |
| 1212 web_contents()->GetTopLevelNativeWindow(), | 1223 web_contents()->GetTopLevelNativeWindow(), |
| 1213 gfx::Size(kAppInfoDialogWidth, kAppInfoDialogHeight), | 1224 gfx::Size(kAppInfoDialogWidth, kAppInfoDialogHeight), |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1499 extension_service_->EnableExtension(extension_id); | 1510 extension_service_->EnableExtension(extension_id); |
| 1500 } else { | 1511 } else { |
| 1501 ExtensionErrorReporter::GetInstance()->ReportError( | 1512 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1502 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1513 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1503 true); // Be noisy. | 1514 true); // Be noisy. |
| 1504 } | 1515 } |
| 1505 requirements_checker_.reset(); | 1516 requirements_checker_.reset(); |
| 1506 } | 1517 } |
| 1507 | 1518 |
| 1508 } // namespace extensions | 1519 } // namespace extensions |
| OLD | NEW |