| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 13 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 14 #include "chrome/browser/prefs/pref_member.h" | 14 #include "chrome/browser/prefs/pref_member.h" |
| 15 #include "chrome/browser/search_engines/template_url_service_observer.h" | 15 #include "chrome/browser/search_engines/template_url_service_observer.h" |
| 16 #include "chrome/browser/shell_integration.h" | 16 #include "chrome/browser/shell_integration.h" |
| 17 #include "chrome/browser/sync/profile_sync_service_observer.h" | 17 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 18 #include "chrome/browser/ui/webui/options2/options_ui2.h" | 18 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
| 19 #include "ui/base/models/table_model_observer.h" | 19 #include "ui/base/models/table_model_observer.h" |
| 20 | 20 |
| 21 #if defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/chromeos/device_hierarchy_observer.h" |
| 23 #endif |
| 24 |
| 21 class AutocompleteController; | 25 class AutocompleteController; |
| 22 class CustomHomePagesTableModel; | 26 class CustomHomePagesTableModel; |
| 23 class TemplateURLService; | 27 class TemplateURLService; |
| 24 | 28 |
| 25 namespace options2 { | 29 namespace options2 { |
| 26 | 30 |
| 27 // Chrome browser options page UI handler. | 31 // Chrome browser options page UI handler. |
| 28 class BrowserOptionsHandler : public OptionsPageUIHandler, | 32 class BrowserOptionsHandler |
| 29 public ProfileSyncServiceObserver, | 33 : public OptionsPageUIHandler, |
| 30 public AutocompleteControllerDelegate, | 34 public ProfileSyncServiceObserver, |
| 31 public ShellIntegration::DefaultWebClientObserver, | 35 public AutocompleteControllerDelegate, |
| 32 public TemplateURLServiceObserver { | 36 public ShellIntegration::DefaultWebClientObserver, |
| 37 public TemplateURLServiceObserver, |
| 38 #if defined(OS_CHROMEOS) |
| 39 public chromeos::DeviceHierarchyObserver, |
| 40 #endif |
| 41 public base::SupportsWeakPtr<BrowserOptionsHandler> { |
| 33 public: | 42 public: |
| 34 BrowserOptionsHandler(); | 43 BrowserOptionsHandler(); |
| 35 virtual ~BrowserOptionsHandler(); | 44 virtual ~BrowserOptionsHandler(); |
| 36 | 45 |
| 37 virtual void Initialize() OVERRIDE; | 46 virtual void Initialize() OVERRIDE; |
| 38 | 47 |
| 39 // OptionsPageUIHandler implementation. | 48 // OptionsPageUIHandler implementation. |
| 40 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | 49 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; |
| 41 virtual void RegisterMessages() OVERRIDE; | 50 virtual void RegisterMessages() OVERRIDE; |
| 42 | 51 |
| 43 // ProfileSyncServiceObserver implementation. | 52 // ProfileSyncServiceObserver implementation. |
| 44 virtual void OnStateChanged() OVERRIDE; | 53 virtual void OnStateChanged() OVERRIDE; |
| 45 | 54 |
| 46 // AutocompleteControllerDelegate implementation. | 55 // AutocompleteControllerDelegate implementation. |
| 47 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | 56 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; |
| 48 | 57 |
| 49 // ShellIntegration::DefaultWebClientObserver implementation. | 58 // ShellIntegration::DefaultWebClientObserver implementation. |
| 50 virtual void SetDefaultWebClientUIState( | 59 virtual void SetDefaultWebClientUIState( |
| 51 ShellIntegration::DefaultWebClientUIState state) OVERRIDE; | 60 ShellIntegration::DefaultWebClientUIState state) OVERRIDE; |
| 52 | 61 |
| 53 // TemplateURLServiceObserver implementation. | 62 // TemplateURLServiceObserver implementation. |
| 54 virtual void OnTemplateURLServiceChanged() OVERRIDE; | 63 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
| 55 | 64 |
| 65 #if defined(OS_CHROMEOS) |
| 66 // DeviceHierarchyObserver implementation. |
| 67 virtual void DeviceHierarchyChanged() OVERRIDE; |
| 68 #endif |
| 69 |
| 56 private: | 70 private: |
| 57 // content::NotificationObserver implementation. | 71 // content::NotificationObserver implementation. |
| 58 virtual void Observe(int type, | 72 virtual void Observe(int type, |
| 59 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
| 60 const content::NotificationDetails& details) OVERRIDE; | 74 const content::NotificationDetails& details) OVERRIDE; |
| 61 | 75 |
| 62 // Makes this the default browser. Called from WebUI. | 76 // Makes this the default browser. Called from WebUI. |
| 63 void BecomeDefaultBrowser(const ListValue* args); | 77 void BecomeDefaultBrowser(const base::ListValue* args); |
| 64 | 78 |
| 65 // Sets the search engine at the given index to be default. Called from WebUI. | 79 // Sets the search engine at the given index to be default. Called from WebUI. |
| 66 void SetDefaultSearchEngine(const ListValue* args); | 80 void SetDefaultSearchEngine(const base::ListValue* args); |
| 67 | 81 |
| 68 // Gets autocomplete suggestions asynchronously for the given string. | 82 // Gets autocomplete suggestions asynchronously for the given string. |
| 69 // Called from WebUI. | 83 // Called from WebUI. |
| 70 void RequestAutocompleteSuggestions(const ListValue* args); | 84 void RequestAutocompleteSuggestions(const base::ListValue* args); |
| 71 | 85 |
| 72 // Enables/disables Instant. | 86 // Enables/disables Instant. |
| 73 void EnableInstant(const ListValue* args); | 87 void EnableInstant(const base::ListValue* args); |
| 74 void DisableInstant(const ListValue* args); | 88 void DisableInstant(const base::ListValue* args); |
| 75 | 89 |
| 76 // Enables/disables auto-launching of Chrome on computer startup. | 90 // Enables/disables auto-launching of Chrome on computer startup. |
| 77 void ToggleAutoLaunch(const ListValue* args); | 91 void ToggleAutoLaunch(const base::ListValue* args); |
| 78 | 92 |
| 79 // Checks (on the file thread) whether the user is in the auto-launch trial | 93 // Checks (on the file thread) whether the user is in the auto-launch trial |
| 80 // and whether Chrome is set to auto-launch at login. Gets a reply on the UI | 94 // and whether Chrome is set to auto-launch at login. Gets a reply on the UI |
| 81 // thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in | 95 // thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in |
| 82 // as a parameter to avoid the need to lock between this function and the | 96 // as a parameter to avoid the need to lock between this function and the |
| 83 // destructor. | 97 // destructor. |
| 84 | 98 |
| 85 void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this); | 99 void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this); |
| 86 // Sets up (on the UI thread) the necessary bindings for toggling auto-launch | 100 // Sets up (on the UI thread) the necessary bindings for toggling auto-launch |
| 87 // (if the user is part of the auto-launch and makes sure the HTML UI knows | 101 // (if the user is part of the auto-launch and makes sure the HTML UI knows |
| 88 // whether Chrome will auto-launch at login. | 102 // whether Chrome will auto-launch at login. |
| 89 void CheckAutoLaunchCallback(bool is_in_auto_launch_group, | 103 void CheckAutoLaunchCallback(bool is_in_auto_launch_group, |
| 90 bool will_launch_at_login); | 104 bool will_launch_at_login); |
| 91 | 105 |
| 92 // Called to request information about the Instant field trial. | 106 // Called to request information about the Instant field trial. |
| 93 void GetInstantFieldTrialStatus(const ListValue* args); | 107 void GetInstantFieldTrialStatus(const base::ListValue* args); |
| 94 | 108 |
| 95 // Returns the string ID for the given default browser state. | 109 // Returns the string ID for the given default browser state. |
| 96 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state); | 110 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state); |
| 97 | 111 |
| 98 // Gets the current default browser state, and asynchronously reports it to | 112 // Gets the current default browser state, and asynchronously reports it to |
| 99 // the WebUI page. | 113 // the WebUI page. |
| 100 void UpdateDefaultBrowserState(); | 114 void UpdateDefaultBrowserState(); |
| 101 | 115 |
| 102 // Updates the UI with the given state for the default browser. | 116 // Updates the UI with the given state for the default browser. |
| 103 void SetDefaultBrowserUIString(int status_string_id); | 117 void SetDefaultBrowserUIString(int status_string_id); |
| 104 | 118 |
| 105 // Updates the label of the 'Show Home page'. | 119 // Updates the label of the 'Show Home page'. |
| 106 void UpdateHomePageLabel() const; | 120 void UpdateHomePageLabel() const; |
| 107 | 121 |
| 108 // Loads the possible default search engine list and reports it to the WebUI. | 122 // Loads the possible default search engine list and reports it to the WebUI. |
| 109 void UpdateSearchEngines(); | 123 void UpdateSearchEngines(); |
| 110 | 124 |
| 111 // Sends an array of Profile objects to javascript. | 125 // Sends an array of Profile objects to javascript. |
| 112 // Each object is of the form: | 126 // Each object is of the form: |
| 113 // profileInfo = { | 127 // profileInfo = { |
| 114 // name: "Profile Name", | 128 // name: "Profile Name", |
| 115 // iconURL: "chrome://path/to/icon/image", | 129 // iconURL: "chrome://path/to/icon/image", |
| 116 // filePath: "/path/to/profile/data/on/disk", | 130 // filePath: "/path/to/profile/data/on/disk", |
| 117 // isCurrentProfile: false | 131 // isCurrentProfile: false |
| 118 // }; | 132 // }; |
| 119 void SendProfilesInfo(); | 133 void SendProfilesInfo(); |
| 120 | 134 |
| 121 // Asynchronously opens a new browser window to create a new profile. | 135 // Asynchronously opens a new browser window to create a new profile. |
| 122 // |args| is not used. | 136 // |args| is not used. |
| 123 void CreateProfile(const ListValue* args); | 137 void CreateProfile(const base::ListValue* args); |
| 124 | 138 |
| 125 void ObserveThemeChanged(); | 139 void ObserveThemeChanged(); |
| 126 void ThemesReset(const ListValue* args); | 140 void ThemesReset(const base::ListValue* args); |
| 127 #if defined(TOOLKIT_GTK) | 141 #if defined(TOOLKIT_GTK) |
| 128 void ThemesSetGTK(const ListValue* args); | 142 void ThemesSetGTK(const base::ListValue* args); |
| 129 #endif | 143 #endif |
| 130 | 144 |
| 131 #if defined(OS_CHROMEOS) | 145 #if defined(OS_CHROMEOS) |
| 146 // Check for input devices. |
| 147 void CheckTouchpadExists(); |
| 148 void CheckMouseExists(); |
| 149 |
| 150 // Callback for input device checks. |
| 151 void TouchpadExists(bool* exists); |
| 152 void MouseExists(bool* exists); |
| 153 |
| 154 // Called when the System configuration screen is used to adjust |
| 155 // the screen brightness. |
| 156 // |args| will be an empty list. |
| 157 void DecreaseScreenBrightnessCallback(const base::ListValue* args); |
| 158 void IncreaseScreenBrightnessCallback(const base::ListValue* args); |
| 159 |
| 132 void UpdateAccountPicture(); | 160 void UpdateAccountPicture(); |
| 133 #endif | 161 #endif |
| 134 | 162 |
| 135 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | 163 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; |
| 136 | 164 |
| 137 StringPrefMember homepage_; | 165 StringPrefMember homepage_; |
| 138 BooleanPrefMember default_browser_policy_; | 166 BooleanPrefMember default_browser_policy_; |
| 139 | 167 |
| 140 // Used to observe updates to the preference of the list of URLs to load | 168 // Used to observe updates to the preference of the list of URLs to load |
| 141 // on startup, which can be updated via sync. | 169 // on startup, which can be updated via sync. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 152 | 180 |
| 153 // True if the multiprofiles switch is enabled. | 181 // True if the multiprofiles switch is enabled. |
| 154 bool multiprofile_; | 182 bool multiprofile_; |
| 155 | 183 |
| 156 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | 184 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); |
| 157 }; | 185 }; |
| 158 | 186 |
| 159 } // namespace options2 | 187 } // namespace options2 |
| 160 | 188 |
| 161 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ | 189 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER2_H_ |
| OLD | NEW |