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

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

Issue 916073004: Plugin Power Saver: Migrate ASK to BLOCK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
9 9
10 PermissionMenuModel::PermissionMenuModel( 10 PermissionMenuModel::PermissionMenuModel(
11 const GURL& url, 11 const GURL& url,
12 const WebsiteSettingsUI::PermissionInfo& info, 12 const WebsiteSettingsUI::PermissionInfo& info,
13 const ChangeCallback& callback) 13 const ChangeCallback& callback)
14 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) { 14 : ui::SimpleMenuModel(this), permission_(info), callback_(callback) {
15 DCHECK(!callback_.is_null()); 15 DCHECK(!callback_.is_null());
16 base::string16 label; 16 base::string16 label;
17 switch (permission_.default_setting) { 17 switch (permission_.default_setting) {
18 case CONTENT_SETTING_ALLOW: 18 case CONTENT_SETTING_ALLOW:
19 label = l10n_util::GetStringUTF16( 19 label = l10n_util::GetStringUTF16(
20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); 20 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW);
21 break; 21 break;
22 case CONTENT_SETTING_BLOCK: 22 case CONTENT_SETTING_BLOCK:
23 label = l10n_util::GetStringUTF16( 23 label = l10n_util::GetStringUTF16(
24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); 24 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK);
25 break; 25 break;
26 case CONTENT_SETTING_ASK: 26 case CONTENT_SETTING_ASK:
27 // For Plugins, ASK is obsolete. Show as DETECT to reflect actual 27 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
28 // behavior.
29 label = l10n_util::GetStringUTF16( 28 label = l10n_util::GetStringUTF16(
30 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS 29 permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS
31 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT 30 ? IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK
32 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK); 31 : IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK);
33 break; 32 break;
34 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: 33 case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT:
35 label = l10n_util::GetStringUTF16( 34 label = l10n_util::GetStringUTF16(
36 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT); 35 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_DETECT_IMPORTANT_CONTENT);
37 break; 36 break;
38 case CONTENT_SETTING_NUM_SETTINGS: 37 case CONTENT_SETTING_NUM_SETTINGS:
39 NOTREACHED(); 38 NOTREACHED();
40 default: 39 default:
41 break; 40 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS; 72 permission_.default_setting = CONTENT_SETTING_NUM_SETTINGS;
74 AddCheckItem(CONTENT_SETTING_ALLOW, 73 AddCheckItem(CONTENT_SETTING_ALLOW,
75 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW)); 74 l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW));
76 AddCheckItem(CONTENT_SETTING_BLOCK, 75 AddCheckItem(CONTENT_SETTING_BLOCK,
77 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY)); 76 l10n_util::GetStringUTF16(IDS_PERMISSION_DENY));
78 } 77 }
79 78
80 PermissionMenuModel::~PermissionMenuModel() {} 79 PermissionMenuModel::~PermissionMenuModel() {}
81 80
82 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const { 81 bool PermissionMenuModel::IsCommandIdChecked(int command_id) const {
83 // For Plugins, ASK is obsolete. Show as DETECT to reflect actual behavior. 82 // For Plugins, ASK is obsolete. Show as BLOCK to reflect actual behavior.
84 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS && 83 if (permission_.type == CONTENT_SETTINGS_TYPE_PLUGINS &&
85 permission_.setting == CONTENT_SETTING_ASK && 84 permission_.setting == CONTENT_SETTING_ASK &&
86 command_id == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT) { 85 command_id == CONTENT_SETTING_BLOCK) {
87 return true; 86 return true;
88 } 87 }
89 return permission_.setting == command_id; 88 return permission_.setting == command_id;
90 } 89 }
91 90
92 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const { 91 bool PermissionMenuModel::IsCommandIdEnabled(int command_id) const {
93 return true; 92 return true;
94 } 93 }
95 94
96 bool PermissionMenuModel::GetAcceleratorForCommandId( 95 bool PermissionMenuModel::GetAcceleratorForCommandId(
97 int command_id, 96 int command_id,
98 ui::Accelerator* accelerator) { 97 ui::Accelerator* accelerator) {
99 // Accelerators are not supported. 98 // Accelerators are not supported.
100 return false; 99 return false;
101 } 100 }
102 101
103 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) { 102 void PermissionMenuModel::ExecuteCommand(int command_id, int event_flags) {
104 permission_.setting = static_cast<ContentSetting>(command_id); 103 permission_.setting = static_cast<ContentSetting>(command_id);
105 callback_.Run(permission_); 104 callback_.Run(permission_);
106 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_info_message_filter.cc ('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