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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 10196004: Changed ChromeURLDataManager to a ProfileKeyedService and made a Factory for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed style nit Created 8 years, 8 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
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/sync_promo/sync_promo_ui.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/first_run/first_run.h" 11 #include "chrome/browser/first_run/first_run.h"
12 #include "chrome/browser/google/google_util.h" 12 #include "chrome/browser/google/google_util.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_info_cache.h" 15 #include "chrome/browser/profiles/profile_info_cache.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 17 #include "chrome/browser/sync/profile_sync_service.h"
18 #include "chrome/browser/sync/profile_sync_service_factory.h" 18 #include "chrome/browser/sync/profile_sync_service_factory.h"
19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 19 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h"
20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
21 #include "chrome/browser/ui/webui/options2/core_options_handler2.h" 21 #include "chrome/browser/ui/webui/options2/core_options_handler2.h"
22 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" 22 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
23 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" 23 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
24 #include "chrome/browser/ui/webui/theme_source.h" 24 #include "chrome/browser/ui/webui/theme_source.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } // namespace 105 } // namespace
106 106
107 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) { 107 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) {
108 SyncPromoHandler* handler = new SyncPromoHandler( 108 SyncPromoHandler* handler = new SyncPromoHandler(
109 g_browser_process->profile_manager()); 109 g_browser_process->profile_manager());
110 web_ui->AddMessageHandler(handler); 110 web_ui->AddMessageHandler(handler);
111 111
112 // Set up the chrome://theme/ source. 112 // Set up the chrome://theme/ source.
113 Profile* profile = Profile::FromWebUI(web_ui); 113 Profile* profile = Profile::FromWebUI(web_ui);
114 ThemeSource* theme = new ThemeSource(profile); 114 ThemeSource* theme = new ThemeSource(profile);
115 profile->GetChromeURLDataManager()->AddDataSource(theme); 115 ChromeURLDataManagerFactory::GetForProfile(profile)->AddDataSource(theme);
116 116
117 // Set up the sync promo source. 117 // Set up the sync promo source.
118 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(web_ui); 118 SyncPromoUIHTMLSource* html_source = new SyncPromoUIHTMLSource(web_ui);
119 html_source->set_json_path(kStringsJsFile); 119 html_source->set_json_path(kStringsJsFile);
120 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS); 120 html_source->add_resource_path(kSyncPromoJsFile, IDR_SYNC_PROMO_JS);
121 html_source->set_default_resource(IDR_SYNC_PROMO_HTML); 121 html_source->set_default_resource(IDR_SYNC_PROMO_HTML);
122 profile->GetChromeURLDataManager()->AddDataSource(html_source); 122 ChromeURLDataManagerFactory::GetForProfile(profile)->
123 AddDataSource(html_source);
123 124
124 sync_promo_trial::RecordUserShownPromo(web_ui); 125 sync_promo_trial::RecordUserShownPromo(web_ui);
125 } 126 }
126 127
127 // static 128 // static
128 bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) { 129 bool SyncPromoUI::HasShownPromoAtStartup(Profile* profile) {
129 return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount); 130 return profile->GetPrefs()->HasPrefPath(prefs::kSyncPromoStartupCount);
130 } 131 }
131 132
132 // static 133 // static
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 std::string value; 263 std::string value;
263 if (GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) { 264 if (GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) {
264 int source = 0; 265 int source = 0;
265 if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE && 266 if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
266 source < SOURCE_UNKNOWN) { 267 source < SOURCE_UNKNOWN) {
267 return static_cast<Source>(source); 268 return static_cast<Source>(source);
268 } 269 }
269 } 270 }
270 return SOURCE_UNKNOWN; 271 return SOURCE_UNKNOWN;
271 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698