OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ | 5 #ifndef BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ |
6 #define BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ | 6 #define BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/containers/small_map.h" | 11 #include "base/containers/small_map.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "blimp/net/blimp_connection_details.h" | |
13 #include "blimp/net/blimp_message_processor.h" | 14 #include "blimp/net/blimp_message_processor.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
16 class SkBitmap; | 17 class SkBitmap; |
17 | 18 |
18 namespace blimp { | 19 namespace blimp { |
19 namespace client { | 20 namespace client { |
20 | 21 |
21 // Handles all incoming and outgoing protobuf messages of type | 22 // Handles all incoming and outgoing protobuf messages of type |
22 // RenderWidget::NAVIGATION. Delegates can be added to be notified of incoming | 23 // RenderWidget::NAVIGATION. Delegates can be added to be notified of incoming |
23 // messages. | 24 // messages. |
24 class NavigationFeature : public BlimpMessageProcessor { | 25 class NavigationFeature : public BlimpMessageProcessor { |
25 public: | 26 public: |
26 // A delegate to be notified of specific navigation events related to a | 27 // A delegate to be notified of specific navigation events related to a |
27 // a particular tab. | 28 // a particular tab. |
28 class NavigationFeatureDelegate { | 29 class NavigationFeatureDelegate { |
29 public: | 30 public: |
30 virtual ~NavigationFeatureDelegate() {} | 31 virtual ~NavigationFeatureDelegate() {} |
31 virtual void OnUrlChanged(int tab_id, const GURL& url) = 0; | 32 virtual void OnUrlChanged(int tab_id, const GURL& url) = 0; |
32 virtual void OnFaviconChanged(int tab_id, const SkBitmap& favicon) = 0; | 33 virtual void OnFaviconChanged(int tab_id, const SkBitmap& favicon) = 0; |
33 virtual void OnTitleChanged(int tab_id, const std::string& title) = 0; | 34 virtual void OnTitleChanged(int tab_id, const std::string& title) = 0; |
34 virtual void OnLoadingChanged(int tab_id, bool loading) = 0; | 35 virtual void OnLoadingChanged(int tab_id, bool loading) = 0; |
35 virtual void OnPageLoadStatusUpdate(int tab_id, bool completed) = 0; | 36 virtual void OnPageLoadStatusUpdate(int tab_id, bool completed) = 0; |
36 }; | 37 }; |
37 | 38 |
38 NavigationFeature(); | 39 NavigationFeature(BlimpConnectionDetails* details); |
39 ~NavigationFeature() override; | 40 ~NavigationFeature() override; |
40 | 41 |
41 // Set the BlimpMessageProcessor that will be used to send | 42 // Set the BlimpMessageProcessor that will be used to send |
42 // BlimpMessage::NAVIGATION messages to the engine. | 43 // BlimpMessage::NAVIGATION messages to the engine. |
43 void set_outgoing_message_processor( | 44 void set_outgoing_message_processor( |
44 std::unique_ptr<BlimpMessageProcessor> processor); | 45 std::unique_ptr<BlimpMessageProcessor> processor); |
45 | 46 |
46 // Sets a NavigationMessageDelegate to be notified of all navigation messages | 47 // Sets a NavigationMessageDelegate to be notified of all navigation messages |
47 // for |tab_id| from the engine. | 48 // for |tab_id| from the engine. |
48 void SetDelegate(int tab_id, NavigationFeatureDelegate* delegate); | 49 void SetDelegate(int tab_id, NavigationFeatureDelegate* delegate); |
49 void RemoveDelegate(int tab_id); | 50 void RemoveDelegate(int tab_id); |
50 | 51 |
51 void NavigateToUrlText(int tab_id, const std::string& url_text); | 52 void NavigateToUrlText(int tab_id, const std::string& url_text); |
52 void Reload(int tab_id); | 53 void Reload(int tab_id); |
53 void GoForward(int tab_id); | 54 void GoForward(int tab_id); |
54 void GoBack(int tab_id); | 55 void GoBack(int tab_id); |
55 | 56 |
56 private: | 57 private: |
57 // BlimpMessageProcessor implementation. | 58 // BlimpMessageProcessor implementation. |
58 void ProcessMessage(std::unique_ptr<BlimpMessage> message, | 59 void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
59 const net::CompletionCallback& callback) override; | 60 const net::CompletionCallback& callback) override; |
60 | 61 |
61 NavigationFeatureDelegate* FindDelegate(const int tab_id); | 62 NavigationFeatureDelegate* FindDelegate(const int tab_id); |
62 | 63 |
63 typedef base::SmallMap<std::map<int, NavigationFeatureDelegate*>> DelegateMap; | 64 typedef base::SmallMap<std::map<int, NavigationFeatureDelegate*>> DelegateMap; |
64 | 65 |
65 DelegateMap delegates_; | 66 DelegateMap delegates_; |
66 | 67 |
68 BlimpConnectionDetails* connection_details_ = nullptr; | |
Khushal
2016/05/18 00:23:00
Do you need to initialize it to nullptr here? The
shaktisahu
2016/05/19 21:39:18
Done.
| |
69 | |
67 // Used to send BlimpMessage::NAVIGATION messages to the engine. | 70 // Used to send BlimpMessage::NAVIGATION messages to the engine. |
68 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; | 71 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
69 | 72 |
70 DISALLOW_COPY_AND_ASSIGN(NavigationFeature); | 73 DISALLOW_COPY_AND_ASSIGN(NavigationFeature); |
71 }; | 74 }; |
72 | 75 |
73 } // namespace client | 76 } // namespace client |
74 } // namespace blimp | 77 } // namespace blimp |
75 | 78 |
76 #endif // BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ | 79 #endif // BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ |
OLD | NEW |