Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/public/browser/web_ui_message_handler.h

Issue 1421893005: Settings Rewrite: Fork SyncSetupHandler for MD-Settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 10 matching lines...) Expand all
21 namespace content { 21 namespace content {
22 22
23 class WebUI; 23 class WebUI;
24 class WebUIImpl; 24 class WebUIImpl;
25 25
26 // Messages sent from the DOM are forwarded via the WebUI to handler 26 // Messages sent from the DOM are forwarded via the WebUI to handler
27 // classes. These objects are owned by WebUI and destroyed when the 27 // classes. These objects are owned by WebUI and destroyed when the
28 // host is destroyed. 28 // host is destroyed.
29 class CONTENT_EXPORT WebUIMessageHandler { 29 class CONTENT_EXPORT WebUIMessageHandler {
30 public: 30 public:
31 explicit WebUIMessageHandler(WebUI* web_ui) : web_ui_(web_ui) {}
32
33 // DEPRECATED. Use WebUIMessageHandler(WebUI*) constructor instead.
34 // TODO(tommycli): Remove once legacy callers gone.
31 WebUIMessageHandler() : web_ui_(nullptr) {} 35 WebUIMessageHandler() : web_ui_(nullptr) {}
36
32 virtual ~WebUIMessageHandler() {} 37 virtual ~WebUIMessageHandler() {}
33 38
34 protected: 39 protected:
35 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue); 40 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue);
36 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue); 41 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue);
37 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue); 42 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue);
38 43
39 // Helper methods: 44 // Helper methods:
40 45
41 // Extract an integer value from a list Value. 46 // Extract an integer value from a list Value.
42 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); 47 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int);
43 48
44 // Extract a floating point (double) value from a list Value. 49 // Extract a floating point (double) value from a list Value.
45 static bool ExtractDoubleValue(const base::ListValue* value, 50 static bool ExtractDoubleValue(const base::ListValue* value,
46 double* out_value); 51 double* out_value);
47 52
48 // Extract a string value from a list Value. 53 // Extract a string value from a list Value.
49 static base::string16 ExtractStringValue(const base::ListValue* value); 54 static base::string16 ExtractStringValue(const base::ListValue* value);
50 55
51 // This is where subclasses specify which messages they'd like to handle and 56 // This is where subclasses specify which messages they'd like to handle and
52 // perform any additional initialization.. At this point web_ui() will return 57 // perform any additional initialization.. At this point web_ui() will return
53 // the associated WebUI object. 58 // the associated WebUI object.
54 virtual void RegisterMessages() = 0; 59 virtual void RegisterMessages() = 0;
55 60
56 // Returns the attached WebUI for this handler. 61 // Returns the attached WebUI for this handler.
57 WebUI* web_ui() const { return web_ui_; } 62 WebUI* web_ui() const { return web_ui_; }
58 63
64 // DEPRECATED. Attach during construction instead. May be kept for testing.
65 // TODO(tommycli): Remove once callers gone - or rename to SetWebUIForTesting.
59 // Sets the attached WebUI - exposed to subclasses for testing purposes. 66 // Sets the attached WebUI - exposed to subclasses for testing purposes.
60 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; } 67 void set_web_ui(WebUI* web_ui) { web_ui_ = web_ui; }
61 68
62 private: 69 private:
63 // Provide external classes access to web_ui() and set_web_ui(). 70 // Provide external classes access to web_ui() and set_web_ui().
64 friend class WebUIImpl; 71 friend class WebUIImpl;
65 friend class ::WebUIBrowserTest; 72 friend class ::WebUIBrowserTest;
66 73
67 WebUI* web_ui_; 74 WebUI* web_ui_;
68 }; 75 };
69 76
70 } // namespace content 77 } // namespace content
71 78
72 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ 79 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
OLDNEW
« content/browser/webui/web_ui_impl.cc ('K') | « content/browser/webui/web_ui_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698