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

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

Issue 2507003005: Implement extension controlled indicators, starting with New Tab page (Closed)
Patch Set: mo hackin' Created 4 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/settings/on_startup_handler.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/logging.h"
10 #include "chrome/browser/extensions/settings_api_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "content/public/browser/web_ui.h"
13 #include "extensions/browser/extension_system.h"
14 #include "extensions/browser/management_policy.h"
15 #include "extensions/common/extension.h"
16
17 namespace settings {
18
19 OnStartupHandler::OnStartupHandler() {}
dpapad 2016/11/17 01:16:46 Same question here. Can we just use the existing h
Dan Beam 2016/11/17 02:51:47 Acknowledged.
20 OnStartupHandler::~OnStartupHandler() {}
21
22 void OnStartupHandler::RegisterMessages() {
23 web_ui()->RegisterMessageCallback("getNtpExtension",
24 base::Bind(&OnStartupHandler::HandleGetNtpExtension,
25 base::Unretained(this)));
26 }
27
28 void OnStartupHandler::HandleGetNtpExtension(
29 const base::ListValue* args) {
30 const base::Value* callback_id;
31 CHECK(args->Get(0, &callback_id));
32
33 AllowJavascript();
34
35 Profile* profile = Profile::FromWebUI(web_ui());
36 const extensions::Extension* ntp_extension =
37 extensions::GetExtensionOverridingNewTabPage(profile);
38
39 if (!ntp_extension) {
40 ResolveJavascriptCallback(*callback_id, *base::Value::CreateNullValue());
41 return;
42 }
43
44 base::DictionaryValue dict;
45 dict.SetString("id", ntp_extension->id());
46 dict.SetString("name", ntp_extension->name());
47 dict.SetBoolean("canBeDisabled", !extensions::ExtensionSystem::Get(profile)
48 ->management_policy()->MustRemainEnabled(ntp_extension, nullptr));
dpapad 2016/11/17 01:50:07 Nit: Having the "->" on this line instead of previ
Dan Beam 2016/11/17 02:51:47 Done.
49 ResolveJavascriptCallback(*callback_id, dict);
50 }
51
52 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698