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

Side by Side Diff: chrome/browser/content_settings/permission_context_base.cc

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/content_settings/permission_context_base.h" 5 #include "chrome/browser/content_settings/permission_context_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
11 #include "chrome/browser/content_settings/permission_bubble_request_impl.h" 11 #include "chrome/browser/content_settings/permission_bubble_request_impl.h"
12 #include "chrome/browser/content_settings/permission_queue_controller.h" 12 #include "chrome/browser/content_settings/permission_queue_controller.h"
13 #include "chrome/browser/content_settings/permission_request_id.h" 13 #include "chrome/browser/content_settings/permission_request_id.h"
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 16 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 22
23 // Enum for UMA purposes, make sure you update histograms.xml if you 23 // Enum for UMA purposes, make sure you update histograms.xml if you
24 // add new pemissions. Never delete or reorder 24 // add new pemissions. Never delete or reorder
25 // an entry; only add new entries immediately before PERMISSION_NUM 25 // an entry; only add new entries immediately before PERMISSION_NUM
26 enum PermissionType { 26 enum PermissionType {
27 PERMISSION_UNKNOWN = 0, 27 PERMISSION_UNKNOWN = 0,
28 PERMISSION_MIDI_SYSEX = 1, 28 PERMISSION_MIDI_SYSEX = 1,
29 PERMISSION_PUSH_MESSAGING = 2, 29 PERMISSION_PUSH_MESSAGING = 2,
30 PERMISSION_NOTIFICATIONS = 3,
30 31
31 // Always keep this at the end. 32 // Always keep this at the end.
32 PERMISSION_NUM, 33 PERMISSION_NUM,
33 }; 34 };
34 35
35 namespace { 36 namespace {
36 37
37 // Helper function for UMA tracking purposes. 38 // Helper function for UMA tracking purposes.
38 PermissionType SettingToPermission(ContentSettingsType permission) { 39 PermissionType SettingToPermission(ContentSettingsType permission) {
39 switch (permission) { 40 switch (permission) {
40 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 41 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
41 return PERMISSION_MIDI_SYSEX; 42 return PERMISSION_MIDI_SYSEX;
42 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: 43 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
43 return PERMISSION_PUSH_MESSAGING; 44 return PERMISSION_PUSH_MESSAGING;
45 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
46 return PERMISSION_NOTIFICATIONS;
44 default: 47 default:
45 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; 48 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
46 } 49 }
47 return PERMISSION_UNKNOWN; 50 return PERMISSION_UNKNOWN;
48 } 51 }
49 52
50 } // namespace 53 } // namespace
51 54
52 PermissionContextBase::PermissionContextBase( 55 PermissionContextBase::PermissionContextBase(
53 Profile* profile, 56 Profile* profile,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 DCHECK_EQ(embedder_origin, embedder_origin.GetOrigin()); 208 DCHECK_EQ(embedder_origin, embedder_origin.GetOrigin());
206 ContentSetting content_setting = 209 ContentSetting content_setting =
207 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 210 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
208 profile_->GetHostContentSettingsMap()->SetContentSetting( 211 profile_->GetHostContentSettingsMap()->SetContentSetting(
209 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), 212 ContentSettingsPattern::FromURLNoWildcard(requesting_origin),
210 ContentSettingsPattern::FromURLNoWildcard(embedder_origin), 213 ContentSettingsPattern::FromURLNoWildcard(embedder_origin),
211 permission_type_, 214 permission_type_,
212 std::string(), 215 std::string(),
213 content_setting); 216 content_setting);
214 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698