OLD | NEW |
---|---|
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/webui/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
6 | 6 |
7 #include <algorithm> | |
7 #include <map> | 8 #include <map> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/strings/string_number_conversions.h" | |
14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 17 #include "base/values.h" |
16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/content_settings/content_settings_details.h" | 20 #include "chrome/browser/content_settings/content_settings_details.h" |
19 #include "chrome/browser/content_settings/content_settings_utils.h" | 21 #include "chrome/browser/content_settings/content_settings_utils.h" |
20 #include "chrome/browser/content_settings/host_content_settings_map.h" | 22 #include "chrome/browser/content_settings/host_content_settings_map.h" |
21 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 23 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
22 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 24 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 26 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
25 #include "chrome/browser/google/google_util.h" | 27 #include "chrome/browser/google/google_util.h" |
26 #include "chrome/browser/notifications/desktop_notification_service.h" | 28 #include "chrome/browser/notifications/desktop_notification_service.h" |
27 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 29 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
28 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/content_settings.h" | 33 #include "chrome/common/content_settings.h" |
32 #include "chrome/common/content_settings_pattern.h" | 34 #include "chrome/common/content_settings_pattern.h" |
33 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
34 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
35 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
36 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
38 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
39 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
40 #include "content/public/browser/web_ui.h" | 42 #include "content/public/browser/web_ui.h" |
41 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/page_zoom.h" | |
42 #include "extensions/common/extension_set.h" | 45 #include "extensions/common/extension_set.h" |
43 #include "extensions/common/permissions/api_permission.h" | 46 #include "extensions/common/permissions/api_permission.h" |
44 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
45 #include "grit/locale_settings.h" | 48 #include "grit/locale_settings.h" |
46 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
47 | 50 |
48 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
49 #include "chrome/browser/chromeos/login/user_manager.h" | 52 #include "chrome/browser/chromeos/login/user_manager.h" |
50 #endif | 53 #endif |
51 | 54 |
(...skipping 24 matching lines...) Expand all Loading... | |
76 "https://support.google.com/chrome/?p=settings_manage_exceptions"; | 79 "https://support.google.com/chrome/?p=settings_manage_exceptions"; |
77 | 80 |
78 const char* kSetting = "setting"; | 81 const char* kSetting = "setting"; |
79 const char* kOrigin = "origin"; | 82 const char* kOrigin = "origin"; |
80 const char* kSource = "source"; | 83 const char* kSource = "source"; |
81 const char* kAppName = "appName"; | 84 const char* kAppName = "appName"; |
82 const char* kAppId = "appId"; | 85 const char* kAppId = "appId"; |
83 const char* kEmbeddingOrigin = "embeddingOrigin"; | 86 const char* kEmbeddingOrigin = "embeddingOrigin"; |
84 const char* kPreferencesSource = "preference"; | 87 const char* kPreferencesSource = "preference"; |
85 const char* kVideoSetting = "video"; | 88 const char* kVideoSetting = "video"; |
89 const char* kZoom = "zoom"; | |
86 | 90 |
87 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { | 91 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { |
88 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, | 92 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, |
89 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, | 93 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, |
90 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, | 94 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, |
91 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, | 95 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, |
92 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, | 96 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, |
93 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, | 97 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, |
94 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, | 98 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, |
95 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, | 99 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, |
96 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, | 100 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, |
97 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, | 101 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, |
98 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"}, | 102 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"}, |
99 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "media-stream"}, | 103 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, "media-stream"}, |
100 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"}, | 104 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"}, |
101 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"}, | 105 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"}, |
102 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"}, | 106 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"}, |
103 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"}, | 107 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"}, |
104 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, | 108 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, |
105 #if defined(OS_CHROMEOS) | 109 #if defined(OS_CHROMEOS) |
106 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, | 110 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, |
107 #endif | 111 #endif |
108 }; | 112 }; |
109 | 113 |
114 // A pseudo content type. We use it to display data like a content setting even | |
115 // though it is not a real content setting. | |
116 const char* kZoomContentType = "zoomlevels"; | |
117 | |
110 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { | 118 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { |
111 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 119 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
112 if (name == kContentSettingsTypeGroupNames[i].name) | 120 if (name == kContentSettingsTypeGroupNames[i].name) |
113 return kContentSettingsTypeGroupNames[i].type; | 121 return kContentSettingsTypeGroupNames[i].type; |
114 } | 122 } |
115 | 123 |
116 NOTREACHED() << name << " is not a recognized content settings type."; | 124 NOTREACHED() << name << " is not a recognized content settings type."; |
117 return CONTENT_SETTINGS_TYPE_DEFAULT; | 125 return CONTENT_SETTINGS_TYPE_DEFAULT; |
118 } | 126 } |
119 | 127 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 // Retrieve the launch URL. | 251 // Retrieve the launch URL. |
244 GURL launch_url = | 252 GURL launch_url = |
245 extensions::AppLaunchInfo::GetLaunchWebURL(extension->get()); | 253 extensions::AppLaunchInfo::GetLaunchWebURL(extension->get()); |
246 // Skip adding the launch URL if it is part of the web extent. | 254 // Skip adding the launch URL if it is part of the web extent. |
247 if (web_extent.MatchesURL(launch_url)) | 255 if (web_extent.MatchesURL(launch_url)) |
248 continue; | 256 continue; |
249 AddExceptionForHostedApp(launch_url.spec(), *extension->get(), exceptions); | 257 AddExceptionForHostedApp(launch_url.spec(), *extension->get(), exceptions); |
250 } | 258 } |
251 } | 259 } |
252 | 260 |
261 // Sort ZoomLevelChanges by host and scheme | |
262 // (a.com < http://a.com < https://a.com < b.com) | |
263 bool ZoomLevelChangeLessThan(const content::HostZoomMap::ZoomLevelChange& a, | |
264 const content::HostZoomMap::ZoomLevelChange& b) { | |
265 if (a.host < b.host) | |
266 return true; | |
267 if (a.host > b.host) | |
268 return false; | |
269 return a.scheme < b.scheme; | |
270 } | |
271 | |
253 } // namespace | 272 } // namespace |
254 | 273 |
255 namespace options { | 274 namespace options { |
256 | 275 |
257 ContentSettingsHandler::MediaSettingsInfo::MediaSettingsInfo() | 276 ContentSettingsHandler::MediaSettingsInfo::MediaSettingsInfo() |
258 : flash_default_setting(CONTENT_SETTING_DEFAULT), | 277 : flash_default_setting(CONTENT_SETTING_DEFAULT), |
259 flash_settings_initialized(false), | 278 flash_settings_initialized(false), |
260 last_flash_refresh_request_id(0), | 279 last_flash_refresh_request_id(0), |
261 show_flash_default_link(false), | 280 show_flash_default_link(false), |
262 show_flash_exceptions_link(false), | 281 show_flash_exceptions_link(false), |
(...skipping 21 matching lines...) Expand all Loading... | |
284 { "allowException", IDS_EXCEPTIONS_ALLOW_BUTTON }, | 303 { "allowException", IDS_EXCEPTIONS_ALLOW_BUTTON }, |
285 { "blockException", IDS_EXCEPTIONS_BLOCK_BUTTON }, | 304 { "blockException", IDS_EXCEPTIONS_BLOCK_BUTTON }, |
286 { "sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON }, | 305 { "sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON }, |
287 { "askException", IDS_EXCEPTIONS_ASK_BUTTON }, | 306 { "askException", IDS_EXCEPTIONS_ASK_BUTTON }, |
288 { "otr_exceptions_explanation", IDS_EXCEPTIONS_OTR_LABEL }, | 307 { "otr_exceptions_explanation", IDS_EXCEPTIONS_OTR_LABEL }, |
289 { "addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS }, | 308 { "addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS }, |
290 { "manageExceptions", IDS_EXCEPTIONS_MANAGE }, | 309 { "manageExceptions", IDS_EXCEPTIONS_MANAGE }, |
291 { "manage_handlers", IDS_HANDLERS_MANAGE }, | 310 { "manage_handlers", IDS_HANDLERS_MANAGE }, |
292 { "exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER }, | 311 { "exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER }, |
293 { "exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER }, | 312 { "exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER }, |
313 { "exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER }, | |
294 { "embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST }, | 314 { "embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST }, |
295 // Cookies filter. | 315 // Cookies filter. |
296 { "cookies_tab_label", IDS_COOKIES_TAB_LABEL }, | 316 { "cookies_tab_label", IDS_COOKIES_TAB_LABEL }, |
297 { "cookies_header", IDS_COOKIES_HEADER }, | 317 { "cookies_header", IDS_COOKIES_HEADER }, |
298 { "cookies_allow", IDS_COOKIES_ALLOW_RADIO }, | 318 { "cookies_allow", IDS_COOKIES_ALLOW_RADIO }, |
299 { "cookies_block", IDS_COOKIES_BLOCK_RADIO }, | 319 { "cookies_block", IDS_COOKIES_BLOCK_RADIO }, |
300 { "cookies_session_only", IDS_COOKIES_SESSION_ONLY_RADIO }, | 320 { "cookies_session_only", IDS_COOKIES_SESSION_ONLY_RADIO }, |
301 { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX }, | 321 { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX }, |
302 { "cookies_clear_when_close", IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX }, | 322 { "cookies_clear_when_close", IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX }, |
303 { "cookies_lso_clear_when_close", IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX }, | 323 { "cookies_lso_clear_when_close", IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX }, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 IDS_AUTOMATIC_DOWNLOADS_ALLOW_RADIO }, | 413 IDS_AUTOMATIC_DOWNLOADS_ALLOW_RADIO }, |
394 { "multiple-automatic-downloads_ask", | 414 { "multiple-automatic-downloads_ask", |
395 IDS_AUTOMATIC_DOWNLOADS_ASK_RADIO }, | 415 IDS_AUTOMATIC_DOWNLOADS_ASK_RADIO }, |
396 { "multiple-automatic-downloads_block", | 416 { "multiple-automatic-downloads_block", |
397 IDS_AUTOMATIC_DOWNLOADS_BLOCK_RADIO }, | 417 IDS_AUTOMATIC_DOWNLOADS_BLOCK_RADIO }, |
398 // MIDI system exclusive messages | 418 // MIDI system exclusive messages |
399 { "midi-sysex_header", IDS_MIDI_SYSEX_TAB_LABEL }, | 419 { "midi-sysex_header", IDS_MIDI_SYSEX_TAB_LABEL }, |
400 { "midiSysExAllow", IDS_MIDI_SYSEX_ALLOW_RADIO }, | 420 { "midiSysExAllow", IDS_MIDI_SYSEX_ALLOW_RADIO }, |
401 { "midiSysExAsk", IDS_MIDI_SYSEX_ASK_RADIO }, | 421 { "midiSysExAsk", IDS_MIDI_SYSEX_ASK_RADIO }, |
402 { "midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO }, | 422 { "midiSysExBlock", IDS_MIDI_SYSEX_BLOCK_RADIO }, |
423 { "zoomlevels_header", IDS_ZOOMLEVELS_HEADER }, | |
424 { "zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON }, | |
403 }; | 425 }; |
404 | 426 |
405 RegisterStrings(localized_strings, resources, arraysize(resources)); | 427 RegisterStrings(localized_strings, resources, arraysize(resources)); |
406 RegisterTitle(localized_strings, "contentSettingsPage", | 428 RegisterTitle(localized_strings, "contentSettingsPage", |
407 IDS_CONTENT_SETTINGS_TITLE); | 429 IDS_CONTENT_SETTINGS_TITLE); |
408 | 430 |
409 // Register titles for each of the individual settings whose exception | 431 // Register titles for each of the individual settings whose exception |
410 // dialogs will be processed by |ContentSettingsHandler|. | 432 // dialogs will be processed by |ContentSettingsHandler|. |
411 RegisterTitle(localized_strings, "cookies", | 433 RegisterTitle(localized_strings, "cookies", |
412 IDS_COOKIES_TAB_LABEL); | 434 IDS_COOKIES_TAB_LABEL); |
(...skipping 18 matching lines...) Expand all Loading... | |
431 IDS_PROTECTED_CONTENT_TAB_LABEL); | 453 IDS_PROTECTED_CONTENT_TAB_LABEL); |
432 #endif | 454 #endif |
433 RegisterTitle(localized_strings, "media-stream", | 455 RegisterTitle(localized_strings, "media-stream", |
434 IDS_MEDIA_STREAM_TAB_LABEL); | 456 IDS_MEDIA_STREAM_TAB_LABEL); |
435 RegisterTitle(localized_strings, "ppapi-broker", | 457 RegisterTitle(localized_strings, "ppapi-broker", |
436 IDS_PPAPI_BROKER_TAB_LABEL); | 458 IDS_PPAPI_BROKER_TAB_LABEL); |
437 RegisterTitle(localized_strings, "multiple-automatic-downloads", | 459 RegisterTitle(localized_strings, "multiple-automatic-downloads", |
438 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); | 460 IDS_AUTOMATIC_DOWNLOADS_TAB_LABEL); |
439 RegisterTitle(localized_strings, "midi-sysex", | 461 RegisterTitle(localized_strings, "midi-sysex", |
440 IDS_MIDI_SYSEX_TAB_LABEL); | 462 IDS_MIDI_SYSEX_TAB_LABEL); |
463 RegisterTitle(localized_strings, "zoomlevels", | |
464 IDS_ZOOMLEVELS_TAB_LABEL); | |
441 | 465 |
442 localized_strings->SetBoolean("newContentSettings", | 466 localized_strings->SetBoolean("newContentSettings", |
443 CommandLine::ForCurrentProcess()->HasSwitch(switches::kContentSettings2)); | 467 CommandLine::ForCurrentProcess()->HasSwitch(switches::kContentSettings2)); |
444 localized_strings->SetString( | 468 localized_strings->SetString( |
445 "exceptionsLearnMoreUrl", | 469 "exceptionsLearnMoreUrl", |
446 google_util::StringAppendGoogleLocaleParam( | 470 google_util::StringAppendGoogleLocaleParam( |
447 kExceptionsLearnMoreUrl)); | 471 kExceptionsLearnMoreUrl)); |
448 } | 472 } |
449 | 473 |
450 void ContentSettingsHandler::InitializeHandler() { | 474 void ContentSettingsHandler::InitializeHandler() { |
(...skipping 28 matching lines...) Expand all Loading... | |
479 pref_change_registrar_.Add( | 503 pref_change_registrar_.Add( |
480 prefs::kVideoCaptureAllowed, | 504 prefs::kVideoCaptureAllowed, |
481 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, | 505 base::Bind(&ContentSettingsHandler::UpdateMediaSettingsView, |
482 base::Unretained(this))); | 506 base::Unretained(this))); |
483 pref_change_registrar_.Add( | 507 pref_change_registrar_.Add( |
484 prefs::kEnableDRM, | 508 prefs::kEnableDRM, |
485 base::Bind( | 509 base::Bind( |
486 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, | 510 &ContentSettingsHandler::UpdateProtectedContentExceptionsButton, |
487 base::Unretained(this))); | 511 base::Unretained(this))); |
488 | 512 |
513 content::HostZoomMap* host_zoom_map = | |
514 content::HostZoomMap::GetForBrowserContext(profile); | |
515 host_zoom_map_subscription_ = | |
516 host_zoom_map->AddZoomLevelChangedCallback( | |
517 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, | |
518 base::Unretained(this))); | |
519 | |
489 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, profile)); | 520 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, profile)); |
490 } | 521 } |
491 | 522 |
492 void ContentSettingsHandler::InitializePage() { | 523 void ContentSettingsHandler::InitializePage() { |
493 media_settings_ = MediaSettingsInfo(); | 524 media_settings_ = MediaSettingsInfo(); |
494 RefreshFlashMediaSettings(); | 525 RefreshFlashMediaSettings(); |
495 | 526 |
496 UpdateHandlersEnabledRadios(); | 527 UpdateHandlersEnabledRadios(); |
497 UpdateAllExceptionsViewsFromModel(); | 528 UpdateAllExceptionsViewsFromModel(); |
498 UpdateProtectedContentExceptionsButton(); | 529 UpdateProtectedContentExceptionsButton(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 web_ui()->CallJavascriptFunction( | 701 web_ui()->CallJavascriptFunction( |
671 "ContentSettings.updateHandlersEnabledRadios", | 702 "ContentSettings.updateHandlersEnabledRadios", |
672 handlers_enabled); | 703 handlers_enabled); |
673 } | 704 } |
674 | 705 |
675 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 706 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
676 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 707 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
677 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 708 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { |
678 UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); | 709 UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); |
679 } | 710 } |
711 UpdateZoomLevelsExceptionsView(); | |
680 } | 712 } |
681 | 713 |
682 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { | 714 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { |
683 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 715 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
684 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 716 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { |
685 UpdateOTRExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); | 717 UpdateOTRExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); |
686 } | 718 } |
687 } | 719 } |
688 | 720 |
689 void ContentSettingsHandler::UpdateExceptionsViewFromModel( | 721 void ContentSettingsHandler::UpdateExceptionsViewFromModel( |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 web_ui()->CallJavascriptFunction( | 983 web_ui()->CallJavascriptFunction( |
952 "ContentSettings.showExperimentalWebMIDISettings", | 984 "ContentSettings.showExperimentalWebMIDISettings", |
953 base::FundamentalValue(true)); | 985 base::FundamentalValue(true)); |
954 } | 986 } |
955 | 987 |
956 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 988 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
957 UpdateExceptionsViewFromHostContentSettingsMap( | 989 UpdateExceptionsViewFromHostContentSettingsMap( |
958 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 990 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
959 } | 991 } |
960 | 992 |
993 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | |
994 base::ListValue zoom_levels_exceptions; | |
995 | |
996 content::HostZoomMap* host_zoom_map = | |
997 content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); | |
998 content::HostZoomMap::ZoomLevelVector zoom_levels( | |
999 host_zoom_map->GetAllZoomLevels()); | |
1000 std::sort(zoom_levels.begin(), zoom_levels.end(), ZoomLevelChangeLessThan); | |
1001 | |
1002 for (content::HostZoomMap::ZoomLevelVector::const_iterator i = | |
1003 zoom_levels.begin(); | |
1004 i != zoom_levels.end(); | |
1005 ++i) { | |
1006 base::DictionaryValue* exception = new base::DictionaryValue(); | |
1007 switch (i->mode) { | |
1008 case content::HostZoomMap::ZOOM_CHANGED_FOR_HOST: | |
1009 exception->SetString(kOrigin, i->host); | |
1010 break; | |
1011 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | |
1012 exception->SetString(kOrigin, i->scheme + "://" + i->host); | |
1013 break; | |
1014 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | |
1015 NOTREACHED(); | |
1016 } | |
1017 exception->SetString(kSetting, | |
1018 ContentSettingToString(CONTENT_SETTING_DEFAULT)); | |
1019 | |
1020 // Calculate the zoom percent from the factor. Round up to the nearest whole | |
1021 // number. | |
1022 int percent = static_cast<int>( | |
1023 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); | |
1024 exception->SetString(kZoom, base::IntToString(percent) + "%"); | |
markusheintz_
2014/03/12 16:31:06
hm ... I guess the string concatenation should wor
battre
2014/03/13 09:22:14
Done.
| |
1025 exception->SetString(kSource, kPreferencesSource); | |
1026 // Append the new entry to the list and map. | |
1027 zoom_levels_exceptions.Append(exception); | |
1028 } | |
1029 | |
1030 base::StringValue type_string(kZoomContentType); | |
1031 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | |
1032 type_string, zoom_levels_exceptions); | |
1033 } | |
1034 | |
961 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 1035 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
962 ContentSettingsType type) { | 1036 ContentSettingsType type) { |
963 base::ListValue exceptions; | 1037 base::ListValue exceptions; |
964 GetExceptionsFromHostContentSettingsMap( | 1038 GetExceptionsFromHostContentSettingsMap( |
965 GetContentSettingsMap(), type, &exceptions); | 1039 GetContentSettingsMap(), type, &exceptions); |
966 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); | 1040 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); |
967 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1041 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, |
968 exceptions); | 1042 exceptions); |
969 | 1043 |
970 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 1044 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 ContentSettingsPattern::FromString(pattern), | 1222 ContentSettingsPattern::FromString(pattern), |
1149 secondary_pattern.empty() | 1223 secondary_pattern.empty() |
1150 ? ContentSettingsPattern::Wildcard() | 1224 ? ContentSettingsPattern::Wildcard() |
1151 : ContentSettingsPattern::FromString(secondary_pattern), | 1225 : ContentSettingsPattern::FromString(secondary_pattern), |
1152 type, | 1226 type, |
1153 std::string(), | 1227 std::string(), |
1154 NULL); | 1228 NULL); |
1155 } | 1229 } |
1156 } | 1230 } |
1157 | 1231 |
1232 void ContentSettingsHandler::RemoveZoomLevelException( | |
1233 const base::ListValue* args, size_t arg_index) { | |
1234 std::string mode; | |
1235 bool rv = args->GetString(arg_index++, &mode); | |
1236 DCHECK(rv); | |
1237 | |
1238 std::string pattern; | |
1239 rv = args->GetString(arg_index++, &pattern); | |
1240 DCHECK(rv); | |
1241 | |
1242 content::HostZoomMap* host_zoom_map = | |
1243 content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); | |
1244 double default_level = host_zoom_map->GetDefaultZoomLevel(); | |
1245 | |
1246 std::string::size_type scheme_separator_position = pattern.find("://"); | |
markusheintz_
2014/03/12 16:31:06
In src/content/public/common/url_constants.cc ther
battre
2014/03/13 09:22:14
Done.
battre
2014/03/13 09:22:14
Done.
| |
1247 if (scheme_separator_position == std::string::npos) { | |
1248 host_zoom_map->SetZoomLevelForHost(pattern, default_level); | |
1249 } else { | |
1250 std::string scheme = pattern.substr(0, scheme_separator_position); | |
1251 std::string host = pattern.substr(scheme_separator_position + 3); | |
markusheintz_
2014/03/12 16:31:06
Please replace the '3' with the length of the cont
battre
2014/03/13 09:22:14
Done.
| |
1252 host_zoom_map->SetZoomLevelForHostAndScheme(scheme, host, default_level); | |
1253 } | |
1254 } | |
1255 | |
1158 void ContentSettingsHandler::RegisterMessages() { | 1256 void ContentSettingsHandler::RegisterMessages() { |
1159 web_ui()->RegisterMessageCallback("setContentFilter", | 1257 web_ui()->RegisterMessageCallback("setContentFilter", |
1160 base::Bind(&ContentSettingsHandler::SetContentFilter, | 1258 base::Bind(&ContentSettingsHandler::SetContentFilter, |
1161 base::Unretained(this))); | 1259 base::Unretained(this))); |
1162 web_ui()->RegisterMessageCallback("removeException", | 1260 web_ui()->RegisterMessageCallback("removeException", |
1163 base::Bind(&ContentSettingsHandler::RemoveException, | 1261 base::Bind(&ContentSettingsHandler::RemoveException, |
1164 base::Unretained(this))); | 1262 base::Unretained(this))); |
1165 web_ui()->RegisterMessageCallback("setException", | 1263 web_ui()->RegisterMessageCallback("setException", |
1166 base::Bind(&ContentSettingsHandler::SetException, | 1264 base::Bind(&ContentSettingsHandler::SetException, |
1167 base::Unretained(this))); | 1265 base::Unretained(this))); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1275 default: | 1373 default: |
1276 break; | 1374 break; |
1277 } | 1375 } |
1278 } | 1376 } |
1279 | 1377 |
1280 void ContentSettingsHandler::RemoveException(const base::ListValue* args) { | 1378 void ContentSettingsHandler::RemoveException(const base::ListValue* args) { |
1281 size_t arg_i = 0; | 1379 size_t arg_i = 0; |
1282 std::string type_string; | 1380 std::string type_string; |
1283 CHECK(args->GetString(arg_i++, &type_string)); | 1381 CHECK(args->GetString(arg_i++, &type_string)); |
1284 | 1382 |
1383 if (type_string == kZoomContentType) { | |
markusheintz_
2014/03/12 16:31:06
Please add a comment why this needs to go before t
battre
2014/03/13 09:22:14
Done.
| |
1384 RemoveZoomLevelException(args, arg_i); | |
1385 return; | |
1386 } | |
1387 | |
1285 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 1388 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); |
1286 switch (type) { | 1389 switch (type) { |
1287 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 1390 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
1288 RemoveNotificationException(args, arg_i); | 1391 RemoveNotificationException(args, arg_i); |
1289 break; | 1392 break; |
1290 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 1393 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
1291 RemoveMediaException(args, arg_i); | 1394 RemoveMediaException(args, arg_i); |
1292 break; | 1395 break; |
1293 default: | 1396 default: |
1294 RemoveExceptionFromHostContentSettingsMap(args, arg_i, type); | 1397 RemoveExceptionFromHostContentSettingsMap(args, arg_i, type); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1393 ShowFlashMediaLink(DEFAULT_SETTING, false); | 1496 ShowFlashMediaLink(DEFAULT_SETTING, false); |
1394 ShowFlashMediaLink(EXCEPTIONS, false); | 1497 ShowFlashMediaLink(EXCEPTIONS, false); |
1395 | 1498 |
1396 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 1499 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
1397 if (prefs->GetBoolean(prefs::kPepperFlashSettingsEnabled)) | 1500 if (prefs->GetBoolean(prefs::kPepperFlashSettingsEnabled)) |
1398 RefreshFlashMediaSettings(); | 1501 RefreshFlashMediaSettings(); |
1399 else | 1502 else |
1400 media_settings_.flash_settings_initialized = false; | 1503 media_settings_.flash_settings_initialized = false; |
1401 } | 1504 } |
1402 | 1505 |
1506 void ContentSettingsHandler::OnZoomLevelChanged( | |
1507 const content::HostZoomMap::ZoomLevelChange& change) { | |
1508 UpdateZoomLevelsExceptionsView(); | |
1509 } | |
1510 | |
1403 void ContentSettingsHandler::ShowFlashMediaLink(LinkType link_type, bool show) { | 1511 void ContentSettingsHandler::ShowFlashMediaLink(LinkType link_type, bool show) { |
1404 bool& show_link = link_type == DEFAULT_SETTING ? | 1512 bool& show_link = link_type == DEFAULT_SETTING ? |
1405 media_settings_.show_flash_default_link : | 1513 media_settings_.show_flash_default_link : |
1406 media_settings_.show_flash_exceptions_link; | 1514 media_settings_.show_flash_exceptions_link; |
1407 if (show_link != show) { | 1515 if (show_link != show) { |
1408 web_ui()->CallJavascriptFunction( | 1516 web_ui()->CallJavascriptFunction( |
1409 link_type == DEFAULT_SETTING ? | 1517 link_type == DEFAULT_SETTING ? |
1410 "ContentSettings.showMediaPepperFlashDefaultLink" : | 1518 "ContentSettings.showMediaPepperFlashDefaultLink" : |
1411 "ContentSettings.showMediaPepperFlashExceptionsLink", | 1519 "ContentSettings.showMediaPepperFlashExceptionsLink", |
1412 base::FundamentalValue(show)); | 1520 base::FundamentalValue(show)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1570 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
1463 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 1571 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
1464 // Exceptions apply only when the feature is enabled. | 1572 // Exceptions apply only when the feature is enabled. |
1465 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1573 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1466 web_ui()->CallJavascriptFunction( | 1574 web_ui()->CallJavascriptFunction( |
1467 "ContentSettings.enableProtectedContentExceptions", | 1575 "ContentSettings.enableProtectedContentExceptions", |
1468 base::FundamentalValue(enable_exceptions)); | 1576 base::FundamentalValue(enable_exceptions)); |
1469 } | 1577 } |
1470 | 1578 |
1471 } // namespace options | 1579 } // namespace options |
OLD | NEW |