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

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

Issue 8135001: Fixed behavior of the bookmark bar visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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>
10
11 #include "base/bind.h" 9 #include "base/bind.h"
12 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 11 #include "base/command_line.h"
14 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
15 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
16 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
17 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
18 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
19 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/defaults.h" 18 #include "chrome/browser/defaults.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } // namespace 186 } // namespace
189 187
190 /////////////////////////////////////////////////////////////////////////////// 188 ///////////////////////////////////////////////////////////////////////////////
191 // NewTabUI 189 // NewTabUI
192 190
193 NewTabUI::NewTabUI(TabContents* contents) 191 NewTabUI::NewTabUI(TabContents* contents)
194 : ChromeWebUI(contents) { 192 : ChromeWebUI(contents) {
195 // Override some options on the Web UI. 193 // Override some options on the Web UI.
196 hide_favicon_ = true; 194 hide_favicon_ = true;
197 195
198 if (!NTP4BookmarkFeaturesEnabled() &&
199 GetProfile()->GetPrefs()->GetBoolean(prefs::kEnableBookmarkBar) &&
200 browser_defaults::bookmarks_enabled) {
201 set_force_bookmark_bar_visible(true);
202 }
203
204 focus_location_bar_by_default_ = true; 196 focus_location_bar_by_default_ = true;
205 should_hide_url_ = true; 197 should_hide_url_ = true;
206 overridden_title_ = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); 198 overridden_title_ = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
207 199
208 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more 200 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more
209 // highly. Note this means we're including clicks on not only most visited 201 // highly. Note this means we're including clicks on not only most visited
210 // thumbnails, but also clicks on recently bookmarked. 202 // thumbnails, but also clicks on recently bookmarked.
211 link_transition_type_ = PageTransition::AUTO_BOOKMARK; 203 link_transition_type_ = PageTransition::AUTO_BOOKMARK;
212 204
213 if (!GetProfile()->IsOffTheRecord()) { 205 if (!GetProfile()->IsOffTheRecord()) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 282
291 } 283 }
292 void NewTabUI::RenderViewCreated(RenderViewHost* render_view_host) { 284 void NewTabUI::RenderViewCreated(RenderViewHost* render_view_host) {
293 StartTimingPaint(render_view_host); 285 StartTimingPaint(render_view_host);
294 } 286 }
295 287
296 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) { 288 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) {
297 StartTimingPaint(render_view_host); 289 StartTimingPaint(render_view_host);
298 } 290 }
299 291
292 bool NewTabUI::IsBookmarkBarVisible() const {
293 const PrefService* prefs = GetProfile()->GetPrefs();
294 return browser_defaults::bookmarks_enabled &&
295 !prefs->IsManagedPreference(prefs::kShowBookmarkBar) &&
Evan Stade 2011/10/04 21:10:38 only 4 spaces
Joao da Silva 2011/10/05 14:31:25 Done.
296 !prefs->GetBoolean(prefs::kShowBookmarkBar) &&
297 !NTP4BookmarkFeaturesEnabled();
298 }
299
300 void NewTabUI::Observe(int type, 300 void NewTabUI::Observe(int type,
301 const NotificationSource& source, 301 const NotificationSource& source,
302 const NotificationDetails& details) { 302 const NotificationDetails& details) {
303 switch (type) { 303 switch (type) {
304 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 304 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
305 InitializeCSSCaches(); 305 InitializeCSSCaches();
306 ListValue args; 306 ListValue args;
307 args.Append(Value::CreateStringValue( 307 args.Append(Value::CreateStringValue(
308 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage( 308 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage(
309 IDR_THEME_NTP_ATTRIBUTION) ? 309 IDR_THEME_NTP_ATTRIBUTION) ?
310 "true" : "false")); 310 "true" : "false"));
311 CallJavascriptFunction("themeChanged", args); 311 CallJavascriptFunction("themeChanged", args);
312 break; 312 break;
313 } 313 }
314 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: { 314 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: {
315 if (GetProfile()->GetPrefs()->IsManagedPreference(
316 prefs::kEnableBookmarkBar)) {
317 break;
318 }
319 if (!NTP4Enabled()) { 315 if (!NTP4Enabled()) {
320 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) 316 if (IsBookmarkBarVisible()) {
Evan Stade 2011/10/04 21:10:38 don't add curlies
Joao da Silva 2011/10/05 14:31:25 Done.
321 CallJavascriptFunction("bookmarkBarAttached"); 317 CallJavascriptFunction("bookmarkBarAttached");
322 else 318 } else {
323 CallJavascriptFunction("bookmarkBarDetached"); 319 CallJavascriptFunction("bookmarkBarDetached");
320 }
324 } 321 }
325 break; 322 break;
326 } 323 }
327 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: { 324 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: {
328 last_paint_ = base::TimeTicks::Now(); 325 last_paint_ = base::TimeTicks::Now();
329 break; 326 break;
330 } 327 }
331 default: 328 default:
332 CHECK(false) << "Unexpected notification: " << type; 329 CHECK(false) << "Unexpected notification: " << type;
333 } 330 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 SendResponse(request_id, html_bytes); 464 SendResponse(request_id, html_bytes);
468 } 465 }
469 466
470 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 467 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
471 return "text/html"; 468 return "text/html";
472 } 469 }
473 470
474 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 471 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
475 return false; 472 return false;
476 } 473 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698