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

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

Issue 2715233004: views: use shorter menu strings in Harmony website settings (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
« no previous file with comments | « chrome/browser/ui/views/website_settings/permission_selector_row.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/website_settings/permission_menu_model.h" 5 #include "chrome/browser/ui/website_settings/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 16
16 PermissionMenuModel::PermissionMenuModel( 17 PermissionMenuModel::PermissionMenuModel(
17 Profile* profile, 18 Profile* profile,
18 const GURL& url, 19 const GURL& url,
19 const WebsiteSettingsUI::PermissionInfo& info, 20 const WebsiteSettingsUI::PermissionInfo& info,
20 const ChangeCallback& callback) 21 const ChangeCallback& callback)
21 : ui::SimpleMenuModel(this), 22 : ui::SimpleMenuModel(this),
22 host_content_settings_map_( 23 host_content_settings_map_(
23 HostContentSettingsMapFactory::GetForProfile(profile)), 24 HostContentSettingsMapFactory::GetForProfile(profile)),
24 permission_(info), 25 permission_(info),
(...skipping 29 matching lines...) Expand all
54 label = l10n_util::GetStringUTF16( 55 label = l10n_util::GetStringUTF16(
55 PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_) 56 PluginUtils::ShouldPreferHtmlOverPlugins(host_content_settings_map_)
56 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK 57 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK
57 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT) ; 58 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT) ;
58 break; 59 break;
59 case CONTENT_SETTING_NUM_SETTINGS: 60 case CONTENT_SETTING_NUM_SETTINGS:
60 NOTREACHED(); 61 NOTREACHED();
61 default: 62 default:
62 break; 63 break;
63 } 64 }
65
66 // The Material UI for site settings uses comboboxes instead of menubuttons,
67 // which means the elements of the menu themselves have to be shorter, instead
68 // of simply setting a shorter label on the menubutton.
69 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
70 label = WebsiteSettingsUI::PermissionActionToUIString(
71 profile, info.type, info.setting, effective_default_setting,
72 info.source);
73 }
74
64 AddCheckItem(CONTENT_SETTING_DEFAULT, label); 75 AddCheckItem(CONTENT_SETTING_DEFAULT, label);
65 76
66 // Notifications does not support CONTENT_SETTING_ALLOW in incognito. 77 // Notifications does not support CONTENT_SETTING_ALLOW in incognito.
67 bool allow_disabled_for_notifications = 78 bool allow_disabled_for_notifications =
68 permission_.is_incognito && 79 permission_.is_incognito &&
69 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 80 permission_.type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
70 // Media only supports CONTENT_SETTTING_ALLOW for secure origins. 81 // Media only supports CONTENT_SETTTING_ALLOW for secure origins.
71 bool is_media_permission = 82 bool is_media_permission =
72 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 83 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
73 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; 84 permission_.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 135 }
125 136
126 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 137 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
127 return true; 138 return true;
128 } 139 }
129 140
130 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 141 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
131 permission_.setting = static_cast<ContentSetting>(command_id); 142 permission_.setting = static_cast<ContentSetting>(command_id);
132 callback_.Run(permission_); 143 callback_.Run(permission_);
133 } 144 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/permission_selector_row.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698