| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
| 6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/protector/setting_change.h" |
| 13 #include "chrome/browser/protector/settings_change_global_error.h" |
| 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" |
| 16 |
| 17 class GURL; |
| 18 class Profile; |
| 19 class TemplateURLService; |
| 20 |
| 21 namespace protector { |
| 22 |
| 23 // Accumulates settings changes and shows them altogether to user. |
| 24 class Protector : public SettingsChangeGlobalError::Delegate, |
| 25 public content::NotificationObserver { |
| 26 public: |
| 27 explicit Protector(Profile* profile); |
| 28 virtual ~Protector(); |
| 29 |
| 30 // Opens a tab with specified URL in the browser window we've shown error |
| 31 // bubble for. |
| 32 void OpenTab(const GURL& url); |
| 33 |
| 34 // Returns TemplateURLService for the profile we've shown error bubble |
| 35 // for. |
| 36 TemplateURLService* GetTemplateURLService(); |
| 37 |
| 38 // SettingsChangeGlobalError::Delegate implementation. |
| 39 virtual void OnApplyChanges() OVERRIDE; |
| 40 virtual void OnDiscardChanges() OVERRIDE; |
| 41 virtual void OnDecisionTimeout() OVERRIDE; |
| 42 |
| 43 // content::NotificationObserver implementation. |
| 44 virtual void Observe(int type, |
| 45 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) OVERRIDE; |
| 47 |
| 48 private: |
| 49 // Shows global error about the specified change. Ownership of the change |
| 50 // is passed to the error object. |
| 51 void ShowChange(SettingChange* change); |
| 52 |
| 53 // Common handler for error delegate handlers. Calls the specified method |
| 54 // on each change we showed error for. |
| 55 void OnChangesAction(SettingChangeAction action); |
| 56 |
| 57 // Pointer to error bubble controller. Indicates if we're showing change |
| 58 // notification to user. Owns itself. |
| 59 scoped_ptr<SettingsChangeGlobalError> error_; |
| 60 |
| 61 // Profile which settings we are protecting. |
| 62 Profile* profile_; |
| 63 |
| 64 // Notifications helper. |
| 65 content::NotificationRegistrar registrar_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(Protector); |
| 68 }; |
| 69 |
| 70 // Signs string value with protector's key. |
| 71 std::string SignSetting(const std::string& value); |
| 72 |
| 73 } // namespace protector |
| 74 |
| 75 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
| OLD | NEW |