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

Side by Side Diff: chrome/browser/ui/page_info/permission_menu_model.cc

Issue 2754383004: Rename WebsiteSettings code to PageInfo. (Closed)
Patch Set: Created 3 years, 9 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
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/page_info/permission_menu_model.h" 5 #include "chrome/browser/ui/page_info/permission_menu_model.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/plugins/plugin_utils.h" 8 #include "chrome/browser/plugins/plugin_utils.h"
9 #include "chrome/browser/plugins/plugins_field_trial.h" 9 #include "chrome/browser/plugins/plugins_field_trial.h"
10 #include "chrome/common/chrome_features.h" 10 #include "chrome/common/chrome_features.h"
11 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
12 #include "content/public/common/origin_util.h" 12 #include "content/public/common/origin_util.h"
13 #include "ppapi/features/features.h" 13 #include "ppapi/features/features.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/material_design/material_design_controller.h" 15 #include "ui/base/material_design/material_design_controller.h"
16 16
17 PermissionMenuModel::PermissionMenuModel( 17 PermissionMenuModel::PermissionMenuModel(Profile* profile,
18 Profile* profile, 18 const GURL& url,
19 const GURL& url, 19 const PageInfoUI::PermissionInfo& info,
20 const WebsiteSettingsUI::PermissionInfo& info, 20 const ChangeCallback& callback)
21 const ChangeCallback& callback)
22 : ui::SimpleMenuModel(this), 21 : ui::SimpleMenuModel(this),
23 host_content_settings_map_( 22 host_content_settings_map_(
24 HostContentSettingsMapFactory::GetForProfile(profile)), 23 HostContentSettingsMapFactory::GetForProfile(profile)),
25 permission_(info), 24 permission_(info),
26 callback_(callback) { 25 callback_(callback) {
27 DCHECK(!callback_.is_null()); 26 DCHECK(!callback_.is_null());
28 base::string16 label; 27 base::string16 label;
29 28
30 // Retrieve the string to show for the default setting for this permission. 29 // Retrieve the string to show for the default setting for this permission.
31 ContentSetting effective_default_setting = permission_.default_setting; 30 ContentSetting effective_default_setting = permission_.default_setting;
(...skipping 29 matching lines...) Expand all
61 case CONTENT_SETTING_NUM_SETTINGS: 60 case CONTENT_SETTING_NUM_SETTINGS:
62 NOTREACHED(); 61 NOTREACHED();
63 default: 62 default:
64 break; 63 break;
65 } 64 }
66 65
67 // The Material UI for site settings uses comboboxes instead of menubuttons, 66 // The Material UI for site settings uses comboboxes instead of menubuttons,
68 // which means the elements of the menu themselves have to be shorter, instead 67 // which means the elements of the menu themselves have to be shorter, instead
69 // of simply setting a shorter label on the menubutton. 68 // of simply setting a shorter label on the menubutton.
70 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 69 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
71 label = WebsiteSettingsUI::PermissionActionToUIString( 70 label = PageInfoUI::PermissionActionToUIString(
72 profile, permission_.type, CONTENT_SETTING_DEFAULT, 71 profile, permission_.type, CONTENT_SETTING_DEFAULT,
73 effective_default_setting, permission_.source); 72 effective_default_setting, permission_.source);
74 } 73 }
75 74
76 AddCheckItem(CONTENT_SETTING_DEFAULT, label); 75 AddCheckItem(CONTENT_SETTING_DEFAULT, label);
77 76
78 // Retrieve the string to show for allowing the permission. 77 // Retrieve the string to show for allowing the permission.
79 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. 78 // Notifications does not support CONTENT_SETTING_ALLOW in incognito.
80 bool allow_disabled_for_notifications = 79 bool allow_disabled_for_notifications =
81 permission_.is_incognito && 80 permission_.is_incognito &&
82 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 81 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
83 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. 82 // Media only supports CONTENT_SETTTING_ALLOW for secure origins.
84 bool is_media_permission = 83 bool is_media_permission =
85 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 84 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
86 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; 85 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
87 if (!allow_disabled_for_notifications && 86 if (!allow_disabled_for_notifications &&
88 (!is_media_permission || content::IsOriginSecure(url))) { 87 (!is_media_permission || content::IsOriginSecure(url))) {
89 label = l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); 88 label = l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW);
90 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 89 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
91 label = WebsiteSettingsUI::PermissionActionToUIString( 90 label = PageInfoUI::PermissionActionToUIString(
92 profile, permission_.type, CONTENT_SETTING_ALLOW, 91 profile, permission_.type, CONTENT_SETTING_ALLOW,
93 effective_default_setting, permission_.source); 92 effective_default_setting, permission_.source);
94 } 93 }
95 AddCheckItem(CONTENT_SETTING_ALLOW, label); 94 AddCheckItem(CONTENT_SETTING_ALLOW, label);
96 } 95 }
97 96
98 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the 97 // TODO(tommycli): With the HTML5 by Default feature, Flash is treated the
99 // same as any other permission with ASK, i.e. there is no ASK exception. 98 // same as any other permission with ASK, i.e. there is no ASK exception.
100 // Once the feature flag is gone, remove this block of code entirely. 99 // Once the feature flag is gone, remove this block of code entirely.
101 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && 100 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
102 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) { 101 !PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)) {
103 label = l10n_util::GetStringUTF16( 102 label = l10n_util::GetStringUTF16(
104 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT); 103 IDS_WEBSITE_SETTINGS_MENU_ITEM_DETECT_IMPORTANT_CONTENT);
105 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label); 104 AddCheckItem(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, label);
106 } 105 }
107 106
108 // Retrieve the string to show for blocking the permission. 107 // Retrieve the string to show for blocking the permission.
109 label = l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK); 108 label = l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK);
110 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 109 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
111 label = WebsiteSettingsUI::PermissionActionToUIString( 110 label = PageInfoUI::PermissionActionToUIString(
112 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, 111 profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting,
113 info.source); 112 info.source);
114 } 113 }
115 AddCheckItem(CONTENT_SETTING_BLOCK, label); 114 AddCheckItem(CONTENT_SETTING_BLOCK, label);
116 } 115 }
117 116
118 PermissionMenuModel::PermissionMenuModel(Profile* profile, 117 PermissionMenuModel::PermissionMenuModel(Profile* profile,
119 const GURL& url, 118 const GURL& url,
120 ContentSetting setting, 119 ContentSetting setting,
121 const ChangeCallback& callback) 120 const ChangeCallback& callback)
(...skipping 25 matching lines...) Expand all
147 } 146 }
148 147
149 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 148 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
150 return true; 149 return true;
151 } 150 }
152 151
153 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 152 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
154 permission_.setting = static_cast<ContentSetting>(command_id); 153 permission_.setting = static_cast<ContentSetting>(command_id);
155 callback_.Run(permission_); 154 callback_.Run(permission_);
156 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698