OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_DOM_UI_OPTIONS_UI_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_OPTIONS_UI_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 13 #include "chrome/browser/dom_ui/dom_ui.h" |
| 14 #include "chrome/common/notification_registrar.h" |
| 15 #include "chrome/common/notification_type.h" |
| 16 |
| 17 class GURL; |
| 18 class PrefService; |
| 19 struct UserMetricsAction; |
| 20 |
| 21 class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 22 public: |
| 23 // The constructor takes over ownership of |localized_strings|. |
| 24 explicit OptionsUIHTMLSource(DictionaryValue* localized_strings); |
| 25 virtual ~OptionsUIHTMLSource() {} |
| 26 |
| 27 // Called when the network layer has requested a resource underneath |
| 28 // the path we registered. |
| 29 virtual void StartDataRequest(const std::string& path, |
| 30 bool is_off_the_record, |
| 31 int request_id); |
| 32 virtual std::string GetMimeType(const std::string&) const { |
| 33 return "text/html"; |
| 34 } |
| 35 |
| 36 private: |
| 37 // Localized strings collection. |
| 38 scoped_ptr<DictionaryValue> localized_strings_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); |
| 41 }; |
| 42 |
| 43 // The base class handler of Javascript messages of options pages. |
| 44 class OptionsPageUIHandler : public DOMMessageHandler, |
| 45 public NotificationObserver { |
| 46 public: |
| 47 OptionsPageUIHandler(); |
| 48 virtual ~OptionsPageUIHandler(); |
| 49 |
| 50 // Collects localized strings for options page. |
| 51 virtual void GetLocalizedValues(DictionaryValue* localized_strings) = 0; |
| 52 |
| 53 // DOMMessageHandler implementation. |
| 54 virtual void RegisterMessages() {} |
| 55 |
| 56 // NotificationObserver implementation. |
| 57 virtual void Observe(NotificationType type, |
| 58 const NotificationSource& source, |
| 59 const NotificationDetails& details) {} |
| 60 |
| 61 void UserMetricsRecordAction(const UserMetricsAction& action, |
| 62 PrefService* prefs); |
| 63 |
| 64 protected: |
| 65 NotificationRegistrar registrar_; |
| 66 |
| 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler); |
| 69 }; |
| 70 |
| 71 class OptionsUI : public DOMUI { |
| 72 public: |
| 73 explicit OptionsUI(TabContents* contents); |
| 74 virtual ~OptionsUI() {} |
| 75 |
| 76 private: |
| 77 void AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
| 78 OptionsPageUIHandler* handler); |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(OptionsUI); |
| 81 }; |
| 82 |
| 83 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_UI_H_ |
OLD | NEW |