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

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

Issue 1033103002: Plugin Power Saver: Overhaul plugin-power-saver flags. Show in UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/website_settings/permission_menu_model.h" 5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
6 6
7 #include "chrome/browser/plugins/plugins_field_trial.h"
7 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
9 10
10 PermissionMenuModel::PermissionMenuModel( 11 PermissionMenuModel::PermissionMenuModel(
11 const GURL& url, 12 const GURL& url,
12 const WebsiteSettingsUI::PermissionInfo& info, 13 const WebsiteSettingsUI::PermissionInfo& info,
13 const ChangeCallback& callback) 14 const ChangeCallback& callback)
14 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { 15 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) {
15 DCHECK(!callback_.is_null()); 16 DCHECK(!callback_.is_null());
16 base::string16 label; 17 base::string16 label;
17 switch (permission_.default_setting) { 18
19 ContentSetting effective_setting = permission_.setting;
20
21 #if defined(ENABLE_PLUGINS)
22 effective_setting = PluginsFieldTrial::EffectiveContentSetting(
23 permission_.type, permission_.setting);
24 #endif // defined(ENABLE_PLUGINS)
25
26 switch (effective_setting) {
18 case CONTENT_SETTING_ALLOW: 27 case CONTENT_SETTING_ALLOW:
19 label = l10n_util::GetStringUTF16( 28 label = l10n_util::GetStringUTF16(
20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); 29 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
21 break; 30 break;
22 case CONTENT_SETTING_BLOCK: 31 case CONTENT_SETTING_BLOCK:
23 label = l10n_util::GetStringUTF16( 32 label = l10n_util::GetStringUTF16(
24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); 33 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
25 break; 34 break;
26 case CONTENT_SETTING_ASK: 35 case CONTENT_SETTING_ASK:
27 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. 36 label =
28 label = l10n_util::GetStringUTF16( 37 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
29 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS
30 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK
31 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
32 break; 38 break;
33 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: 39 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
34 label = l10n_util::GetStringUTF16( 40 label = l10n_util::GetStringUTF16(
35 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT); 41 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT);
36 break; 42 break;
37 case CONTENT_SETTING_NUM_SETTINGS: 43 case CONTENT_SETTING_NUM_SETTINGS:
38 NOTREACHED(); 44 NOTREACHED();
39 default: 45 default:
40 break; 46 break;
41 } 47 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; 89 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS;
84 AddCheckItem(CONTENT_SETTING_ALLOW, 90 AddCheckItem(CONTENT_SETTING_ALLOW,
85 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); 91 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW));
86 AddCheckItem(CONTENT_SETTING_BLOCK, 92 AddCheckItem(CONTENT_SETTING_BLOCK,
87 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); 93 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY));
88 } 94 }
89 95
90 PermissionMenuModel::~PermissionMenuModel() {} 96 PermissionMenuModel::~PermissionMenuModel() {}
91 97
92 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { 98 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
93 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. 99 ContentSetting setting = permission_.setting;
94 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && 100
95 permission_.setting == CONTENT_SETTING_ASK && 101 #if defined(ENABLE_PLUGINS)
96 command_id == CONTENT_SETTING_BLOCK) { 102 setting = PluginsFieldTrial::EffectiveContentSetting(permission_.type,
97 return true; 103 permission_.setting);
98 } 104 #endif // defined(ENABLE_PLUGINS)
99 return permission_.setting == command_id; 105
106 return setting == command_id;
100 } 107 }
101 108
102 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 109 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
103 return true; 110 return true;
104 } 111 }
105 112
106 bool PermissionMenuModel::GetAcceleratorForCommandId( 113 bool PermissionMenuModel::GetAcceleratorForCommandId(
107 int command_id, 114 int command_id,
108 ui::Accelerator* accelerator) { 115 ui::Accelerator* accelerator) {
109 // Accelerators are not supported. 116 // Accelerators are not supported.
110 return false; 117 return false;
111 } 118 }
112 119
113 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 120 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
114 permission_.setting = static_cast<ContentSetting>(command_id); 121 permission_.setting = static_cast<ContentSetting>(command_id);
115 callback_.Run(permission_); 122 callback_.Run(permission_);
116 } 123 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings.js ('k') | chrome/browser/ui/website_settings/website_settings_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698