summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/personalization.h
blob: f278d28d63fe6229769860a60cfc64c4715e677d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef CHROME_PERSONALIZATION

// TODO(timsteele): Remove this file by finding proper homes for everything in
// trunk.
#ifndef CHROME_BROWSER_SYNC_PERSONALIZATION_H_
#define CHROME_BROWSER_SYNC_PERSONALIZATION_H_

#include <string>
#include "base/basictypes.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"

class Browser;
class DOMUI;
class DOMMessageHandler;
class Profile;
class RenderView;
class RenderViewHost;
class WebFrame;
class WebView;

class ProfileSyncService;
class ProfileSyncServiceObserver;

namespace views { class View; }

// TODO(ncarter): Move these switches into chrome_switches.  They are here
// now because we want to keep them secret during early development.
namespace switches {
extern const wchar_t kSyncServiceURL[];
extern const wchar_t kSyncServicePort[];
extern const wchar_t kSyncUserForTest[];
extern const wchar_t kSyncPasswordForTest[];
}

// Names of various preferences.
// TODO(munjal): Move these preferences to common/pref_names.h.
namespace prefs {
extern const wchar_t kSyncPath[];
extern const wchar_t kSyncLastSyncedTime[];
extern const wchar_t kSyncUserName[];
extern const wchar_t kSyncHasSetupCompleted[];
}

// Contains a profile sync service, which is initialized at profile creation.
// A pointer to this class is passed as a handle.
class ProfilePersonalization {
 public:
  ProfilePersonalization() {}
  virtual ~ProfilePersonalization() {}

  virtual ProfileSyncService* sync_service() = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(ProfilePersonalization);
};

// Contains methods to perform Personalization-related tasks on behalf of the
// caller.
namespace Personalization {

// Checks if P13N is globally disabled or not, and that |profile| has a valid
// ProfilePersonalization member (it can be NULL for TestingProfiles).
bool IsSyncEnabled(Profile* profile);

// Returns whether |url| should be loaded in a DOMUI.
bool NeedsDOMUI(const GURL& url);

// Construct a new ProfilePersonalization and return it so the caller can take
// ownership.
ProfilePersonalization* CreateProfilePersonalization(Profile* p);

// The caller of Create...() above should call this when the returned
// ProfilePersonalization object should be deleted.
void CleanupProfilePersonalization(ProfilePersonalization* p);

// Handler for "cloudy:stats"
std::string MakeCloudyStats();

// Construct a new DOMMessageHandler for the new tab page |dom_ui|.
DOMMessageHandler* CreateNewTabPageHandler(DOMUI* dom_ui);

// Get HTML for the Personalization iframe in the New Tab Page.
std::string GetNewTabSource();

// Returns the text for personalization info menu item and sets its enabled
// state.
std::wstring GetMenuItemInfoText(Browser* browser);

// Performs appropriate action when the sync menu item is clicked.
void HandleMenuItemClick(Profile* p);
}  // namespace Personalization

// The internal scheme used to retrieve HTML resources for personalization
// related code (e.g cloudy:stats, GAIA login page).
// We need to ensure the GAIA login HTML is loaded into an HTMLDialogContents.
// Outside of p13n (for the time being) only "gears://" gives this (see
// HtmlDialogContents::IsHtmlDialogUrl) for the application shortcut dialog.
// TODO(timsteele): We should have a robust way to handle this to allow more
// reuse of our HTML dialog code, perhaps by using a dedicated "dialog-resource"
// scheme (chrome-resource is coupled to DOM_UI). Figure out if that is the best
// course of action / pitch this idea to chromium-dev.
static const char kPersonalizationScheme[] = "cloudy";

#endif  // CHROME_BROWSER_SYNC_PERSONALIZATION_H_
#endif  // CHROME_PERSONALIZATION