| 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 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" |
| 10 #include "base/string16.h" | 11 #include "base/string16.h" |
| 11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 12 #include "testing/gtest/include/gtest/gtest_prod.h" | 13 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 class WebUIImpl; | 16 class WebUIImpl; |
| 16 class WebUIBrowserTest; | 17 class WebUIBrowserTest; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class DictionaryValue; | 20 class DictionaryValue; |
| 20 class ListValue; | 21 class ListValue; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 class WebUI; | 26 class WebUI; |
| 26 | 27 |
| 27 // Messages sent from the DOM are forwarded via the WebUI to handler | 28 // Messages sent from the DOM are forwarded via the WebUI to handler |
| 28 // classes. These objects are owned by WebUI and destroyed when the | 29 // classes. These objects are owned by WebUI and destroyed when the |
| 29 // host is destroyed. | 30 // host is destroyed. |
| 30 class CONTENT_EXPORT WebUIMessageHandler { | 31 class CONTENT_EXPORT WebUIMessageHandler { |
| 31 public: | 32 public: |
| 32 WebUIMessageHandler() : web_ui_(NULL) {} | 33 WebUIMessageHandler() : web_ui_(NULL) {} |
| 33 virtual ~WebUIMessageHandler() {} | 34 virtual ~WebUIMessageHandler() {} |
| 34 | 35 |
| 35 protected: | 36 protected: |
| 37 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractIntegerValue); |
| 38 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractDoubleValue); |
| 39 FRIEND_TEST_ALL_PREFIXES(WebUIMessageHandlerTest, ExtractStringValue); |
| 40 |
| 36 // Helper methods: | 41 // Helper methods: |
| 37 | 42 |
| 38 // Adds "url" and "title" keys on incoming dictionary, setting title | 43 // Adds "url" and "title" keys on incoming dictionary, setting title |
| 39 // as the url as a fallback on empty title. | 44 // as the url as a fallback on empty title. |
| 40 static void SetURLAndTitle(base::DictionaryValue* dictionary, | 45 static void SetURLAndTitle(base::DictionaryValue* dictionary, |
| 41 string16 title, | 46 string16 title, |
| 42 const GURL& gurl); | 47 const GURL& gurl); |
| 43 | 48 |
| 44 // Extract an integer value from a list Value. | 49 // Extract an integer value from a list Value. |
| 45 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); | 50 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 friend class ::WebUIImpl; | 72 friend class ::WebUIImpl; |
| 68 friend class ::WebUIBrowserTest; | 73 friend class ::WebUIBrowserTest; |
| 69 | 74 |
| 70 WebUI* web_ui_; | 75 WebUI* web_ui_; |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 } // namespace content | 78 } // namespace content |
| 74 | 79 |
| 75 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ | 80 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_ |
| 76 | 81 |
| OLD | NEW |