Chromium Code Reviews| 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/options2/content_settings_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/content_settings_handler2.h" |
| 6 | 6 |
| 7 #include <map> | |
| 8 #include <string> | |
| 9 #include <vector> | 7 #include <vector> |
| 10 | 8 |
| 11 #include "base/bind.h" | 9 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 14 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 13 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/content_settings/content_settings_details.h" | 15 #include "chrome/browser/content_settings/content_settings_details.h" |
| 18 #include "chrome/browser/content_settings/content_settings_utils.h" | 16 #include "chrome/browser/content_settings/content_settings_utils.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 36 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
| 39 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 40 #include "content/public/browser/web_ui.h" | 38 #include "content/public/browser/web_ui.h" |
| 41 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
| 42 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 43 #include "grit/locale_settings.h" | 41 #include "grit/locale_settings.h" |
| 42 #include "net/base/net_util.h" | |
| 44 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 45 | 44 |
| 46 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 47 #include "chrome/browser/chromeos/login/user_manager.h" | 46 #include "chrome/browser/chromeos/login/user_manager.h" |
| 48 #endif | 47 #endif |
| 49 | 48 |
| 50 using content::UserMetricsAction; | 49 using content::UserMetricsAction; |
| 51 | 50 |
| 52 namespace { | 51 namespace { |
| 53 | 52 |
| 54 struct ContentSettingsTypeNameEntry { | 53 enum ExContentSettingsTypeEnum { |
| 55 ContentSettingsType type; | 54 EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC = |
| 56 const char* name; | 55 CONTENT_SETTINGS_NUM_TYPES, |
| 56 EX_CONTENT_SETTINGS_NUM_TYPES | |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; | 59 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; |
| 60 typedef std::map<ContentSettingsPattern, OnePatternSettings> | 60 typedef std::map<ContentSettingsPattern, OnePatternSettings> |
| 61 AllPatternsSettings; | 61 AllPatternsSettings; |
| 62 | 62 |
| 63 const char* kDisplayPattern = "displayPattern"; | 63 const char* kDisplayPattern = "displayPattern"; |
| 64 const char* kSetting = "setting"; | 64 const char* kSetting = "setting"; |
| 65 const char* kOrigin = "origin"; | 65 const char* kOrigin = "origin"; |
| 66 const char* kSource = "source"; | 66 const char* kSource = "source"; |
| 67 const char* kEmbeddingOrigin = "embeddingOrigin"; | 67 const char* kEmbeddingOrigin = "embeddingOrigin"; |
| 68 | 68 const char* kDefaultProviderID = "default"; |
| 69 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { | 69 const char* kPreferencesSource = "preferences"; |
| 70 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"}, | |
| 71 {CONTENT_SETTINGS_TYPE_IMAGES, "images"}, | |
| 72 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"}, | |
| 73 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"}, | |
| 74 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, | |
| 75 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, | |
| 76 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, | |
| 77 {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, | |
| 78 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"}, | |
| 79 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"}, | |
| 80 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"}, | |
| 81 }; | |
| 82 COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) == | |
| 83 CONTENT_SETTINGS_NUM_TYPES, | |
| 84 MISSING_CONTENT_SETTINGS_TYPE); | |
| 85 | |
| 86 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { | |
| 87 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | |
| 88 if (name == kContentSettingsTypeGroupNames[i].name) | |
| 89 return kContentSettingsTypeGroupNames[i].type; | |
| 90 } | |
| 91 | |
| 92 NOTREACHED() << name << " is not a recognized content settings type."; | |
| 93 return CONTENT_SETTINGS_TYPE_DEFAULT; | |
| 94 } | |
| 95 | 70 |
| 96 std::string ContentSettingToString(ContentSetting setting) { | 71 std::string ContentSettingToString(ContentSetting setting) { |
| 97 switch (setting) { | 72 switch (setting) { |
| 98 case CONTENT_SETTING_ALLOW: | 73 case CONTENT_SETTING_ALLOW: |
| 99 return "allow"; | 74 return "allow"; |
| 100 case CONTENT_SETTING_ASK: | 75 case CONTENT_SETTING_ASK: |
| 101 return "ask"; | 76 return "ask"; |
| 102 case CONTENT_SETTING_BLOCK: | 77 case CONTENT_SETTING_BLOCK: |
| 103 return "block"; | 78 return "block"; |
| 104 case CONTENT_SETTING_SESSION_ONLY: | 79 case CONTENT_SETTING_SESSION_ONLY: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 exception->SetString(kDisplayPattern, launch_url_string); | 209 exception->SetString(kDisplayPattern, launch_url_string); |
| 235 exception->SetString(kSetting, | 210 exception->SetString(kSetting, |
| 236 ContentSettingToString(CONTENT_SETTING_ALLOW)); | 211 ContentSettingToString(CONTENT_SETTING_ALLOW)); |
| 237 exception->SetString(kOrigin, launch_url_string); | 212 exception->SetString(kOrigin, launch_url_string); |
| 238 exception->SetString(kEmbeddingOrigin, launch_url_string); | 213 exception->SetString(kEmbeddingOrigin, launch_url_string); |
| 239 exception->SetString(kSource, "HostedApp"); | 214 exception->SetString(kSource, "HostedApp"); |
| 240 exceptions->Append(exception); | 215 exceptions->Append(exception); |
| 241 } | 216 } |
| 242 } | 217 } |
| 243 | 218 |
| 219 ContentSetting FlashPermissionToContentSetting( | |
| 220 PP_Flash_BrowserOperations_Permission permission) { | |
| 221 switch (permission) { | |
| 222 case PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT: | |
| 223 return CONTENT_SETTING_DEFAULT; | |
| 224 case PP_FLASH_BROWSEROPERATIONS_PERMISSION_ALLOW: | |
| 225 return CONTENT_SETTING_ALLOW; | |
| 226 case PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK: | |
| 227 return CONTENT_SETTING_BLOCK; | |
| 228 case PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK: | |
| 229 return CONTENT_SETTING_ASK; | |
| 230 default: | |
| 231 NOTREACHED(); | |
| 232 return CONTENT_SETTING_DEFAULT; | |
| 233 } | |
| 234 } | |
| 235 | |
| 236 PP_Flash_BrowserOperations_Permission FlashPermissionFromContentSetting( | |
| 237 ContentSetting setting) { | |
| 238 switch (setting) { | |
| 239 case CONTENT_SETTING_DEFAULT: | |
| 240 return PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT; | |
| 241 case CONTENT_SETTING_ALLOW: | |
| 242 return PP_FLASH_BROWSEROPERATIONS_PERMISSION_ALLOW; | |
| 243 case CONTENT_SETTING_BLOCK: | |
| 244 return PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK; | |
| 245 case CONTENT_SETTING_ASK: | |
| 246 return PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK; | |
| 247 default: | |
| 248 NOTREACHED(); | |
| 249 return PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT; | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 std::string CanonicalizeHost(const std::string& host) { | |
| 254 url_canon::CanonHostInfo info; | |
| 255 return net::CanonicalizeHost(host, &info); | |
| 256 } | |
| 257 | |
| 258 bool IsValidHost(const std::string& host) { | |
| 259 std::string canonicalized_host = CanonicalizeHost(host); | |
| 260 return !canonicalized_host.empty(); | |
| 261 } | |
| 262 | |
| 244 } // namespace | 263 } // namespace |
| 245 | 264 |
| 246 namespace options2 { | 265 namespace options2 { |
| 247 | 266 |
| 267 class ContentSettingsHandler::ExContentSettingsType { | |
| 268 public: | |
| 269 explicit ExContentSettingsType(int value) : value_(value) { | |
| 270 DCHECK(value_ < EX_CONTENT_SETTINGS_NUM_TYPES); | |
| 271 } | |
| 272 explicit ExContentSettingsType(ContentSettingsType type) : value_(type) {} | |
| 273 explicit ExContentSettingsType(ExContentSettingsTypeEnum type) | |
| 274 : value_(type) {} | |
| 275 | |
| 276 bool IsExtraContentSettingsType() const { | |
| 277 return value_ >= CONTENT_SETTINGS_NUM_TYPES; | |
| 278 } | |
| 279 | |
| 280 operator int() const { return value_; } | |
| 281 | |
| 282 ContentSettingsType ToContentSettingsType() const { | |
| 283 DCHECK(value_ < CONTENT_SETTINGS_NUM_TYPES); | |
| 284 return static_cast<ContentSettingsType>(value_); | |
| 285 } | |
| 286 | |
| 287 private: | |
| 288 int value_; | |
| 289 }; | |
| 290 | |
| 291 ContentSettingsHandler::CachedPepperFlashSettings::CachedPepperFlashSettings() | |
| 292 : default_permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), | |
| 293 initialized(false) { | |
| 294 } | |
| 295 | |
| 296 ContentSettingsHandler::CachedPepperFlashSettings::~CachedPepperFlashSettings() { | |
| 297 } | |
| 298 | |
| 299 struct ContentSettingsHandler::ExContentSettingsTypeNameEntry { | |
| 300 ExContentSettingsType type; | |
| 301 const char* name; | |
| 302 }; | |
| 303 | |
| 304 const ContentSettingsHandler::ExContentSettingsTypeNameEntry | |
| 305 ContentSettingsHandler::kExContentSettingsTypeGroupNames[] = { | |
| 306 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_COOKIES), "cookies"}, | |
| 307 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_IMAGES), "images"}, | |
| 308 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_JAVASCRIPT), "javascript"}, | |
| 309 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_PLUGINS), "plugins"}, | |
| 310 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_POPUPS), "popups"}, | |
| 311 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_GEOLOCATION), "location"}, | |
| 312 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS), "notifications"}, | |
| 313 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_INTENTS), "intents"}, | |
| 314 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE), | |
| 315 "auto-select-certificate"}, | |
| 316 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_FULLSCREEN), "fullscreen"}, | |
| 317 {ExContentSettingsType(CONTENT_SETTINGS_TYPE_MOUSELOCK), "mouselock"}, | |
| 318 {ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC), | |
| 319 "pepper_flash_cameramic"}, | |
| 320 }; | |
| 321 | |
| 248 ContentSettingsHandler::ContentSettingsHandler() { | 322 ContentSettingsHandler::ContentSettingsHandler() { |
| 249 } | 323 } |
| 250 | 324 |
| 251 ContentSettingsHandler::~ContentSettingsHandler() { | 325 ContentSettingsHandler::~ContentSettingsHandler() { |
| 252 } | 326 } |
| 253 | 327 |
| 254 void ContentSettingsHandler::GetLocalizedValues( | 328 void ContentSettingsHandler::GetLocalizedValues( |
| 255 DictionaryValue* localized_strings) { | 329 DictionaryValue* localized_strings) { |
| 256 DCHECK(localized_strings); | 330 DCHECK(localized_strings); |
| 257 | 331 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 { "allowWebIntents", IDS_ALLOW_WEB_INTENTS }, | 391 { "allowWebIntents", IDS_ALLOW_WEB_INTENTS }, |
| 318 // Fullscreen filter. | 392 // Fullscreen filter. |
| 319 { "fullscreen_tab_label", IDS_FULLSCREEN_TAB_LABEL }, | 393 { "fullscreen_tab_label", IDS_FULLSCREEN_TAB_LABEL }, |
| 320 { "fullscreen_header", IDS_FULLSCREEN_HEADER }, | 394 { "fullscreen_header", IDS_FULLSCREEN_HEADER }, |
| 321 // Mouse Lock filter. | 395 // Mouse Lock filter. |
| 322 { "mouselock_tab_label", IDS_MOUSE_LOCK_TAB_LABEL }, | 396 { "mouselock_tab_label", IDS_MOUSE_LOCK_TAB_LABEL }, |
| 323 { "mouselock_header", IDS_MOUSE_LOCK_HEADER }, | 397 { "mouselock_header", IDS_MOUSE_LOCK_HEADER }, |
| 324 { "mouselock_allow", IDS_MOUSE_LOCK_ALLOW_RADIO }, | 398 { "mouselock_allow", IDS_MOUSE_LOCK_ALLOW_RADIO }, |
| 325 { "mouselock_ask", IDS_MOUSE_LOCK_ASK_RADIO }, | 399 { "mouselock_ask", IDS_MOUSE_LOCK_ASK_RADIO }, |
| 326 { "mouselock_block", IDS_MOUSE_LOCK_BLOCK_RADIO }, | 400 { "mouselock_block", IDS_MOUSE_LOCK_BLOCK_RADIO }, |
| 401 // Pepper Flash camera and microphone fileter. | |
|
csilv
2012/06/05 00:40:21
nit: "filter"
yzshen1
2012/06/05 17:28:43
Done.
| |
| 402 { "pepper_flash_cameramic_tab_label", | |
| 403 IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL }, | |
| 404 { "pepper_flash_cameramic_header", IDS_PEPPER_FLASH_CAMERAMIC_HEADER }, | |
| 405 { "pepper_flash_cameramic_ask", IDS_PEPPER_FLASH_CAMERAMIC_ASK_RADIO }, | |
| 406 { "pepper_flash_cameramic_block", IDS_PEPPER_FLASH_CAMERAMIC_BLOCK_RADIO }, | |
| 327 #if defined(OS_CHROMEOS) | 407 #if defined(OS_CHROMEOS) |
| 328 // Protected Content filter | 408 // Protected Content filter |
| 329 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, | 409 { "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL }, |
| 330 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, | 410 { "protectedContentInfo", IDS_PROTECTED_CONTENT_INFO }, |
| 331 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, | 411 { "protectedContentEnable", IDS_PROTECTED_CONTENT_ENABLE}, |
| 332 #endif // defined(OS_CHROMEOS) | 412 #endif // defined(OS_CHROMEOS) |
| 333 }; | 413 }; |
| 334 | 414 |
| 335 RegisterStrings(localized_strings, resources, arraysize(resources)); | 415 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 336 RegisterTitle(localized_strings, "contentSettingsPage", | 416 RegisterTitle(localized_strings, "contentSettingsPage", |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 349 RegisterTitle(localized_strings, "popups", | 429 RegisterTitle(localized_strings, "popups", |
| 350 IDS_POPUP_TAB_LABEL); | 430 IDS_POPUP_TAB_LABEL); |
| 351 RegisterTitle(localized_strings, "location", | 431 RegisterTitle(localized_strings, "location", |
| 352 IDS_GEOLOCATION_TAB_LABEL); | 432 IDS_GEOLOCATION_TAB_LABEL); |
| 353 RegisterTitle(localized_strings, "notifications", | 433 RegisterTitle(localized_strings, "notifications", |
| 354 IDS_NOTIFICATIONS_TAB_LABEL); | 434 IDS_NOTIFICATIONS_TAB_LABEL); |
| 355 RegisterTitle(localized_strings, "fullscreen", | 435 RegisterTitle(localized_strings, "fullscreen", |
| 356 IDS_FULLSCREEN_TAB_LABEL); | 436 IDS_FULLSCREEN_TAB_LABEL); |
| 357 RegisterTitle(localized_strings, "mouselock", | 437 RegisterTitle(localized_strings, "mouselock", |
| 358 IDS_MOUSE_LOCK_TAB_LABEL); | 438 IDS_MOUSE_LOCK_TAB_LABEL); |
| 439 RegisterTitle(localized_strings, "pepper_flash_cameramic", | |
| 440 IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL); | |
| 359 | 441 |
| 360 Profile* profile = Profile::FromWebUI(web_ui()); | 442 Profile* profile = Profile::FromWebUI(web_ui()); |
| 361 localized_strings->SetBoolean( | 443 localized_strings->SetBoolean( |
| 362 "enable_web_intents", | 444 "enable_web_intents", |
| 363 web_intents::IsWebIntentsEnabledForProfile(profile)); | 445 web_intents::IsWebIntentsEnabledForProfile(profile)); |
| 364 // TODO(marja): clean up the options UI after the decision on the session | 446 // TODO(marja): clean up the options UI after the decision on the session |
| 365 // restore changes has stabilized. | 447 // restore changes has stabilized. |
| 366 localized_strings->SetBoolean( | 448 localized_strings->SetBoolean( |
| 367 "enable_restore_session_state", false); | 449 "enable_restore_session_state", false); |
| 368 } | 450 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 382 this, chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 464 this, chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
| 383 content::NotificationService::AllSources()); | 465 content::NotificationService::AllSources()); |
| 384 Profile* profile = Profile::FromWebUI(web_ui()); | 466 Profile* profile = Profile::FromWebUI(web_ui()); |
| 385 notification_registrar_.Add( | 467 notification_registrar_.Add( |
| 386 this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, | 468 this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, |
| 387 content::Source<Profile>(profile)); | 469 content::Source<Profile>(profile)); |
| 388 | 470 |
| 389 PrefService* prefs = profile->GetPrefs(); | 471 PrefService* prefs = profile->GetPrefs(); |
| 390 pref_change_registrar_.Init(prefs); | 472 pref_change_registrar_.Init(prefs); |
| 391 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); | 473 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); |
| 474 pref_change_registrar_.Add(prefs::kPepperFlashSettingsEnabled, this); | |
| 475 | |
| 476 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, profile)); | |
| 392 } | 477 } |
| 393 | 478 |
| 394 void ContentSettingsHandler::InitializePage() { | 479 void ContentSettingsHandler::InitializePage() { |
| 395 UpdateHandlersEnabledRadios(); | 480 UpdateHandlersEnabledRadios(); |
| 396 UpdateAllExceptionsViewsFromModel(); | 481 UpdateAllExceptionsViewsFromModel(); |
| 482 | |
| 483 flash_cameramic_settings_ = CachedPepperFlashSettings(); | |
| 484 flash_settings_manager_->GetPermissionSettings( | |
| 485 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC); | |
| 397 } | 486 } |
| 398 | 487 |
| 399 void ContentSettingsHandler::Observe( | 488 void ContentSettingsHandler::Observe( |
| 400 int type, | 489 int type, |
| 401 const content::NotificationSource& source, | 490 const content::NotificationSource& source, |
| 402 const content::NotificationDetails& details) { | 491 const content::NotificationDetails& details) { |
| 403 switch (type) { | 492 switch (type) { |
| 404 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 493 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 405 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) { | 494 if (content::Source<Profile>(source).ptr()->IsOffTheRecord()) { |
| 406 web_ui()->CallJavascriptFunction( | 495 web_ui()->CallJavascriptFunction( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 420 HostContentSettingsMap* map = | 509 HostContentSettingsMap* map = |
| 421 content::Source<HostContentSettingsMap>(source).ptr(); | 510 content::Source<HostContentSettingsMap>(source).ptr(); |
| 422 if (map != GetContentSettingsMap() && | 511 if (map != GetContentSettingsMap() && |
| 423 map != GetOTRContentSettingsMap()) | 512 map != GetOTRContentSettingsMap()) |
| 424 break; | 513 break; |
| 425 | 514 |
| 426 const ContentSettingsDetails* settings_details = | 515 const ContentSettingsDetails* settings_details = |
| 427 content::Details<const ContentSettingsDetails>(details).ptr(); | 516 content::Details<const ContentSettingsDetails>(details).ptr(); |
| 428 | 517 |
| 429 // TODO(estade): we pretend update_all() is always true. | 518 // TODO(estade): we pretend update_all() is always true. |
| 430 if (settings_details->update_all_types()) | 519 if (settings_details->update_all_types()) { |
| 431 UpdateAllExceptionsViewsFromModel(); | 520 UpdateAllExceptionsViewsFromModel(); |
| 432 else | 521 } else { |
| 433 UpdateExceptionsViewFromModel(settings_details->type()); | 522 UpdateExceptionsViewFromModel( |
| 523 ExContentSettingsType(settings_details->type())); | |
| 524 } | |
| 434 break; | 525 break; |
| 435 } | 526 } |
| 436 | 527 |
| 437 case chrome::NOTIFICATION_PREF_CHANGED: { | 528 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 438 const std::string& pref_name = | 529 const std::string& pref_name = |
| 439 *content::Details<std::string>(details).ptr(); | 530 *content::Details<std::string>(details).ptr(); |
| 440 if (pref_name == prefs::kGeolocationContentSettings) | 531 if (pref_name == prefs::kGeolocationContentSettings) { |
| 441 UpdateGeolocationExceptionsView(); | 532 UpdateGeolocationExceptionsView(); |
| 533 } else if (pref_name == prefs::kPepperFlashSettingsEnabled) { | |
| 534 if (!flash_cameramic_settings_.initialized) { | |
| 535 flash_settings_manager_->GetPermissionSettings( | |
| 536 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC); | |
| 537 } | |
| 538 } | |
| 539 | |
| 442 break; | 540 break; |
| 443 } | 541 } |
| 444 | 542 |
| 445 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { | 543 case chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { |
| 446 UpdateNotificationExceptionsView(); | 544 UpdateNotificationExceptionsView(); |
| 447 break; | 545 break; |
| 448 } | 546 } |
| 449 | 547 |
| 450 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { | 548 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { |
| 451 UpdateHandlersEnabledRadios(); | 549 UpdateHandlersEnabledRadios(); |
| 452 break; | 550 break; |
| 453 } | 551 } |
| 454 | 552 |
| 455 default: | 553 default: |
| 456 OptionsPageUIHandler::Observe(type, source, details); | 554 OptionsPageUIHandler::Observe(type, source, details); |
| 457 } | 555 } |
| 458 } | 556 } |
| 459 | 557 |
| 558 void ContentSettingsHandler::OnGetPermissionSettingsCompleted( | |
| 559 uint32 /* request_id */, | |
| 560 bool success, | |
| 561 PP_Flash_BrowserOperations_Permission default_permission, | |
| 562 const ppapi::FlashSiteSettings& sites) { | |
| 563 if (success && !flash_cameramic_settings_.initialized) { | |
| 564 flash_cameramic_settings_.initialized = true; | |
| 565 flash_cameramic_settings_.default_permission = default_permission; | |
| 566 for (ppapi::FlashSiteSettings::const_iterator iter = sites.begin(); | |
| 567 iter != sites.end(); ++iter) { | |
| 568 if (IsValidHost(iter->site)) | |
| 569 flash_cameramic_settings_.sites[iter->site] = iter->permission; | |
| 570 } | |
| 571 UpdateExceptionsViewFromModel( | |
| 572 ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC)); | |
| 573 | |
| 574 web_ui()->CallJavascriptFunction( | |
| 575 "ContentSettings.enablePepperFlashCameraMicSettings"); | |
| 576 } | |
| 577 } | |
| 578 | |
| 460 void ContentSettingsHandler::UpdateSettingDefaultFromModel( | 579 void ContentSettingsHandler::UpdateSettingDefaultFromModel( |
| 461 ContentSettingsType type) { | 580 const ExContentSettingsType& type) { |
| 462 DictionaryValue filter_settings; | 581 DictionaryValue filter_settings; |
| 463 std::string provider_id; | 582 std::string provider_id; |
| 464 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", | |
| 465 GetSettingDefaultFromModel(type, &provider_id)); | |
| 466 filter_settings.SetString( | 583 filter_settings.SetString( |
| 467 ContentSettingsTypeToGroupName(type) + ".managedBy", | 584 ExContentSettingsTypeToGroupName(type) + ".value", |
| 468 provider_id); | 585 GetSettingDefaultFromModel(type, &provider_id)); |
| 586 filter_settings.SetString( | |
| 587 ExContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); | |
| 469 | 588 |
| 470 web_ui()->CallJavascriptFunction( | 589 web_ui()->CallJavascriptFunction( |
| 471 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 590 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 472 web_ui()->CallJavascriptFunction( | 591 web_ui()->CallJavascriptFunction( |
| 473 "BrowserOptions.setContentFilterSettingsValue", filter_settings); | 592 "BrowserOptions.setContentFilterSettingsValue", filter_settings); |
| 474 } | 593 } |
| 475 | 594 |
| 476 std::string ContentSettingsHandler::GetSettingDefaultFromModel( | 595 std::string ContentSettingsHandler::GetSettingDefaultFromModel( |
| 477 ContentSettingsType type, std::string* provider_id) { | 596 const ExContentSettingsType& type, std::string* provider_id) { |
| 478 Profile* profile = Profile::FromWebUI(web_ui()); | 597 Profile* profile = Profile::FromWebUI(web_ui()); |
| 479 ContentSetting default_setting; | 598 ContentSetting default_setting; |
| 480 if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 599 if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 481 default_setting = | 600 default_setting = |
| 482 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 601 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
| 483 GetDefaultContentSetting(provider_id); | 602 GetDefaultContentSetting(provider_id); |
| 603 } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { | |
| 604 default_setting = FlashPermissionToContentSetting( | |
| 605 flash_cameramic_settings_.default_permission); | |
| 606 *provider_id = kDefaultProviderID; | |
| 484 } else { | 607 } else { |
| 485 default_setting = | 608 default_setting = |
| 486 profile->GetHostContentSettingsMap()-> | 609 profile->GetHostContentSettingsMap()-> |
| 487 GetDefaultContentSetting(type, provider_id); | 610 GetDefaultContentSetting(type.ToContentSettingsType(), provider_id); |
| 488 } | 611 } |
| 489 | 612 |
| 490 return ContentSettingToString(default_setting); | 613 return ContentSettingToString(default_setting); |
| 491 } | 614 } |
| 492 | 615 |
| 493 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 616 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
| 494 base::FundamentalValue handlers_enabled( | 617 base::FundamentalValue handlers_enabled( |
| 495 GetProtocolHandlerRegistry()->enabled()); | 618 GetProtocolHandlerRegistry()->enabled()); |
| 496 | 619 |
| 497 web_ui()->CallJavascriptFunction( | 620 web_ui()->CallJavascriptFunction( |
| 498 "ContentSettings.updateHandlersEnabledRadios", | 621 "ContentSettings.updateHandlersEnabledRadios", |
| 499 handlers_enabled); | 622 handlers_enabled); |
| 500 } | 623 } |
| 501 | 624 |
| 502 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 625 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
| 503 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 626 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
| 504 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 627 type < EX_CONTENT_SETTINGS_NUM_TYPES; ++type) { |
| 505 // The content settings type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE | 628 // The content settings type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE |
| 506 // is supposed to be set by policy only. Hence there is no user facing UI | 629 // is supposed to be set by policy only. Hence there is no user facing UI |
| 507 // for this content type and we skip it here. | 630 // for this content type and we skip it here. |
| 508 if (type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) | 631 if (type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE) |
| 509 continue; | 632 continue; |
| 510 UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); | 633 UpdateExceptionsViewFromModel(ExContentSettingsType(type)); |
| 511 } | 634 } |
| 512 } | 635 } |
| 513 | 636 |
| 514 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { | 637 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { |
| 515 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 638 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
| 516 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 639 type < EX_CONTENT_SETTINGS_NUM_TYPES; ++type) { |
| 517 UpdateOTRExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); | 640 UpdateOTRExceptionsViewFromModel(ExContentSettingsType(type)); |
| 518 } | 641 } |
| 519 } | 642 } |
| 520 | 643 |
| 521 void ContentSettingsHandler::UpdateExceptionsViewFromModel( | 644 void ContentSettingsHandler::UpdateExceptionsViewFromModel( |
| 522 ContentSettingsType type) { | 645 const ExContentSettingsType& type) { |
| 523 // Don't update intents settings at this point. | 646 // Don't update intents settings at this point. |
| 524 // Turn on when enable_web_intents_tag is enabled. | 647 // Turn on when enable_web_intents_tag is enabled. |
| 525 if (type == CONTENT_SETTINGS_TYPE_INTENTS) | 648 if (type == CONTENT_SETTINGS_TYPE_INTENTS) |
| 526 return; | 649 return; |
| 527 | 650 |
| 528 switch (type) { | 651 switch (type) { |
| 529 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 652 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 530 UpdateGeolocationExceptionsView(); | 653 UpdateGeolocationExceptionsView(); |
| 531 break; | 654 break; |
| 532 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 655 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 533 UpdateNotificationExceptionsView(); | 656 UpdateNotificationExceptionsView(); |
| 534 break; | 657 break; |
| 658 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: | |
| 659 UpdateFlashCameraMicExceptionsView(); | |
| 660 break; | |
| 535 default: | 661 default: |
| 536 UpdateExceptionsViewFromHostContentSettingsMap(type); | 662 UpdateExceptionsViewFromHostContentSettingsMap( |
| 663 type.ToContentSettingsType()); | |
| 537 break; | 664 break; |
| 538 } | 665 } |
| 539 } | 666 } |
| 540 | 667 |
| 541 void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel( | 668 void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel( |
| 542 ContentSettingsType type) { | 669 const ExContentSettingsType& type) { |
| 543 switch (type) { | 670 switch (type) { |
| 544 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 671 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 545 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 672 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 546 case CONTENT_SETTINGS_TYPE_INTENTS: | 673 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 547 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: | 674 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: |
| 675 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: | |
| 548 break; | 676 break; |
| 549 default: | 677 default: |
| 550 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 678 UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| 679 type.ToContentSettingsType()); | |
| 551 break; | 680 break; |
| 552 } | 681 } |
| 553 } | 682 } |
| 554 | 683 |
| 555 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { | 684 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { |
| 556 Profile* profile = Profile::FromWebUI(web_ui()); | 685 Profile* profile = Profile::FromWebUI(web_ui()); |
| 557 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 686 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| 558 | 687 |
| 559 ContentSettingsForOneType all_settings; | 688 ContentSettingsForOneType all_settings; |
| 560 map->GetSettingsForOneType( | 689 map->GetSettingsForOneType( |
| 561 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 690 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 562 std::string(), | 691 std::string(), |
| 563 &all_settings); | 692 &all_settings); |
| 564 | 693 |
| 565 // Group geolocation settings by primary_pattern. | 694 // Group geolocation settings by primary_pattern. |
| 566 AllPatternsSettings all_patterns_settings; | 695 AllPatternsSettings all_patterns_settings; |
| 567 for (ContentSettingsForOneType::iterator i = | 696 for (ContentSettingsForOneType::iterator i = |
| 568 all_settings.begin(); | 697 all_settings.begin(); |
| 569 i != all_settings.end(); | 698 i != all_settings.end(); |
| 570 ++i) { | 699 ++i) { |
| 571 // Don't add default settings. | 700 // Don't add default settings. |
| 572 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 701 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
| 573 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 702 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| 574 i->source != "preferences") { | 703 i->source != kPreferencesSource) { |
| 575 continue; | 704 continue; |
| 576 } | 705 } |
| 577 all_patterns_settings[i->primary_pattern][i->secondary_pattern] = | 706 all_patterns_settings[i->primary_pattern][i->secondary_pattern] = |
| 578 i->setting; | 707 i->setting; |
| 579 } | 708 } |
| 580 | 709 |
| 581 ListValue exceptions; | 710 ListValue exceptions; |
| 582 AddExceptionsGrantedByHostedApps( | 711 AddExceptionsGrantedByHostedApps( |
| 583 profile, ExtensionAPIPermission::kGeolocation, &exceptions); | 712 profile, ExtensionAPIPermission::kGeolocation, &exceptions); |
| 584 | 713 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 611 } | 740 } |
| 612 } | 741 } |
| 613 | 742 |
| 614 StringValue type_string( | 743 StringValue type_string( |
| 615 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 744 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 616 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 745 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", |
| 617 type_string, exceptions); | 746 type_string, exceptions); |
| 618 | 747 |
| 619 // This is mainly here to keep this function ideologically parallel to | 748 // This is mainly here to keep this function ideologically parallel to |
| 620 // UpdateExceptionsViewFromHostContentSettingsMap(). | 749 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 621 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 750 UpdateSettingDefaultFromModel( |
| 751 ExContentSettingsType(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 622 } | 752 } |
| 623 | 753 |
| 624 void ContentSettingsHandler::UpdateNotificationExceptionsView() { | 754 void ContentSettingsHandler::UpdateNotificationExceptionsView() { |
| 625 Profile* profile = Profile::FromWebUI(web_ui()); | 755 Profile* profile = Profile::FromWebUI(web_ui()); |
| 626 DesktopNotificationService* service = | 756 DesktopNotificationService* service = |
| 627 DesktopNotificationServiceFactory::GetForProfile(profile); | 757 DesktopNotificationServiceFactory::GetForProfile(profile); |
| 628 | 758 |
| 629 ContentSettingsForOneType settings; | 759 ContentSettingsForOneType settings; |
| 630 service->GetNotificationsSettings(&settings); | 760 service->GetNotificationsSettings(&settings); |
| 631 | 761 |
| 632 ListValue exceptions; | 762 ListValue exceptions; |
| 633 AddExceptionsGrantedByHostedApps( | 763 AddExceptionsGrantedByHostedApps( |
| 634 profile, ExtensionAPIPermission::kNotification, &exceptions); | 764 profile, ExtensionAPIPermission::kNotification, &exceptions); |
| 635 | 765 |
| 636 for (ContentSettingsForOneType::const_iterator i = | 766 for (ContentSettingsForOneType::const_iterator i = |
| 637 settings.begin(); | 767 settings.begin(); |
| 638 i != settings.end(); | 768 i != settings.end(); |
| 639 ++i) { | 769 ++i) { |
| 640 // Don't add default settings. | 770 // Don't add default settings. |
| 641 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 771 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
| 642 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 772 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| 643 i->source != "preferences") { | 773 i->source != kPreferencesSource) { |
| 644 continue; | 774 continue; |
| 645 } | 775 } |
| 646 | 776 |
| 647 exceptions.Append( | 777 exceptions.Append( |
| 648 GetNotificationExceptionForPage(i->primary_pattern, i->setting, | 778 GetNotificationExceptionForPage(i->primary_pattern, i->setting, |
| 649 i->source)); | 779 i->source)); |
| 650 } | 780 } |
| 651 | 781 |
| 652 StringValue type_string( | 782 StringValue type_string( |
| 653 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 783 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
| 654 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | 784 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", |
| 655 type_string, exceptions); | 785 type_string, exceptions); |
| 656 | 786 |
| 657 // This is mainly here to keep this function ideologically parallel to | 787 // This is mainly here to keep this function ideologically parallel to |
| 658 // UpdateExceptionsViewFromHostContentSettingsMap(). | 788 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 659 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 789 UpdateSettingDefaultFromModel( |
| 790 ExContentSettingsType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | |
| 791 } | |
| 792 | |
| 793 void ContentSettingsHandler::UpdateFlashCameraMicExceptionsView() { | |
| 794 ListValue exceptions; | |
| 795 for (CachedPepperFlashSettings::SiteMap::iterator iter = | |
| 796 flash_cameramic_settings_.sites.begin(); | |
| 797 iter != flash_cameramic_settings_.sites.end(); ++iter) { | |
| 798 DictionaryValue* exception = new DictionaryValue(); | |
| 799 exception->SetString(kDisplayPattern, iter->first); | |
| 800 exception->SetString( | |
| 801 kSetting, | |
| 802 ContentSettingToString(FlashPermissionToContentSetting(iter->second))); | |
| 803 exception->SetString(kSource, kPreferencesSource); | |
| 804 exceptions.Append(exception); | |
| 805 } | |
| 806 | |
| 807 StringValue type_string(ExContentSettingsTypeToGroupName( | |
| 808 ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC))); | |
| 809 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", | |
| 810 type_string, exceptions); | |
| 811 | |
| 812 UpdateSettingDefaultFromModel( | |
| 813 ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC)); | |
| 660 } | 814 } |
| 661 | 815 |
| 662 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( | 816 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( |
| 663 ContentSettingsType type) { | 817 ContentSettingsType type) { |
| 664 ContentSettingsForOneType entries; | 818 ContentSettingsForOneType entries; |
| 665 GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries); | 819 GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries); |
| 666 | 820 |
| 667 ListValue exceptions; | 821 ListValue exceptions; |
| 668 for (size_t i = 0; i < entries.size(); ++i) { | 822 for (size_t i = 0; i < entries.size(); ++i) { |
| 669 // Skip default settings from extensions and policy, and the default content | 823 // Skip default settings from extensions and policy, and the default content |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 695 | 849 |
| 696 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); | 850 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); |
| 697 | 851 |
| 698 // TODO(koz): The default for fullscreen is always 'ask'. | 852 // TODO(koz): The default for fullscreen is always 'ask'. |
| 699 // http://crbug.com/104683 | 853 // http://crbug.com/104683 |
| 700 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) | 854 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) |
| 701 return; | 855 return; |
| 702 | 856 |
| 703 // The default may also have changed (we won't get a separate notification). | 857 // The default may also have changed (we won't get a separate notification). |
| 704 // If it hasn't changed, this call will be harmless. | 858 // If it hasn't changed, this call will be harmless. |
| 705 UpdateSettingDefaultFromModel(type); | 859 UpdateSettingDefaultFromModel(ExContentSettingsType(type)); |
| 706 } | 860 } |
| 707 | 861 |
| 708 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( | 862 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( |
| 709 ContentSettingsType type) { | 863 ContentSettingsType type) { |
| 710 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); | 864 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); |
| 711 if (!otr_settings_map) | 865 if (!otr_settings_map) |
| 712 return; | 866 return; |
| 713 | 867 |
| 714 ContentSettingsForOneType otr_entries; | 868 ContentSettingsForOneType otr_entries; |
| 715 otr_settings_map->GetSettingsForOneType(type, "", &otr_entries); | 869 otr_settings_map->GetSettingsForOneType(type, "", &otr_entries); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 void ContentSettingsHandler::SetContentFilter(const ListValue* args) { | 945 void ContentSettingsHandler::SetContentFilter(const ListValue* args) { |
| 792 DCHECK_EQ(2U, args->GetSize()); | 946 DCHECK_EQ(2U, args->GetSize()); |
| 793 std::string group, setting; | 947 std::string group, setting; |
| 794 if (!(args->GetString(0, &group) && | 948 if (!(args->GetString(0, &group) && |
| 795 args->GetString(1, &setting))) { | 949 args->GetString(1, &setting))) { |
| 796 NOTREACHED(); | 950 NOTREACHED(); |
| 797 return; | 951 return; |
| 798 } | 952 } |
| 799 | 953 |
| 800 ContentSetting default_setting = ContentSettingFromString(setting); | 954 ContentSetting default_setting = ContentSettingFromString(setting); |
| 801 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 955 ExContentSettingsType content_type = |
| 956 ExContentSettingsTypeFromGroupName(group); | |
| 802 Profile* profile = Profile::FromWebUI(web_ui()); | 957 Profile* profile = Profile::FromWebUI(web_ui()); |
| 803 | 958 |
| 804 #if defined(OS_CHROMEOS) | 959 #if defined(OS_CHROMEOS) |
| 805 // ChromeOS special case : in Guest mode settings are opened in Incognito | 960 // ChromeOS special case : in Guest mode settings are opened in Incognito |
| 806 // mode, so we need original profile to actually modify settings. | 961 // mode, so we need original profile to actually modify settings. |
| 807 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) | 962 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
| 808 profile = profile->GetOriginalProfile(); | 963 profile = profile->GetOriginalProfile(); |
| 809 #endif | 964 #endif |
| 810 | 965 |
| 811 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 966 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 812 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 967 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
| 813 SetDefaultContentSetting(default_setting); | 968 SetDefaultContentSetting(default_setting); |
| 969 } else if (content_type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { | |
| 970 flash_cameramic_settings_.default_permission = | |
| 971 FlashPermissionFromContentSetting(default_setting); | |
| 972 flash_settings_manager_->SetDefaultPermission( | |
| 973 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC, | |
| 974 flash_cameramic_settings_.default_permission, false); | |
| 814 } else { | 975 } else { |
| 815 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 976 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| 816 ApplyWhitelist(content_type, default_setting); | 977 ContentSettingsType converted_type = content_type.ToContentSettingsType(); |
| 817 map->SetDefaultContentSetting(content_type, default_setting); | 978 ApplyWhitelist(converted_type, default_setting); |
| 979 map->SetDefaultContentSetting(converted_type, default_setting); | |
| 818 } | 980 } |
| 819 switch (content_type) { | 981 switch (content_type) { |
| 820 case CONTENT_SETTINGS_TYPE_COOKIES: | 982 case CONTENT_SETTINGS_TYPE_COOKIES: |
| 821 content::RecordAction( | 983 content::RecordAction( |
| 822 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 984 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
| 823 break; | 985 break; |
| 824 case CONTENT_SETTINGS_TYPE_IMAGES: | 986 case CONTENT_SETTINGS_TYPE_IMAGES: |
| 825 content::RecordAction( | 987 content::RecordAction( |
| 826 UserMetricsAction("Options_DefaultImagesSettingChanged")); | 988 UserMetricsAction("Options_DefaultImagesSettingChanged")); |
| 827 break; | 989 break; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 846 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); | 1008 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); |
| 847 break; | 1009 break; |
| 848 case CONTENT_SETTINGS_TYPE_INTENTS: | 1010 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 849 content::RecordAction( | 1011 content::RecordAction( |
| 850 UserMetricsAction("Options_DefaultHandlersSettingChanged")); | 1012 UserMetricsAction("Options_DefaultHandlersSettingChanged")); |
| 851 break; | 1013 break; |
| 852 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | 1014 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
| 853 content::RecordAction( | 1015 content::RecordAction( |
| 854 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); | 1016 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); |
| 855 break; | 1017 break; |
| 1018 case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC: | |
| 1019 content::RecordAction( | |
| 1020 UserMetricsAction("Options_DefaultFlashCameraMicSettingChanged")); | |
| 1021 break; | |
| 856 default: | 1022 default: |
| 857 break; | 1023 break; |
| 858 } | 1024 } |
| 859 } | 1025 } |
| 860 | 1026 |
| 861 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 1027 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
| 862 size_t arg_i = 0; | 1028 size_t arg_i = 0; |
| 863 std::string type_string; | 1029 std::string type_string; |
| 864 CHECK(args->GetString(arg_i++, &type_string)); | 1030 CHECK(args->GetString(arg_i++, &type_string)); |
| 865 | 1031 |
| 866 Profile* profile = Profile::FromWebUI(web_ui()); | 1032 Profile* profile = Profile::FromWebUI(web_ui()); |
| 867 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 1033 ExContentSettingsType type = ExContentSettingsTypeFromGroupName( |
| 1034 type_string); | |
| 868 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 1035 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 869 std::string origin; | 1036 std::string origin; |
| 870 std::string embedding_origin; | 1037 std::string embedding_origin; |
| 871 bool rv = args->GetString(arg_i++, &origin); | 1038 bool rv = args->GetString(arg_i++, &origin); |
| 872 DCHECK(rv); | 1039 DCHECK(rv); |
| 873 rv = args->GetString(arg_i++, &embedding_origin); | 1040 rv = args->GetString(arg_i++, &embedding_origin); |
| 874 DCHECK(rv); | 1041 DCHECK(rv); |
| 875 | 1042 |
| 876 profile->GetHostContentSettingsMap()-> | 1043 profile->GetHostContentSettingsMap()-> |
| 877 SetContentSetting(ContentSettingsPattern::FromString(origin), | 1044 SetContentSetting(ContentSettingsPattern::FromString(origin), |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 894 ClearSetting(ContentSettingsPattern::FromString(origin)); | 1061 ClearSetting(ContentSettingsPattern::FromString(origin)); |
| 895 } else { | 1062 } else { |
| 896 std::string mode; | 1063 std::string mode; |
| 897 bool rv = args->GetString(arg_i++, &mode); | 1064 bool rv = args->GetString(arg_i++, &mode); |
| 898 DCHECK(rv); | 1065 DCHECK(rv); |
| 899 | 1066 |
| 900 std::string pattern; | 1067 std::string pattern; |
| 901 rv = args->GetString(arg_i++, &pattern); | 1068 rv = args->GetString(arg_i++, &pattern); |
| 902 DCHECK(rv); | 1069 DCHECK(rv); |
| 903 | 1070 |
| 904 HostContentSettingsMap* settings_map = | 1071 if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { |
| 905 mode == "normal" ? GetContentSettingsMap() : | 1072 DCHECK_EQ(mode, "normal"); |
| 906 GetOTRContentSettingsMap(); | 1073 |
| 907 // The settings map could be null if the mode was OTR but the OTR profile | 1074 CachedPepperFlashSettings::SiteMap::iterator iter = |
| 908 // got destroyed before we received this message. | 1075 flash_cameramic_settings_.sites.find(pattern); |
| 909 if (settings_map) { | 1076 if (iter != flash_cameramic_settings_.sites.end()) { |
| 910 settings_map->SetContentSetting( | 1077 flash_cameramic_settings_.sites.erase(iter); |
| 911 ContentSettingsPattern::FromString(pattern), | 1078 ppapi::FlashSiteSettings site_settings(1, |
| 912 ContentSettingsPattern::Wildcard(), | 1079 ppapi::FlashSiteSetting( |
| 913 ContentSettingsTypeFromGroupName(type_string), | 1080 pattern, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT)); |
| 914 "", | 1081 flash_settings_manager_->SetSitePermission( |
| 915 CONTENT_SETTING_DEFAULT); | 1082 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC, |
| 1083 site_settings); | |
| 1084 } else { | |
| 1085 NOTREACHED(); | |
| 1086 } | |
| 1087 UpdateFlashCameraMicExceptionsView(); | |
| 1088 } else { | |
| 1089 HostContentSettingsMap* settings_map = | |
| 1090 mode == "normal" ? GetContentSettingsMap() : | |
| 1091 GetOTRContentSettingsMap(); | |
| 1092 // The settings map could be null if the mode was OTR but the OTR profile | |
| 1093 // got destroyed before we received this message. | |
| 1094 if (settings_map) { | |
| 1095 settings_map->SetContentSetting( | |
| 1096 ContentSettingsPattern::FromString(pattern), | |
| 1097 ContentSettingsPattern::Wildcard(), | |
| 1098 type.ToContentSettingsType(), | |
| 1099 "", | |
| 1100 CONTENT_SETTING_DEFAULT); | |
| 1101 } | |
| 916 } | 1102 } |
| 917 } | 1103 } |
| 918 } | 1104 } |
| 919 | 1105 |
| 920 void ContentSettingsHandler::SetException(const ListValue* args) { | 1106 void ContentSettingsHandler::SetException(const ListValue* args) { |
| 921 size_t arg_i = 0; | 1107 size_t arg_i = 0; |
| 922 std::string type_string; | 1108 std::string type_string; |
| 923 CHECK(args->GetString(arg_i++, &type_string)); | 1109 CHECK(args->GetString(arg_i++, &type_string)); |
| 924 std::string mode; | 1110 std::string mode; |
| 925 CHECK(args->GetString(arg_i++, &mode)); | 1111 CHECK(args->GetString(arg_i++, &mode)); |
| 926 std::string pattern; | 1112 std::string pattern; |
| 927 CHECK(args->GetString(arg_i++, &pattern)); | 1113 CHECK(args->GetString(arg_i++, &pattern)); |
| 928 std::string setting; | 1114 std::string setting; |
| 929 CHECK(args->GetString(arg_i++, &setting)); | 1115 CHECK(args->GetString(arg_i++, &setting)); |
| 930 | 1116 |
| 931 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 1117 ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); |
| 932 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 1118 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
| 933 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 1119 type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 934 NOTREACHED(); | 1120 NOTREACHED(); |
| 935 return; | 1121 } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { |
| 1122 DCHECK(IsValidHost(pattern)); | |
| 1123 | |
| 1124 if (flash_cameramic_settings_.sites.find(pattern) == | |
| 1125 flash_cameramic_settings_.sites.end()) { | |
| 1126 pattern = CanonicalizeHost(pattern); | |
| 1127 } | |
| 1128 PP_Flash_BrowserOperations_Permission permission = | |
| 1129 FlashPermissionFromContentSetting(ContentSettingFromString(setting)); | |
| 1130 flash_cameramic_settings_.sites[pattern] = permission; | |
| 1131 ppapi::FlashSiteSettings | |
| 1132 site_settings(1, ppapi::FlashSiteSetting(pattern, permission)); | |
| 1133 flash_settings_manager_->SetSitePermission( | |
| 1134 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC, | |
| 1135 site_settings); | |
| 1136 UpdateFlashCameraMicExceptionsView(); | |
| 1137 } else { | |
| 1138 HostContentSettingsMap* settings_map = | |
| 1139 mode == "normal" ? GetContentSettingsMap() : | |
| 1140 GetOTRContentSettingsMap(); | |
| 1141 | |
| 1142 // The settings map could be null if the mode was OTR but the OTR profile | |
| 1143 // got destroyed before we received this message. | |
| 1144 if (!settings_map) | |
| 1145 return; | |
| 1146 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), | |
| 1147 ContentSettingsPattern::Wildcard(), | |
| 1148 type.ToContentSettingsType(), | |
| 1149 "", | |
| 1150 ContentSettingFromString(setting)); | |
| 936 } | 1151 } |
| 937 | |
| 938 HostContentSettingsMap* settings_map = | |
| 939 mode == "normal" ? GetContentSettingsMap() : | |
| 940 GetOTRContentSettingsMap(); | |
| 941 | |
| 942 // The settings map could be null if the mode was OTR but the OTR profile | |
| 943 // got destroyed before we received this message. | |
| 944 if (!settings_map) | |
| 945 return; | |
| 946 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), | |
| 947 ContentSettingsPattern::Wildcard(), | |
| 948 type, | |
| 949 "", | |
| 950 ContentSettingFromString(setting)); | |
| 951 } | 1152 } |
| 952 | 1153 |
| 953 void ContentSettingsHandler::CheckExceptionPatternValidity( | 1154 void ContentSettingsHandler::CheckExceptionPatternValidity( |
| 954 const ListValue* args) { | 1155 const ListValue* args) { |
| 955 size_t arg_i = 0; | 1156 size_t arg_i = 0; |
| 956 Value* type; | 1157 std::string type_string; |
| 957 CHECK(args->Get(arg_i++, &type)); | 1158 CHECK(args->GetString(arg_i++, &type_string)); |
| 958 std::string mode_string; | 1159 std::string mode_string; |
| 959 CHECK(args->GetString(arg_i++, &mode_string)); | 1160 CHECK(args->GetString(arg_i++, &mode_string)); |
| 960 std::string pattern_string; | 1161 std::string pattern_string; |
| 961 CHECK(args->GetString(arg_i++, &pattern_string)); | 1162 CHECK(args->GetString(arg_i++, &pattern_string)); |
| 962 | 1163 |
| 963 ContentSettingsPattern pattern = | 1164 ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string); |
| 964 ContentSettingsPattern::FromString(pattern_string); | 1165 bool is_valid = false; |
| 1166 if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) { | |
| 1167 is_valid = IsValidHost(pattern_string); | |
| 1168 } else { | |
| 1169 ContentSettingsPattern pattern = | |
| 1170 ContentSettingsPattern::FromString(pattern_string); | |
| 1171 is_valid = pattern.IsValid(); | |
| 1172 } | |
| 965 | 1173 |
| 1174 scoped_ptr<Value> type_value(Value::CreateStringValue(type_string)); | |
| 966 scoped_ptr<Value> mode_value(Value::CreateStringValue(mode_string)); | 1175 scoped_ptr<Value> mode_value(Value::CreateStringValue(mode_string)); |
| 967 scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string)); | 1176 scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string)); |
| 968 scoped_ptr<Value> valid_value(Value::CreateBooleanValue(pattern.IsValid())); | 1177 scoped_ptr<Value> valid_value(Value::CreateBooleanValue(is_valid)); |
| 969 | 1178 |
| 970 web_ui()->CallJavascriptFunction( | 1179 web_ui()->CallJavascriptFunction( |
| 971 "ContentSettings.patternValidityCheckComplete", | 1180 "ContentSettings.patternValidityCheckComplete", |
| 972 *type, | 1181 *type_value.get(), |
| 973 *mode_value.get(), | 1182 *mode_value.get(), |
| 974 *pattern_value.get(), | 1183 *pattern_value.get(), |
| 975 *valid_value.get()); | 1184 *valid_value.get()); |
| 976 } | 1185 } |
| 977 | 1186 |
| 978 // static | 1187 // static |
| 979 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( | 1188 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( |
| 980 ContentSettingsType type) { | 1189 ContentSettingsType type) { |
| 981 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 1190 return ExContentSettingsTypeToGroupName(ExContentSettingsType(type)); |
| 982 if (type == kContentSettingsTypeGroupNames[i].type) | |
| 983 return kContentSettingsTypeGroupNames[i].name; | |
| 984 } | |
| 985 | |
| 986 NOTREACHED(); | |
| 987 return std::string(); | |
| 988 } | 1191 } |
| 989 | 1192 |
| 990 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { | 1193 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { |
| 991 return Profile::FromWebUI(web_ui())->GetHostContentSettingsMap(); | 1194 return Profile::FromWebUI(web_ui())->GetHostContentSettingsMap(); |
| 992 } | 1195 } |
| 993 | 1196 |
| 994 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { | 1197 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { |
| 995 return Profile::FromWebUI(web_ui())->GetProtocolHandlerRegistry(); | 1198 return Profile::FromWebUI(web_ui())->GetProtocolHandlerRegistry(); |
| 996 } | 1199 } |
| 997 | 1200 |
| 998 HostContentSettingsMap* | 1201 HostContentSettingsMap* |
| 999 ContentSettingsHandler::GetOTRContentSettingsMap() { | 1202 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 1000 Profile* profile = Profile::FromWebUI(web_ui()); | 1203 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1001 if (profile->HasOffTheRecordProfile()) | 1204 if (profile->HasOffTheRecordProfile()) |
| 1002 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 1205 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 1003 return NULL; | 1206 return NULL; |
| 1004 } | 1207 } |
| 1005 | 1208 |
| 1209 // static | |
| 1210 ContentSettingsHandler::ExContentSettingsType | |
| 1211 ContentSettingsHandler::ExContentSettingsTypeFromGroupName( | |
| 1212 const std::string& name) { | |
| 1213 COMPILE_ASSERT(arraysize(kExContentSettingsTypeGroupNames) == | |
| 1214 EX_CONTENT_SETTINGS_NUM_TYPES, | |
| 1215 MISSING_CONTENT_SETTINGS_TYPE); | |
| 1216 | |
| 1217 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { | |
| 1218 if (name == kExContentSettingsTypeGroupNames[i].name) | |
| 1219 return kExContentSettingsTypeGroupNames[i].type; | |
| 1220 } | |
| 1221 | |
| 1222 NOTREACHED() << name << " is not a recognized content settings type."; | |
| 1223 return ExContentSettingsType(CONTENT_SETTINGS_TYPE_DEFAULT); | |
| 1224 } | |
| 1225 | |
| 1226 // static | |
| 1227 std::string ContentSettingsHandler::ExContentSettingsTypeToGroupName( | |
| 1228 const ExContentSettingsType& type) { | |
| 1229 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { | |
| 1230 if (type == kExContentSettingsTypeGroupNames[i].type) | |
| 1231 return kExContentSettingsTypeGroupNames[i].name; | |
| 1232 } | |
| 1233 | |
| 1234 NOTREACHED(); | |
| 1235 return std::string(); | |
| 1236 } | |
| 1237 | |
| 1006 } // namespace options2 | 1238 } // namespace options2 |
| OLD | NEW |