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

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler.cc

Issue 2679453002: MD Settings: CrOS: Use correct profile for Guest mode content settings (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/site_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 19 matching lines...) Expand all
30 #include "content/public/common/page_zoom.h" 30 #include "content/public/common/page_zoom.h"
31 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
32 #include "extensions/browser/extension_registry.h" 32 #include "extensions/browser/extension_registry.h"
33 #include "extensions/common/permissions/api_permission.h" 33 #include "extensions/common/permissions/api_permission.h"
34 #include "extensions/common/permissions/permissions_data.h" 34 #include "extensions/common/permissions/permissions_data.h"
35 #include "storage/browser/quota/quota_manager.h" 35 #include "storage/browser/quota/quota_manager.h"
36 #include "storage/common/quota/quota_status_code.h" 36 #include "storage/common/quota/quota_status_code.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/text/bytes_formatting.h" 38 #include "ui/base/text/bytes_formatting.h"
39 39
40 #if defined(OS_CHROMEOS)
41 #include "components/user_manager/user_manager.h"
42 #endif
43
40 namespace settings { 44 namespace settings {
41 45
42 namespace { 46 namespace {
43 47
44 const char kZoom[] = "zoom"; 48 const char kZoom[] = "zoom";
45 49
46 // Return an appropriate API Permission ID for the given string name. 50 // Return an appropriate API Permission ID for the given string name.
47 extensions::APIPermission::APIPermission::ID APIPermissionFromGroupName( 51 extensions::APIPermission::APIPermission::ID APIPermissionFromGroupName(
48 std::string type) { 52 std::string type) {
49 // Once there are more than two groups to consider, this should be changed to 53 // Once there are more than two groups to consider, this should be changed to
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 void SiteSettingsHandler::HandleSetDefaultValueForContentType( 371 void SiteSettingsHandler::HandleSetDefaultValueForContentType(
368 const base::ListValue* args) { 372 const base::ListValue* args) {
369 CHECK_EQ(2U, args->GetSize()); 373 CHECK_EQ(2U, args->GetSize());
370 std::string content_type; 374 std::string content_type;
371 CHECK(args->GetString(0, &content_type)); 375 CHECK(args->GetString(0, &content_type));
372 std::string setting; 376 std::string setting;
373 CHECK(args->GetString(1, &setting)); 377 CHECK(args->GetString(1, &setting));
374 ContentSetting default_setting; 378 ContentSetting default_setting;
375 CHECK(content_settings::ContentSettingFromString(setting, &default_setting)); 379 CHECK(content_settings::ContentSettingFromString(setting, &default_setting));
376 380
381 Profile* profile = profile_;
382 #if defined(OS_CHROMEOS)
383 // ChromeOS special case : in Guest mode settings are opened in Incognito
dschuyler 2017/02/06 20:19:19 nit: no space before colon here ("case:"). (Oh, an
stevenjb 2017/02/07 01:30:12 Done. (I copy/pasted this)
384 // mode, so we need original profile to actually modify settings.
dschuyler 2017/02/06 20:19:19 ? "need the original"
stevenjb 2017/02/07 01:30:12 Done.
385 if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
386 profile = profile->GetOriginalProfile();
387 #endif
377 HostContentSettingsMap* map = 388 HostContentSettingsMap* map =
378 HostContentSettingsMapFactory::GetForProfile(profile_); 389 HostContentSettingsMapFactory::GetForProfile(profile);
379 map->SetDefaultContentSetting( 390 map->SetDefaultContentSetting(
380 static_cast<ContentSettingsType>(static_cast<int>( 391 static_cast<ContentSettingsType>(static_cast<int>(
381 site_settings::ContentSettingsTypeFromGroupName(content_type))), 392 site_settings::ContentSettingsTypeFromGroupName(content_type))),
382 default_setting); 393 default_setting);
383 } 394 }
384 395
385 void SiteSettingsHandler::HandleGetDefaultValueForContentType( 396 void SiteSettingsHandler::HandleGetDefaultValueForContentType(
386 const base::ListValue* args) { 397 const base::ListValue* args) {
387 AllowJavascript(); 398 AllowJavascript();
388 399
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 origin = content::kUnreachableWebDataURL; 719 origin = content::kUnreachableWebDataURL;
709 } 720 }
710 721
711 content::HostZoomMap* host_zoom_map; 722 content::HostZoomMap* host_zoom_map;
712 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_); 723 host_zoom_map = content::HostZoomMap::GetDefaultForBrowserContext(profile_);
713 double default_level = host_zoom_map->GetDefaultZoomLevel(); 724 double default_level = host_zoom_map->GetDefaultZoomLevel();
714 host_zoom_map->SetZoomLevelForHost(origin, default_level); 725 host_zoom_map->SetZoomLevelForHost(origin, default_level);
715 } 726 }
716 727
717 } // namespace settings 728 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698