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

Side by Side Diff: chrome/browser/ui/webui/new_profile_ui.cc

Issue 7256002: Multi-Profiles: New Profile Setup UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 5 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/new_profile_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/new_profile_ui.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "base/time.h"
9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
13 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
14 #include "chrome/browser/ui/webui/new_profile_handler.h"
15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/url_constants.h"
17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "grit/browser_resources.h"
19 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h"
22 #include "ui/base/l10n/l10n_util.h"
23
24 namespace {
25
26 const char kStringsJsFile[] = "strings.js";
27 const char kNewProfileJsFile[] = "new_profile.js";
28
29 // Checks if this is the current time within a given date range?
30 bool InDateRange(double begin, double end) {
31 base::Time start_time = base::Time::FromDoubleT(begin);
32 base::Time end_time = base::Time::FromDoubleT(end);
33 return start_time < base::Time::Now() && end_time > base::Time::Now();
34 }
35
36 ///////////////////////////////////////////////////////////////////////////////
37 //
38 // NewProfileUIHTMLSource
39 //
40 ///////////////////////////////////////////////////////////////////////////////
41
42 class NewProfileUIHTMLSource : public ChromeWebUIDataSource {
43 public:
44 explicit NewProfileUIHTMLSource(Profile* profile);
45
46 private:
47 ~NewProfileUIHTMLSource() {}
48 DISALLOW_COPY_AND_ASSIGN(NewProfileUIHTMLSource);
49 };
50
51 NewProfileUIHTMLSource::NewProfileUIHTMLSource(Profile* profile)
52 : ChromeWebUIDataSource(chrome::kChromeUINewProfileHost) {
53 AddLocalizedString("title", IDS_NEW_PROFILE_SETUP_TITLE);
54 AddLocalizedString("createProfile", IDS_NEW_PROFILE_SETUP_CREATE_PROFILE);
55 AddLocalizedString("cancelProfile", IDS_NEW_PROFILE_SETUP_CANCEL_PROFILE);
56 AddLocalizedString("profileNameLabel", IDS_NEW_PROFILE_SETUP_NAME_LABEL);
57 AddLocalizedString("profileIconLabel", IDS_NEW_PROFILE_SETUP_ICON_LABEL);
58 AddLocalizedString("summaryConclusion",
59 IDS_NEW_PROFILE_SETUP_SUMMARY_CONCLUSION);
60
61 const string16 short_product_name =
62 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
63 AddString("summaryTitle", l10n_util::GetStringFUTF16(
64 IDS_NEW_PROFILE_SETUP_SUMMARY_TITLE, short_product_name));
65 AddString("summaryBody", l10n_util::GetStringFUTF16(
66 IDS_NEW_PROFILE_SETUP_SUMMARY_BODY, short_product_name));
67
68 // If the user has preferences for a start and end time for a custom logo,
69 // and the time now is between these two times, show the custom logo.
70 // TODO(sail): We should also update the logo if the theme changes or
71 // if these prefs change.
72 // TODO(sail): This code is copy pasted from the NTP code. This should be
73 // refactored.
74 bool hasCustomLogo =
75 profile->GetPrefs()->FindPreference(prefs::kNTPCustomLogoStart) &&
76 profile->GetPrefs()->FindPreference(prefs::kNTPCustomLogoEnd) &&
77 InDateRange(profile->GetPrefs()->GetDouble(prefs::kNTPCustomLogoStart),
78 profile->GetPrefs()->GetDouble(prefs::kNTPCustomLogoEnd));
79 AddString("customlogo", ASCIIToUTF16(hasCustomLogo ? "true" : "false"));
80 }
81
82 } // namespace
83
84 ///////////////////////////////////////////////////////////////////////////////
85 //
86 // NewProfileUI
87 //
88 ///////////////////////////////////////////////////////////////////////////////
89
90 NewProfileUI::NewProfileUI(TabContents* contents) : ChromeWebUI(contents) {
91 should_hide_url_ = true;
92
93 NewProfileHandler* handler = new NewProfileHandler();
94 AddMessageHandler(handler);
95 handler->Attach(this);
96
97 // Set up the new profile source.
98 NewProfileUIHTMLSource* html_source =
99 new NewProfileUIHTMLSource(GetProfile());
100 html_source->set_json_path(kStringsJsFile);
101 html_source->add_resource_path(kNewProfileJsFile, IDR_NEW_PROFILE_JS);
102 html_source->set_default_resource(IDR_NEW_PROFILE_HTML);
103 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
104 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/new_profile_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698