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

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: fix gypi i hope Created 5 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/website_settings/permission_menu_model.h" 5 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
6 6
7 #include "chrome/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "components/plugins/common/plugins_field_trial.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 switch (permission_.default_setting) {
18 case CONTENT_SETTING_ALLOW: 19 case CONTENT_SETTING_ALLOW:
19 label = l10n_util::GetStringUTF16( 20 // For Plugins, allow flag to override displayed content setting.
20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); 21 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
22 PluginsFieldTrial::EnableForcePluginPowerSaver()) {
23 label = l10n_util::GetStringUTF16(
24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT);
25 } else {
26 label = l10n_util::GetStringUTF16(
27 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
28 }
21 break; 29 break;
22 case CONTENT_SETTING_BLOCK: 30 case CONTENT_SETTING_BLOCK:
23 label = l10n_util::GetStringUTF16( 31 label = l10n_util::GetStringUTF16(
24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); 32 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
25 break; 33 break;
26 case CONTENT_SETTING_ASK: 34 case CONTENT_SETTING_ASK:
27 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. 35 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
28 label = l10n_util::GetStringUTF16( 36 label = l10n_util::GetStringUTF16(
29 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS 37 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS
30 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK 38 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; 91 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS;
84 AddCheckItem(CONTENT_SETTING_ALLOW, 92 AddCheckItem(CONTENT_SETTING_ALLOW,
85 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); 93 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW));
86 AddCheckItem(CONTENT_SETTING_BLOCK, 94 AddCheckItem(CONTENT_SETTING_BLOCK,
87 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); 95 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY));
88 } 96 }
89 97
90 PermissionMenuModel::~PermissionMenuModel() {} 98 PermissionMenuModel::~PermissionMenuModel() {}
91 99
92 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { 100 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
93 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior. 101 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS) {
groby-ooo-7-16 2015/03/27 23:12:32 That logic is used several places. Worth factoring
tommycli 2015/03/28 00:40:04 Done. Seems better now. I was actually skeptical o
94 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && 102 // For Plugins, allow flag to override displayed content setting.
95 permission_.setting == CONTENT_SETTING_ASK && 103 if (permission_.setting == CONTENT_SETTING_ALLOW &&
96 command_id == CONTENT_SETTING_BLOCK) { 104 PluginsFieldTrial::EnableForcePluginPowerSaver()) {
97 return true; 105 return command_id == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT;
106 }
107
108 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
109 if (permission_.setting == CONTENT_SETTING_ASK &&
110 command_id == CONTENT_SETTING_BLOCK) {
111 return true;
112 }
98 } 113 }
114
99 return permission_.setting == command_id; 115 return permission_.setting == command_id;
100 } 116 }
101 117
102 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 118 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
103 return true; 119 return true;
104 } 120 }
105 121
106 bool PermissionMenuModel::GetAcceleratorForCommandId( 122 bool PermissionMenuModel::GetAcceleratorForCommandId(
107 int command_id, 123 int command_id,
108 ui::Accelerator* accelerator) { 124 ui::Accelerator* accelerator) {
109 // Accelerators are not supported. 125 // Accelerators are not supported.
110 return false; 126 return false;
111 } 127 }
112 128
113 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 129 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
114 permission_.setting = static_cast<ContentSetting>(command_id); 130 permission_.setting = static_cast<ContentSetting>(command_id);
115 callback_.Run(permission_); 131 callback_.Run(permission_);
116 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698