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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix UserScriptListenerTests.MultiProfile Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.cc ('k') | 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 (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/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "apps/metrics_names.h" 9 #include "apps/metrics_names.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 GURL icon_small = extensions::ExtensionIconSource::GetIconURL( 152 GURL icon_small = extensions::ExtensionIconSource::GetIconURL(
153 extension, 153 extension,
154 extension_misc::EXTENSION_ICON_BITTY, 154 extension_misc::EXTENSION_ICON_BITTY,
155 ExtensionIconSet::MATCH_BIGGER, 155 ExtensionIconSet::MATCH_BIGGER,
156 false, 156 false,
157 &icon_small_exists); 157 &icon_small_exists);
158 value->SetString("icon_small", icon_small.spec()); 158 value->SetString("icon_small", icon_small.spec());
159 value->SetBoolean("icon_small_exists", icon_small_exists); 159 value->SetBoolean("icon_small_exists", icon_small_exists);
160 value->SetInteger("launch_container", 160 value->SetInteger("launch_container",
161 extensions::AppLaunchInfo::GetLaunchContainer(extension)); 161 extensions::AppLaunchInfo::GetLaunchContainer(extension));
162 ExtensionPrefs* prefs = service->extension_prefs(); 162 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile());
163 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension)); 163 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension));
164 value->SetBoolean("is_component", 164 value->SetBoolean("is_component",
165 extension->location() == extensions::Manifest::COMPONENT); 165 extension->location() == extensions::Manifest::COMPONENT);
166 value->SetBoolean("is_webstore", 166 value->SetBoolean("is_webstore",
167 extension->id() == extension_misc::kWebStoreAppId); 167 extension->id() == extension_misc::kWebStoreAppId);
168 168
169 AppSorting* sorting = prefs->app_sorting(); 169 AppSorting* sorting = prefs->app_sorting();
170 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); 170 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id());
171 if (!page_ordinal.IsValid()) { 171 if (!page_ordinal.IsValid()) {
172 // Make sure every app has a page ordinal (some predate the page ordinal). 172 // Make sure every app has a page ordinal (some predate the page ordinal).
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return; 264 return;
265 265
266 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 266 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
267 if (!ShouldDisplayInNewTabPage(extension, prefs)) 267 if (!ShouldDisplayInNewTabPage(extension, prefs))
268 return; 268 return;
269 269
270 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); 270 scoped_ptr<base::DictionaryValue> app_info(GetAppInfo(extension));
271 if (app_info.get()) { 271 if (app_info.get()) {
272 visible_apps_.insert(extension->id()); 272 visible_apps_.insert(extension->id());
273 273
274 ExtensionPrefs* prefs = extension_service_->extension_prefs(); 274 ExtensionPrefs* prefs =
275 ExtensionPrefs::Get(extension_service_->profile());
275 scoped_ptr<base::FundamentalValue> highlight( 276 scoped_ptr<base::FundamentalValue> highlight(
276 base::Value::CreateBooleanValue( 277 base::Value::CreateBooleanValue(
277 prefs->IsFromBookmark(extension->id()) && 278 prefs->IsFromBookmark(extension->id()) &&
278 attempted_bookmark_app_install_)); 279 attempted_bookmark_app_install_));
279 attempted_bookmark_app_install_ = false; 280 attempted_bookmark_app_install_ = false;
280 web_ui()->CallJavascriptFunction( 281 web_ui()->CallJavascriptFunction(
281 "ntp.appAdded", *app_info, *highlight); 282 "ntp.appAdded", *app_info, *highlight);
282 } 283 }
283 284
284 break; 285 break;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 FillAppDictionary(&dictionary); 458 FillAppDictionary(&dictionary);
458 web_ui()->CallJavascriptFunction("ntp.getAppsCallback", dictionary); 459 web_ui()->CallJavascriptFunction("ntp.getAppsCallback", dictionary);
459 460
460 // First time we get here we set up the observer so that we can tell update 461 // First time we get here we set up the observer so that we can tell update
461 // the apps as they change. 462 // the apps as they change.
462 if (!has_loaded_apps_) { 463 if (!has_loaded_apps_) {
463 base::Closure callback = base::Bind( 464 base::Closure callback = base::Bind(
464 &AppLauncherHandler::OnExtensionPreferenceChanged, 465 &AppLauncherHandler::OnExtensionPreferenceChanged,
465 base::Unretained(this)); 466 base::Unretained(this));
466 extension_pref_change_registrar_.Init( 467 extension_pref_change_registrar_.Init(
467 extension_service_->extension_prefs()->pref_service()); 468 ExtensionPrefs::Get(profile)->pref_service());
468 extension_pref_change_registrar_.Add( 469 extension_pref_change_registrar_.Add(
469 extensions::pref_names::kExtensions, callback); 470 extensions::pref_names::kExtensions, callback);
470 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback); 471 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback);
471 472
472 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 473 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
473 content::Source<Profile>(profile)); 474 content::Source<Profile>(profile));
474 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 475 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
475 content::Source<Profile>(profile)); 476 content::Source<Profile>(profile));
476 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 477 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
477 content::Source<Profile>(profile)); 478 content::Source<Profile>(profile));
478 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, 479 registrar_.Add(this,
479 content::Source<AppSorting>( 480 chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
480 extension_service_->extension_prefs()->app_sorting())); 481 content::Source<AppSorting>(
482 ExtensionPrefs::Get(profile)->app_sorting()));
481 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, 483 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
482 content::Source<CrxInstaller>(NULL)); 484 content::Source<CrxInstaller>(NULL));
483 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, 485 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR,
484 content::Source<Profile>(profile)); 486 content::Source<Profile>(profile));
485 } 487 }
486 488
487 has_loaded_apps_ = true; 489 has_loaded_apps_ = true;
488 } 490 }
489 491
490 void AppLauncherHandler::HandleLaunchApp(const base::ListValue* args) { 492 void AppLauncherHandler::HandleLaunchApp(const base::ListValue* args) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 if (i > 0) 638 if (i > 0)
637 CHECK(app_order->GetString(i - 1, &predecessor_to_moved_ext)); 639 CHECK(app_order->GetString(i - 1, &predecessor_to_moved_ext));
638 if (i + 1 < app_order->GetSize()) 640 if (i + 1 < app_order->GetSize())
639 CHECK(app_order->GetString(i + 1, &successor_to_moved_ext)); 641 CHECK(app_order->GetString(i + 1, &successor_to_moved_ext));
640 break; 642 break;
641 } 643 }
642 } 644 }
643 645
644 // Don't update the page; it already knows the apps have been reordered. 646 // Don't update the page; it already knows the apps have been reordered.
645 base::AutoReset<bool> auto_reset(&ignore_changes_, true); 647 base::AutoReset<bool> auto_reset(&ignore_changes_, true);
646 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); 648 ExtensionPrefs::Get(extension_service_->profile())
649 ->SetAppDraggedByUser(dragged_app_id);
647 extension_service_->OnExtensionMoved(dragged_app_id, 650 extension_service_->OnExtensionMoved(dragged_app_id,
648 predecessor_to_moved_ext, 651 predecessor_to_moved_ext,
649 successor_to_moved_ext); 652 successor_to_moved_ext);
650 } 653 }
651 654
652 void AppLauncherHandler::HandleSetPageIndex(const base::ListValue* args) { 655 void AppLauncherHandler::HandleSetPageIndex(const base::ListValue* args) {
653 AppSorting* app_sorting = 656 AppSorting* app_sorting =
654 extension_service_->extension_prefs()->app_sorting(); 657 ExtensionPrefs::Get(extension_service_->profile())->app_sorting();
655 658
656 std::string extension_id; 659 std::string extension_id;
657 double page_index; 660 double page_index;
658 CHECK(args->GetString(0, &extension_id)); 661 CHECK(args->GetString(0, &extension_id));
659 CHECK(args->GetDouble(1, &page_index)); 662 CHECK(args->GetDouble(1, &page_index));
660 const syncer::StringOrdinal& page_ordinal = 663 const syncer::StringOrdinal& page_ordinal =
661 app_sorting->PageIntegerAsStringOrdinal(static_cast<size_t>(page_index)); 664 app_sorting->PageIntegerAsStringOrdinal(static_cast<size_t>(page_index));
662 665
663 // Don't update the page; it already knows the apps have been reordered. 666 // Don't update the page; it already knows the apps have been reordered.
664 base::AutoReset<bool> auto_reset(&ignore_changes_, true); 667 base::AutoReset<bool> auto_reset(&ignore_changes_, true);
(...skipping 18 matching lines...) Expand all
683 std::string url; 686 std::string url;
684 CHECK(args->GetString(0, &url)); 687 CHECK(args->GetString(0, &url));
685 GURL launch_url(url); 688 GURL launch_url(url);
686 689
687 base::string16 title; 690 base::string16 title;
688 CHECK(args->GetString(1, &title)); 691 CHECK(args->GetString(1, &title));
689 692
690 double page_index; 693 double page_index;
691 CHECK(args->GetDouble(2, &page_index)); 694 CHECK(args->GetDouble(2, &page_index));
692 AppSorting* app_sorting = 695 AppSorting* app_sorting =
693 extension_service_->extension_prefs()->app_sorting(); 696 ExtensionPrefs::Get(extension_service_->profile())->app_sorting();
694 const syncer::StringOrdinal& page_ordinal = 697 const syncer::StringOrdinal& page_ordinal =
695 app_sorting->PageIntegerAsStringOrdinal(static_cast<size_t>(page_index)); 698 app_sorting->PageIntegerAsStringOrdinal(static_cast<size_t>(page_index));
696 699
697 Profile* profile = Profile::FromWebUI(web_ui()); 700 Profile* profile = Profile::FromWebUI(web_ui());
698 FaviconService* favicon_service = 701 FaviconService* favicon_service =
699 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); 702 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
700 if (!favicon_service) { 703 if (!favicon_service) {
701 LOG(ERROR) << "No favicon service"; 704 LOG(ERROR) << "No favicon service";
702 return; 705 return;
703 } 706 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { 848 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() {
846 if (!extension_uninstall_dialog_.get()) { 849 if (!extension_uninstall_dialog_.get()) {
847 Browser* browser = chrome::FindBrowserWithWebContents( 850 Browser* browser = chrome::FindBrowserWithWebContents(
848 web_ui()->GetWebContents()); 851 web_ui()->GetWebContents());
849 extension_uninstall_dialog_.reset( 852 extension_uninstall_dialog_.reset(
850 ExtensionUninstallDialog::Create(extension_service_->profile(), 853 ExtensionUninstallDialog::Create(extension_service_->profile(),
851 browser, this)); 854 browser, this));
852 } 855 }
853 return extension_uninstall_dialog_.get(); 856 return extension_uninstall_dialog_.get();
854 } 857 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_settings_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698