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

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

Issue 164002: Apply theme to incognito NTP.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/dom_ui/new_tab_ui.h" 7 #include "chrome/browser/dom_ui/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 return std::string(); 428 return std::string();
429 } 429 }
430 430
431 /////////////////////////////////////////////////////////////////////////////// 431 ///////////////////////////////////////////////////////////////////////////////
432 // IncognitoTabHTMLSource 432 // IncognitoTabHTMLSource
433 433
434 class IncognitoTabHTMLSource : public ChromeURLDataManager::DataSource { 434 class IncognitoTabHTMLSource : public ChromeURLDataManager::DataSource {
435 public: 435 public:
436 // Creates our datasource and sets our user message to a specific message 436 // Creates our datasource and registers initial state of the bookmark bar.
437 // from our string bundle. 437 explicit IncognitoTabHTMLSource(bool bookmark_bar_attached);
438 IncognitoTabHTMLSource();
439 438
440 // Called when the network layer has requested a resource underneath 439 // Called when the network layer has requested a resource underneath
441 // the path we registered. 440 // the path we registered.
442 virtual void StartDataRequest(const std::string& path, int request_id); 441 virtual void StartDataRequest(const std::string& path, int request_id);
443 442
444 virtual std::string GetMimeType(const std::string&) const { 443 virtual std::string GetMimeType(const std::string&) const {
445 return "text/html"; 444 return "text/html";
446 } 445 }
447 446
448 private: 447 private:
448 bool bookmark_bar_attached_;
449
449 DISALLOW_COPY_AND_ASSIGN(IncognitoTabHTMLSource); 450 DISALLOW_COPY_AND_ASSIGN(IncognitoTabHTMLSource);
450 }; 451 };
451 452
452 IncognitoTabHTMLSource::IncognitoTabHTMLSource() 453 IncognitoTabHTMLSource::IncognitoTabHTMLSource(bool bookmark_bar_attached)
453 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()) { 454 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()),
455 bookmark_bar_attached_(bookmark_bar_attached) {
454 } 456 }
455 457
456 void IncognitoTabHTMLSource::StartDataRequest(const std::string& path, 458 void IncognitoTabHTMLSource::StartDataRequest(const std::string& path,
457 int request_id) { 459 int request_id) {
458 DictionaryValue localized_strings; 460 DictionaryValue localized_strings;
459 localized_strings.SetString(L"title", 461 localized_strings.SetString(L"title",
460 l10n_util::GetString(IDS_NEW_TAB_TITLE)); 462 l10n_util::GetString(IDS_NEW_TAB_TITLE));
461 localized_strings.SetString(L"content", 463 localized_strings.SetString(L"content",
462 l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE, 464 l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE,
463 l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL))); 465 l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)));
466 localized_strings.SetString(L"bookmarkbarattached",
467 bookmark_bar_attached_ ? "true" : "false");
464 468
465 SetFontAndTextDirection(&localized_strings); 469 SetFontAndTextDirection(&localized_strings);
466 470
467 static const StringPiece incognito_tab_html( 471 static const StringPiece incognito_tab_html(
468 ResourceBundle::GetSharedInstance().GetRawDataResource( 472 ResourceBundle::GetSharedInstance().GetRawDataResource(
469 IDR_INCOGNITO_TAB_HTML)); 473 IDR_INCOGNITO_TAB_HTML));
470 474
471 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( 475 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
472 incognito_tab_html, &localized_strings); 476 incognito_tab_html, &localized_strings);
473 477
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 } 1526 }
1523 1527
1524 if (NewTabUI::FirstRunDisabled()) 1528 if (NewTabUI::FirstRunDisabled())
1525 NewTabHTMLSource::set_first_run(false); 1529 NewTabHTMLSource::set_first_run(false);
1526 1530
1527 tab_contents()->render_view_host()->set_paint_observer(new PaintTimer); 1531 tab_contents()->render_view_host()->set_paint_observer(new PaintTimer);
1528 1532
1529 if (GetProfile()->IsOffTheRecord()) { 1533 if (GetProfile()->IsOffTheRecord()) {
1530 incognito_ = true; 1534 incognito_ = true;
1531 1535
1532 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource(); 1536 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource(
1537 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar));
1533 1538
1534 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 1539 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
1535 NewRunnableMethod(&chrome_url_data_manager, 1540 NewRunnableMethod(&chrome_url_data_manager,
1536 &ChromeURLDataManager::AddDataSource, 1541 &ChromeURLDataManager::AddDataSource,
1537 html_source)); 1542 html_source));
1538 } else { 1543 } else {
1539 DownloadManager* dlm = GetProfile()->GetDownloadManager(); 1544 DownloadManager* dlm = GetProfile()->GetDownloadManager();
1540 // This might be null in the case of running inside a unit test. 1545 // This might be null in the case of running inside a unit test.
1541 // TODO(arv): Fix unit tests to provide a working mock download manager. 1546 // TODO(arv): Fix unit tests to provide a working mock download manager.
1542 if (dlm) { 1547 if (dlm) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 bool NewTabUI::WebResourcesEnabled() { 1629 bool NewTabUI::WebResourcesEnabled() {
1625 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1630 const CommandLine* command_line = CommandLine::ForCurrentProcess();
1626 return command_line->HasSwitch(switches::kEnableWebResources); 1631 return command_line->HasSwitch(switches::kEnableWebResources);
1627 } 1632 }
1628 1633
1629 // static 1634 // static
1630 bool NewTabUI::FirstRunDisabled() { 1635 bool NewTabUI::FirstRunDisabled() {
1631 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1636 const CommandLine* command_line = CommandLine::ForCurrentProcess();
1632 return command_line->HasSwitch(switches::kDisableNewTabFirstRun); 1637 return command_line->HasSwitch(switches::kDisableNewTabFirstRun);
1633 } 1638 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.cc ('k') | chrome/browser/resources/incognito_tab.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698