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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings_bubble_controller.mm

Issue 11571010: fixed the DCHECK and also corrected the website setting UI for media (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed the DCHECK part code, and added allow support to media for https Created 8 years 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 | Annotate | Revision Log
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 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import <AppKit/AppKit.h> 9 #import <AppKit/AppKit.h>
10 10
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 865 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
866 [button setBordered:NO]; 866 [button setBordered:NO];
867 [[button cell] setControlSize:NSSmallControlSize]; 867 [[button cell] setControlSize:NSSmallControlSize];
868 [button setTag:permissionInfo.type]; 868 [button setTag:permissionInfo.type];
869 [button setAction:@selector(permissionValueChanged:)]; 869 [button setAction:@selector(permissionValueChanged:)];
870 [button setTarget:self]; 870 [button setTarget:self];
871 871
872 // Create the popup menu. 872 // Create the popup menu.
873 // TODO(dubroy): Refactor this code to use PermissionMenuModel. 873 // TODO(dubroy): Refactor this code to use PermissionMenuModel.
874 874
875 // Media stream permission does not support "Always allow". 875 bool secure_scheme = webContents_->GetURL().SchemeIsSecure();
markusheintz_ 2012/12/14 15:46:43 nit: I think we could inline this.
no longer working on chromium 2012/12/14 15:56:19 this secure_scheme is used in two places, and it i
markusheintz_ 2012/12/14 16:12:09 If we keep using it in two places then ignore this
876 // TODO(xians): Media supports "allow" for https but not for http. 876 // Media stream permission only support "Always allow" for https.
877 if (permissionInfo.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 877 if (permissionInfo.type != CONTENT_SETTINGS_TYPE_MEDIASTREAM ||
878 secure_scheme) {
878 [button addItemWithTitle: 879 [button addItemWithTitle:
879 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW)]; 880 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW)];
880 [[button lastItem] setTag:CONTENT_SETTING_ALLOW]; 881 [[button lastItem] setTag:CONTENT_SETTING_ALLOW];
881 } 882 }
882 883
883 // Fullscreen does not support "Always block". 884 // Fullscreen does not support "Always block".
884 if (permissionInfo.type != CONTENT_SETTINGS_TYPE_FULLSCREEN) { 885 if (permissionInfo.type != CONTENT_SETTINGS_TYPE_FULLSCREEN) {
885 [button addItemWithTitle: 886 [button addItemWithTitle:
886 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK)]; 887 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK)];
887 [[button lastItem] setTag:CONTENT_SETTING_BLOCK]; 888 [[button lastItem] setTag:CONTENT_SETTING_BLOCK];
888 } 889 }
889 890
890 [button addItemWithTitle:l10n_util::GetNSStringF( 891 [button addItemWithTitle:l10n_util::GetNSStringF(
891 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL, 892 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL,
892 WebsiteSettingsUI::PermissionValueToUIString( 893 WebsiteSettingsUI::PermissionValueToUIString(
893 permissionInfo.default_setting))]; 894 permissionInfo.default_setting))];
894 [[button lastItem] setTag:CONTENT_SETTING_DEFAULT]; 895 [[button lastItem] setTag:CONTENT_SETTING_DEFAULT];
895 896
896 [button selectItemWithTag:permissionInfo.setting]; 897 if (permissionInfo.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM &&
markusheintz_ 2012/12/14 15:46:43 Can this condition ever be true while the conditi
no longer working on chromium 2012/12/14 15:56:19 line 877 decides if it will add a "allow" button t
markusheintz_ 2012/12/14 16:12:09 But the permission should never be ALLOW for an ht
898 !secure_scheme &&
899 permissionInfo.setting == CONTENT_SETTING_ALLOW) {
900 // Select the default setting as the current setting since MEDIASTREAM
901 // does not support allow for http.
902 [button selectItemWithTag:CONTENT_SETTING_DEFAULT];
903 } else {
904 [button selectItemWithTag:permissionInfo.setting];
905 }
897 906
898 // Set the button title. 907 // Set the button title.
899 scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]); 908 scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]);
900 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString( 909 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString(
901 permissionInfo.setting, 910 permissionInfo.setting,
902 permissionInfo.default_setting, 911 permissionInfo.default_setting,
903 permissionInfo.source); 912 permissionInfo.source);
904 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)]; 913 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)];
905 [[button cell] setUsesItemFromMenu:NO]; 914 [[button cell] setUsesItemFromMenu:NO];
906 [[button cell] setMenuItem:titleItem.get()]; 915 [[button cell] setMenuItem:titleItem.get()];
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 [bubble_controller_ setPermissionInfo:permission_info_list]; 1241 [bubble_controller_ setPermissionInfo:permission_info_list];
1233 } 1242 }
1234 1243
1235 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { 1244 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) {
1236 [bubble_controller_ setFirstVisit:first_visit]; 1245 [bubble_controller_ setFirstVisit:first_visit];
1237 } 1246 }
1238 1247
1239 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1248 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1240 [bubble_controller_ setSelectedTab:tab_id]; 1249 [bubble_controller_ setSelectedTab:tab_id];
1241 } 1250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698