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

Side by Side Diff: chrome/browser/ui/alternate_error_tab_observer.cc

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again; base::File changes conflicted. Created 7 years, 10 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) 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/alternate_error_tab_observer.h" 5 #include "chrome/browser/ui/alternate_error_tab_observer.h"
6 6
7 #include "chrome/browser/google/google_util.h" 7 #include "chrome/browser/google/google_util.h"
8 #include "chrome/browser/prefs/pref_registry_syncable.h"
8 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
12 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 16
16 using content::RenderViewHost; 17 using content::RenderViewHost;
17 using content::WebContents; 18 using content::WebContents;
18 19
19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver); 20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(AlternateErrorPageTabObserver);
20 21
21 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( 22 AlternateErrorPageTabObserver::AlternateErrorPageTabObserver(
22 WebContents* web_contents) 23 WebContents* web_contents)
23 : content::WebContentsObserver(web_contents), 24 : content::WebContentsObserver(web_contents),
24 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) { 25 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) {
25 PrefServiceSyncable* prefs = profile_->GetPrefs(); 26 PrefService* prefs = profile_->GetPrefs();
26 if (prefs) { 27 if (prefs) {
27 pref_change_registrar_.Init(prefs); 28 pref_change_registrar_.Init(prefs);
28 pref_change_registrar_.Add( 29 pref_change_registrar_.Add(
29 prefs::kAlternateErrorPagesEnabled, 30 prefs::kAlternateErrorPagesEnabled,
30 base::Bind(&AlternateErrorPageTabObserver:: 31 base::Bind(&AlternateErrorPageTabObserver::
31 OnAlternateErrorPagesEnabledChanged, 32 OnAlternateErrorPagesEnabledChanged,
32 base::Unretained(this))); 33 base::Unretained(this)));
33 } 34 }
34 35
35 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, 36 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
36 content::Source<Profile>(profile_->GetOriginalProfile())); 37 content::Source<Profile>(profile_->GetOriginalProfile()));
37 } 38 }
38 39
39 AlternateErrorPageTabObserver::~AlternateErrorPageTabObserver() { 40 AlternateErrorPageTabObserver::~AlternateErrorPageTabObserver() {
40 } 41 }
41 42
42 // static 43 // static
43 void AlternateErrorPageTabObserver::RegisterUserPrefs( 44 void AlternateErrorPageTabObserver::RegisterUserPrefs(
44 PrefServiceSyncable* prefs) { 45 PrefRegistrySyncable* prefs) {
45 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, true, 46 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, true,
46 PrefServiceSyncable::SYNCABLE_PREF); 47 PrefRegistrySyncable::SYNCABLE_PREF);
47 } 48 }
48 49
49 //////////////////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////////////////
50 // WebContentsObserver overrides 51 // WebContentsObserver overrides
51 52
52 void AlternateErrorPageTabObserver::RenderViewCreated( 53 void AlternateErrorPageTabObserver::RenderViewCreated(
53 RenderViewHost* render_view_host) { 54 RenderViewHost* render_view_host) {
54 UpdateAlternateErrorPageURL(render_view_host); 55 UpdateAlternateErrorPageURL(render_view_host);
55 } 56 }
56 57
(...skipping 28 matching lines...) Expand all
85 } 86 }
86 87
87 void AlternateErrorPageTabObserver::OnAlternateErrorPagesEnabledChanged() { 88 void AlternateErrorPageTabObserver::OnAlternateErrorPagesEnabledChanged() {
88 UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); 89 UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost());
89 } 90 }
90 91
91 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL( 92 void AlternateErrorPageTabObserver::UpdateAlternateErrorPageURL(
92 RenderViewHost* rvh) { 93 RenderViewHost* rvh) {
93 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL()); 94 rvh->SetAltErrorPageURL(GetAlternateErrorPageURL());
94 } 95 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/alternate_error_tab_observer.h ('k') | chrome/browser/ui/ash/chrome_launcher_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698