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

Side by Side Diff: chrome/browser/dom_ui/tips_handler.cc

Issue 131094: Add GetMessageHandlers to HtmlDialogUIDelegate to allow... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/dom_ui/tips_handler.h ('k') | chrome/browser/extensions/extensions_ui.h » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/dom_ui/tips_handler.h" 7 #include "chrome/browser/dom_ui/tips_handler.h"
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/web_resource/web_resource_service.h" 9 #include "chrome/browser/web_resource/web_resource_service.h"
10 #include "chrome/common/web_resource/web_resource_unpacker.h" 10 #include "chrome/common/web_resource/web_resource_unpacker.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 12
13 namespace { 13 namespace {
14 14
15 const int kNumTipsToShow = 2; 15 const int kNumTipsToShow = 2;
16 16
17 // TODO(mrc): l10n 17 // TODO(mrc): l10n
18 // This title should only appear the very first time Chrome is run with 18 // This title should only appear the very first time Chrome is run with
19 // web resources enabled; otherwise the cache should be populated. 19 // web resources enabled; otherwise the cache should be populated.
20 static const wchar_t* kTipsTitleAtStartup = 20 static const wchar_t* kTipsTitleAtStartup =
21 L"Tips and recommendations to help you discover interesting websites."; 21 L"Tips and recommendations to help you discover interesting websites.";
22 } 22 }
23 23
24 TipsHandler::TipsHandler(DOMUI* dom_ui) 24 DOMMessageHandler* TipsHandler::Attach(DOMUI* dom_ui) {
25 : DOMMessageHandler(dom_ui),
26 dom_ui_(dom_ui) {
27 dom_ui->RegisterMessageCallback("getTips",
28 NewCallback(this, &TipsHandler::HandleGetTips));
29
30 tips_cache_ = dom_ui_->GetProfile()->GetPrefs()-> 25 tips_cache_ = dom_ui_->GetProfile()->GetPrefs()->
31 GetDictionary(prefs::kNTPTipsCache); 26 GetDictionary(prefs::kNTPTipsCache);
27 return DOMMessageHandler::Attach(dom_ui);
28 }
29
30 void TipsHandler::RegisterMessages() {
31 dom_ui_->RegisterMessageCallback("getTips",
32 NewCallback(this, &TipsHandler::HandleGetTips));
32 } 33 }
33 34
34 void TipsHandler::HandleGetTips(const Value* content) { 35 void TipsHandler::HandleGetTips(const Value* content) {
35 // List containing the tips to be displayed. 36 // List containing the tips to be displayed.
36 ListValue list_value; 37 ListValue list_value;
37 38
38 // Holds the web resource data found in the preferences cache. 39 // Holds the web resource data found in the preferences cache.
39 DictionaryValue* wr_dict; 40 DictionaryValue* wr_dict;
40 41
41 // These values hold the data for each web resource item. As the web 42 // These values hold the data for each web resource item. As the web
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 74 }
74 75
75 // static 76 // static
76 void TipsHandler::RegisterUserPrefs(PrefService* prefs) { 77 void TipsHandler::RegisterUserPrefs(PrefService* prefs) {
77 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache); 78 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache);
78 prefs->RegisterStringPref(prefs::kNTPTipsServer, 79 prefs->RegisterStringPref(prefs::kNTPTipsServer,
79 WebResourceService::kDefaultResourceServer); 80 WebResourceService::kDefaultResourceServer);
80 } 81 }
81 82
82 83
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/tips_handler.h ('k') | chrome/browser/extensions/extensions_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698