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_UI_WEBUI_OPTIONS2_WEB_INTENTS_SETTINGS_HANDLER2_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_WEB_INTENTS_SETTINGS_HANDLER2_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/ui/intents/web_intents_model.h" | |
12 #include "chrome/browser/ui/webui/options2/options_ui2.h" | |
13 | |
14 class WebIntentsRegistry; | |
15 | |
16 namespace options2 { | |
17 | |
18 // Manage setting up the backing data for the web intents options page. | |
19 class WebIntentsSettingsHandler : public OptionsPageUIHandler, | |
20 public WebIntentsModel::Observer { | |
21 public: | |
22 WebIntentsSettingsHandler(); | |
23 virtual ~WebIntentsSettingsHandler(); | |
24 | |
25 // OptionsPageUIHandler implementation. | |
26 virtual void GetLocalizedValues( | |
27 base::DictionaryValue* localized_strings) OVERRIDE; | |
28 virtual void RegisterMessages() OVERRIDE; | |
29 | |
30 // WebIntentsModel::Observer implementation. | |
31 virtual void TreeNodesAdded(ui::TreeModel* model, | |
32 ui::TreeModelNode* parent, | |
33 int start, | |
34 int count) OVERRIDE; | |
35 virtual void TreeNodesRemoved(ui::TreeModel* model, | |
36 ui::TreeModelNode* parent, | |
37 int start, | |
38 int count) OVERRIDE; | |
39 virtual void TreeNodeChanged(ui::TreeModel* model, | |
40 ui::TreeModelNode* node) OVERRIDE {} | |
41 virtual void TreeModelBeginBatch(WebIntentsModel* model) OVERRIDE; | |
42 virtual void TreeModelEndBatch(WebIntentsModel* model) OVERRIDE; | |
43 | |
44 private: | |
45 // Creates the WebIntentsModel if neccessary. | |
46 void EnsureWebIntentsModelCreated(); | |
47 | |
48 // Updates search filter for cookies tree model. | |
49 void UpdateSearchResults(const base::ListValue* args); | |
50 | |
51 // Remove all sites data. | |
52 void RemoveAll(const base::ListValue* args); | |
53 | |
54 // Remove selected sites data. | |
55 void RemoveIntent(const base::ListValue* args); | |
56 | |
57 // Helper functions for removals. | |
58 void RemoveOrigin(WebIntentsTreeNode* node); | |
59 void RemoveService(ServiceTreeNode* snode); | |
60 | |
61 // Trigger for SendChildren to load the JS model. | |
62 void LoadChildren(const base::ListValue* args); | |
63 | |
64 // Get children nodes data and pass it to 'IntentsView.loadChildren' to | |
65 // update the WebUI. | |
66 void SendChildren(WebIntentsTreeNode* parent); | |
67 | |
68 WebIntentsRegistry* web_intents_registry_; // Weak pointer. | |
69 | |
70 // Backing data model for the intents list. | |
71 scoped_ptr<WebIntentsModel> intents_tree_model_; | |
72 | |
73 // Flag to indicate whether there is a batch update in progress. | |
74 bool batch_update_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(WebIntentsSettingsHandler); | |
77 }; | |
78 | |
79 } // namespace options2 | |
80 | |
81 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_WEB_INTENTS_SETTINGS_HANDLER2_H_ | |
OLD | NEW |