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

Side by Side Diff: chrome/browser/extensions/extensions_ui.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Profile helper function, rebase Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extensions_ui.h" 5 #include "chrome/browser/extensions/extensions_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (ShouldShowExtension(*extension)) { 235 if (ShouldShowExtension(*extension)) {
236 extensions_list->Append(CreateExtensionDetailValue( 236 extensions_list->Append(CreateExtensionDetailValue(
237 extension_service_, 237 extension_service_,
238 *extension, 238 *extension,
239 empty_pages, // Terminated process has no active pages. 239 empty_pages, // Terminated process has no active pages.
240 false, true)); // enabled, terminated 240 false, true)); // enabled, terminated
241 } 241 }
242 } 242 }
243 results.Set("extensions", extensions_list); 243 results.Set("extensions", extensions_list);
244 244
245 bool developer_mode = web_ui_->GetProfile()->GetPrefs() 245 bool developer_mode = Profile::FromWebUI(web_ui_)->GetPrefs()->
246 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); 246 GetBoolean(prefs::kExtensionsUIDeveloperMode);
247 results.SetBoolean("developerMode", developer_mode); 247 results.SetBoolean("developerMode", developer_mode);
248 248
249 web_ui_->CallJavascriptFunction("returnExtensionsData", results); 249 web_ui_->CallJavascriptFunction("returnExtensionsData", results);
250 } 250 }
251 251
252 void ExtensionsDOMHandler::RegisterForNotifications() { 252 void ExtensionsDOMHandler::RegisterForNotifications() {
253 // Register for notifications that we need to reload the page. 253 // Register for notifications that we need to reload the page.
254 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 254 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
255 NotificationService::AllSources()); 255 NotificationService::AllSources());
256 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, 256 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED,
(...skipping 18 matching lines...) Expand all
275 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 275 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
276 NotificationService::AllSources()); 276 NotificationService::AllSources());
277 registrar_.Add(this, 277 registrar_.Add(this,
278 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, 278 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
279 NotificationService::AllSources()); 279 NotificationService::AllSources());
280 } 280 }
281 281
282 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() { 282 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() {
283 if (!extension_uninstall_dialog_.get()) { 283 if (!extension_uninstall_dialog_.get()) {
284 extension_uninstall_dialog_.reset( 284 extension_uninstall_dialog_.reset(
285 new ExtensionUninstallDialog(web_ui_->GetProfile())); 285 new ExtensionUninstallDialog(Profile::FromWebUI(web_ui_)));
286 } 286 }
287 return extension_uninstall_dialog_.get(); 287 return extension_uninstall_dialog_.get();
288 } 288 }
289 289
290 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { 290 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) {
291 bool developer_mode = web_ui_->GetProfile()->GetPrefs() 291 Profile* profile = Profile::FromWebUI(web_ui_);
292 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); 292 bool developer_mode =
293 web_ui_->GetProfile()->GetPrefs()->SetBoolean( 293 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
294 prefs::kExtensionsUIDeveloperMode, !developer_mode); 294 profile->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode,
295 !developer_mode);
295 } 296 }
296 297
297 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { 298 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) {
298 std::string render_process_id_str; 299 std::string render_process_id_str;
299 std::string render_view_id_str; 300 std::string render_view_id_str;
300 int render_process_id; 301 int render_process_id;
301 int render_view_id; 302 int render_view_id;
302 CHECK(args->GetSize() == 2); 303 CHECK(args->GetSize() == 2);
303 CHECK(args->GetString(0, &render_process_id_str)); 304 CHECK(args->GetString(0, &render_process_id_str));
304 CHECK(args->GetString(1, &render_view_id_str)); 305 CHECK(args->GetString(1, &render_view_id_str));
(...skipping 26 matching lines...) Expand all
331 if (!Extension::UserMayDisable(extension->location())) { 332 if (!Extension::UserMayDisable(extension->location())) {
332 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was" 333 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was"
333 << "made. Extension id: " << extension->id(); 334 << "made. Extension id: " << extension->id();
334 return; 335 return;
335 } 336 }
336 337
337 if (enable_str == "true") { 338 if (enable_str == "true") {
338 ExtensionPrefs* prefs = extension_service_->extension_prefs(); 339 ExtensionPrefs* prefs = extension_service_->extension_prefs();
339 if (prefs->DidExtensionEscalatePermissions(extension_id)) { 340 if (prefs->DidExtensionEscalatePermissions(extension_id)) {
340 ShowExtensionDisabledDialog(extension_service_, 341 ShowExtensionDisabledDialog(extension_service_,
341 web_ui_->GetProfile(), extension); 342 Profile::FromWebUI(web_ui_), extension);
342 } else { 343 } else {
343 extension_service_->EnableExtension(extension_id); 344 extension_service_->EnableExtension(extension_id);
344 } 345 }
345 } else { 346 } else {
346 extension_service_->DisableExtension(extension_id); 347 extension_service_->DisableExtension(extension_id);
347 } 348 }
348 } 349 }
349 350
350 void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const ListValue* args) { 351 void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const ListValue* args) {
351 CHECK(args->GetSize() == 2); 352 CHECK(args->GetSize() == 2);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 444 }
444 445
445 void ExtensionsDOMHandler::ExtensionDialogCanceled() { 446 void ExtensionsDOMHandler::ExtensionDialogCanceled() {
446 extension_id_prompting_ = ""; 447 extension_id_prompting_ = "";
447 } 448 }
448 449
449 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { 450 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) {
450 const Extension* extension = GetExtension(args); 451 const Extension* extension = GetExtension(args);
451 if (!extension || extension->options_url().is_empty()) 452 if (!extension || extension->options_url().is_empty())
452 return; 453 return;
453 web_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( 454 Profile::FromWebUI(web_ui_)->GetExtensionProcessManager()->OpenOptionsPage(
454 extension, NULL); 455 extension, NULL);
455 } 456 }
456 457
457 void ExtensionsDOMHandler::HandleShowButtonMessage(const ListValue* args) { 458 void ExtensionsDOMHandler::HandleShowButtonMessage(const ListValue* args) {
458 const Extension* extension = GetExtension(args); 459 const Extension* extension = GetExtension(args);
459 extension_service_->SetBrowserActionVisibility(extension, true); 460 extension_service_->SetBrowserActionVisibility(extension, true);
460 } 461 }
461 462
462 void ExtensionsDOMHandler::HandleLoadMessage(const ListValue* args) { 463 void ExtensionsDOMHandler::HandleLoadMessage(const ListValue* args) {
463 FilePath::StringType string_path; 464 FilePath::StringType string_path;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 return ResourceBundle::GetSharedInstance(). 797 return ResourceBundle::GetSharedInstance().
797 LoadDataResourceBytes(IDR_PLUGIN); 798 LoadDataResourceBytes(IDR_PLUGIN);
798 } 799 }
799 800
800 // static 801 // static
801 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { 802 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) {
802 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, 803 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode,
803 false, 804 false,
804 PrefService::SYNCABLE_PREF); 805 PrefService::SYNCABLE_PREF);
805 } 806 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility_util.cc ('k') | chrome/browser/printing/cloud_print/cloud_print_setup_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698