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

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: Reviewed, rebased 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
295 browser_defaults::bookmarks_enabled &&
296 !prefs->IsManagedPreference(prefs::kShowBookmarkBar) &&
297 !prefs->GetBoolean(prefs::kShowBookmarkBar) &&
298 !NTP4BookmarkFeaturesEnabled();
sky 2011/10/05 16:59:12 I don't think this should check kShowBookmarkBar.
Joao da Silva 2011/10/06 19:45:38 Yikes, totally forgot to check behavior with fulls
299 }
300
300 void NewTabUI::Observe(int type, 301 void NewTabUI::Observe(int type,
301 const NotificationSource& source, 302 const NotificationSource& source,
302 const NotificationDetails& details) { 303 const NotificationDetails& details) {
303 switch (type) { 304 switch (type) {
304 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 305 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
305 InitializeCSSCaches(); 306 InitializeCSSCaches();
306 ListValue args; 307 ListValue args;
307 args.Append(Value::CreateStringValue( 308 args.Append(Value::CreateStringValue(
308 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage( 309 ThemeServiceFactory::GetForProfile(GetProfile())->HasCustomImage(
309 IDR_THEME_NTP_ATTRIBUTION) ? 310 IDR_THEME_NTP_ATTRIBUTION) ?
310 "true" : "false")); 311 "true" : "false"));
311 CallJavascriptFunction("themeChanged", args); 312 CallJavascriptFunction("themeChanged", args);
312 break; 313 break;
313 } 314 }
314 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: { 315 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: {
315 if (GetProfile()->GetPrefs()->IsManagedPreference(
316 prefs::kEnableBookmarkBar)) {
317 break;
318 }
319 if (!NTP4Enabled()) { 316 if (!NTP4Enabled()) {
320 if (GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) 317 if (IsBookmarkBarVisible())
321 CallJavascriptFunction("bookmarkBarAttached"); 318 CallJavascriptFunction("bookmarkBarAttached");
322 else 319 else
323 CallJavascriptFunction("bookmarkBarDetached"); 320 CallJavascriptFunction("bookmarkBarDetached");
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 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 SendResponse(request_id, html_bytes); 450 SendResponse(request_id, html_bytes);
454 } 451 }
455 452
456 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 453 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
457 return "text/html"; 454 return "text/html";
458 } 455 }
459 456
460 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 457 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
461 return false; 458 return false;
462 } 459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698