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

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

Issue 7399015: Sync Promo: Add a way to collapse the sync promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review feedback 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/sessions/tab_restore_service_observer.h" 27 #include "chrome/browser/sessions/tab_restore_service_observer.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 28 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/themes/theme_service.h" 29 #include "chrome/browser/themes/theme_service.h"
30 #include "chrome/browser/themes/theme_service_factory.h" 30 #include "chrome/browser/themes/theme_service_factory.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
33 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" 33 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
34 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" 34 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h"
35 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" 35 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
36 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" 36 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
37 #include "chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h"
37 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 38 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
38 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 39 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
39 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 40 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
40 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" 41 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h"
41 #include "chrome/browser/ui/webui/ntp/value_helper.h" 42 #include "chrome/browser/ui/webui/ntp/value_helper.h"
42 #include "chrome/browser/ui/webui/theme_source.h" 43 #include "chrome/browser/ui/webui/theme_source.h"
43 #include "chrome/common/chrome_notification_types.h" 44 #include "chrome/common/chrome_notification_types.h"
44 #include "chrome/common/chrome_switches.h" 45 #include "chrome/common/chrome_switches.h"
45 #include "chrome/common/extensions/extension.h" 46 #include "chrome/common/extensions/extension.h"
46 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (NewTabUI::FirstRunDisabled()) 380 if (NewTabUI::FirstRunDisabled())
380 NewTabHTMLSource::set_first_run(false); 381 NewTabHTMLSource::set_first_run(false);
381 382
382 static bool first_view = true; 383 static bool first_view = true;
383 if (first_view) { 384 if (first_view) {
384 first_view = false; 385 first_view = false;
385 } 386 }
386 387
387 if (!GetProfile()->IsOffTheRecord()) { 388 if (!GetProfile()->IsOffTheRecord()) {
388 PrefService* pref_service = GetProfile()->GetPrefs(); 389 PrefService* pref_service = GetProfile()->GetPrefs();
389 AddMessageHandler((new NTPLoginHandler())->Attach(this)); 390 if (!NewTabSyncSetupHandler::ShouldShowSyncPromo())
391 AddMessageHandler((new NTPLoginHandler())->Attach(this));
390 AddMessageHandler((new ShownSectionsHandler(pref_service))->Attach(this)); 392 AddMessageHandler((new ShownSectionsHandler(pref_service))->Attach(this));
391 AddMessageHandler((new browser_sync::ForeignSessionHandler())-> 393 AddMessageHandler((new browser_sync::ForeignSessionHandler())->
392 Attach(this)); 394 Attach(this));
393 AddMessageHandler((new MostVisitedHandler())->Attach(this)); 395 AddMessageHandler((new MostVisitedHandler())->Attach(this));
394 AddMessageHandler((new RecentlyClosedTabsHandler())->Attach(this)); 396 AddMessageHandler((new RecentlyClosedTabsHandler())->Attach(this));
395 AddMessageHandler((new MetricsHandler())->Attach(this)); 397 AddMessageHandler((new MetricsHandler())->Attach(this));
396 if (GetProfile()->IsSyncAccessible()) 398 if (GetProfile()->IsSyncAccessible())
397 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this)); 399 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this));
398 ExtensionService* service = GetProfile()->GetExtensionService(); 400 ExtensionService* service = GetProfile()->GetExtensionService();
399 // We might not have an ExtensionService (on ChromeOS when not logged in 401 // We might not have an ExtensionService (on ChromeOS when not logged in
400 // for example). 402 // for example).
401 if (service) 403 if (service)
402 AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); 404 AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
403 405
404 AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this)); 406 AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this));
405 AddMessageHandler((new NewTabPageClosePromoHandler())->Attach(this)); 407 AddMessageHandler((new NewTabPageClosePromoHandler())->Attach(this));
406 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) 408 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4))
407 AddMessageHandler((new FaviconWebUIHandler())->Attach(this)); 409 AddMessageHandler((new FaviconWebUIHandler())->Attach(this));
408 } 410 }
409 411
412 // Add the sync setup handler for the sync promo UI.
413 scoped_ptr<SyncSetupHandler> handler(new NewTabSyncSetupHandler());
414 AddMessageHandler(handler.release()->Attach(this));
415
410 // Initializing the CSS and HTML can require some CPU, so do it after 416 // Initializing the CSS and HTML can require some CPU, so do it after
411 // we've hooked up the most visited handler. This allows the DB query 417 // we've hooked up the most visited handler. This allows the DB query
412 // for the new tab thumbs to happen earlier. 418 // for the new tab thumbs to happen earlier.
413 InitializeCSSCaches(); 419 InitializeCSSCaches();
414 NewTabHTMLSource* html_source = 420 NewTabHTMLSource* html_source =
415 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); 421 new NewTabHTMLSource(GetProfile()->GetOriginalProfile());
416 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 422 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
417 423
418 // Listen for theme installation. 424 // Listen for theme installation.
419 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 425 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 SendResponse(request_id, html_bytes); 684 SendResponse(request_id, html_bytes);
679 } 685 }
680 686
681 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 687 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
682 return "text/html"; 688 return "text/html";
683 } 689 }
684 690
685 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 691 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
686 return false; 692 return false;
687 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698