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

Side by Side Diff: chrome/browser/ui/webui/options2/media_galleries_handler.cc

Issue 10821077: Add gallery permissions to Media Galleries Preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 4 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 (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/media_galleries_handler.h" 5 #include "chrome/browser/ui/webui/options2/media_galleries_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/media_gallery/media_galleries_preferences.h" 8 #include "chrome/browser/media_gallery/media_galleries_preferences.h"
9 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" 9 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 23 matching lines...) Expand all
34 { "manageGalleriesButton", IDS_MEDIA_GALLERY_MANAGE_BUTTON }, 34 { "manageGalleriesButton", IDS_MEDIA_GALLERY_MANAGE_BUTTON },
35 { "addNewGalleryButton", IDS_MEDIA_GALLERY_ADD_NEW_BUTTON }, 35 { "addNewGalleryButton", IDS_MEDIA_GALLERY_ADD_NEW_BUTTON },
36 }; 36 };
37 37
38 RegisterStrings(values, resources, arraysize(resources)); 38 RegisterStrings(values, resources, arraysize(resources));
39 RegisterTitle(values, "manageMediaGalleries", 39 RegisterTitle(values, "manageMediaGalleries",
40 IDS_MEDIA_GALLERY_MANAGE_TITLE); 40 IDS_MEDIA_GALLERY_MANAGE_TITLE);
41 } 41 }
42 42
43 void MediaGalleriesHandler::InitializeHandler() { 43 void MediaGalleriesHandler::InitializeHandler() {
44 if (!MediaGalleriesPreferences::UserInteractionIsEnabled()) 44 if (!chrome::MediaGalleriesPreferences::UserInteractionIsEnabled())
45 return; 45 return;
46 46
47 Profile* profile = Profile::FromWebUI(web_ui()); 47 Profile* profile = Profile::FromWebUI(web_ui());
48 pref_change_registrar_.Init(profile->GetPrefs()); 48 pref_change_registrar_.Init(profile->GetPrefs());
49 pref_change_registrar_.Add(prefs::kMediaGalleriesRememberedGalleries, this); 49 pref_change_registrar_.Add(prefs::kMediaGalleriesRememberedGalleries, this);
50 } 50 }
51 51
52 void MediaGalleriesHandler::InitializePage() { 52 void MediaGalleriesHandler::InitializePage() {
53 if (!MediaGalleriesPreferences::UserInteractionIsEnabled()) 53 if (!chrome::MediaGalleriesPreferences::UserInteractionIsEnabled())
54 return; 54 return;
55 55
56 OnGalleriesChanged(); 56 OnGalleriesChanged();
57 } 57 }
58 58
59 void MediaGalleriesHandler::RegisterMessages() { 59 void MediaGalleriesHandler::RegisterMessages() {
60 web_ui()->RegisterMessageCallback( 60 web_ui()->RegisterMessageCallback(
61 "addNewGallery", 61 "addNewGallery",
62 base::Bind(&MediaGalleriesHandler::HandleAddNewGallery, 62 base::Bind(&MediaGalleriesHandler::HandleAddNewGallery,
63 base::Unretained(this))); 63 base::Unretained(this)));
(...skipping 22 matching lines...) Expand all
86 FilePath::StringType(), 86 FilePath::StringType(),
87 web_ui()->GetWebContents()->GetView()-> 87 web_ui()->GetWebContents()->GetView()->
88 GetTopLevelNativeWindow(), 88 GetTopLevelNativeWindow(),
89 NULL); 89 NULL);
90 } 90 }
91 91
92 void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) { 92 void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) {
93 // TODO(estade): use uint64. 93 // TODO(estade): use uint64.
94 int id; 94 int id;
95 CHECK(ExtractIntegerValue(args, &id)); 95 CHECK(ExtractIntegerValue(args, &id));
96 MediaGalleriesPreferences* prefs = 96 chrome::MediaGalleriesPreferences* prefs =
97 MediaGalleriesPreferencesFactory::GetForProfile( 97 MediaGalleriesPreferencesFactory::GetForProfile(
98 Profile::FromWebUI(web_ui())); 98 Profile::FromWebUI(web_ui()));
99 prefs->ForgetGalleryById(id); 99 prefs->ForgetGalleryById(id);
100 } 100 }
101 101
102 void MediaGalleriesHandler::FileSelected( 102 void MediaGalleriesHandler::FileSelected(
103 const FilePath& path, int index, void* params) { 103 const FilePath& path, int index, void* params) {
104 MediaGalleriesPreferences* prefs = 104 chrome::MediaGalleriesPreferences* prefs =
105 MediaGalleriesPreferencesFactory::GetForProfile( 105 MediaGalleriesPreferencesFactory::GetForProfile(
106 Profile::FromWebUI(web_ui())); 106 Profile::FromWebUI(web_ui()));
107 prefs->AddGalleryByPath(path); 107 prefs->AddGalleryByPath(path);
108 } 108 }
109 109
110 void MediaGalleriesHandler::Observe( 110 void MediaGalleriesHandler::Observe(
111 int type, 111 int type,
112 const content::NotificationSource& source, 112 const content::NotificationSource& source,
113 const content::NotificationDetails& details) { 113 const content::NotificationDetails& details) {
114 if (type == chrome::NOTIFICATION_PREF_CHANGED && 114 if (type == chrome::NOTIFICATION_PREF_CHANGED &&
115 *content::Details<std::string>(details).ptr() == 115 *content::Details<std::string>(details).ptr() ==
116 prefs::kMediaGalleriesRememberedGalleries) { 116 prefs::kMediaGalleriesRememberedGalleries) {
117 OnGalleriesChanged(); 117 OnGalleriesChanged();
118 } else { 118 } else {
119 NOTREACHED(); 119 NOTREACHED();
120 } 120 }
121 } 121 }
122 122
123 } // namespace options2 123 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_galleries_preferences_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698