| 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 void OnUrlChanged(int tab_id, const GURL& url) = 0; | 31 virtual void OnUrlChanged(int tab_id, const GURL& url) = 0; |
| 31 virtual void OnFaviconChanged(int tab_id, const SkBitmap& favicon) = 0; | 32 virtual void OnFaviconChanged(int tab_id, const SkBitmap& favicon) = 0; |
| 32 virtual void OnTitleChanged(int tab_id, const std::string& title) = 0; | 33 virtual void OnTitleChanged(int tab_id, const std::string& title) = 0; |
| 33 virtual void OnLoadingChanged(int tab_id, bool loading) = 0; | 34 virtual void OnLoadingChanged(int tab_id, bool loading) = 0; |
| 34 virtual void OnPageLoadStatusUpdate(int tab_id, bool completed) = 0; | 35 virtual void OnPageLoadStatusUpdate(int tab_id, bool completed) = 0; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 NavigationFeature(); | 38 NavigationFeature(BlimpConnectionDetails* details); |
| 38 ~NavigationFeature() override; | 39 ~NavigationFeature() override; |
| 39 | 40 |
| 40 // Set the BlimpMessageProcessor that will be used to send | 41 // Set the BlimpMessageProcessor that will be used to send |
| 41 // BlimpMessage::NAVIGATION messages to the engine. | 42 // BlimpMessage::NAVIGATION messages to the engine. |
| 42 void set_outgoing_message_processor( | 43 void set_outgoing_message_processor( |
| 43 std::unique_ptr<BlimpMessageProcessor> processor); | 44 std::unique_ptr<BlimpMessageProcessor> processor); |
| 44 | 45 |
| 45 // Sets a NavigationMessageDelegate to be notified of all navigation messages | 46 // Sets a NavigationMessageDelegate to be notified of all navigation messages |
| 46 // for |tab_id| from the engine. | 47 // for |tab_id| from the engine. |
| 47 void SetDelegate(int tab_id, NavigationFeatureDelegate* delegate); | 48 void SetDelegate(int tab_id, NavigationFeatureDelegate* delegate); |
| 48 void RemoveDelegate(int tab_id); | 49 void RemoveDelegate(int tab_id); |
| 49 | 50 |
| 50 void NavigateToUrlText(int tab_id, const std::string& url_text); | 51 void NavigateToUrlText(int tab_id, const std::string& url_text); |
| 51 void Reload(int tab_id); | 52 void Reload(int tab_id); |
| 52 void GoForward(int tab_id); | 53 void GoForward(int tab_id); |
| 53 void GoBack(int tab_id); | 54 void GoBack(int tab_id); |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 // BlimpMessageProcessor implementation. | 57 // BlimpMessageProcessor implementation. |
| 57 void ProcessMessage(std::unique_ptr<BlimpMessage> message, | 58 void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| 58 const net::CompletionCallback& callback) override; | 59 const net::CompletionCallback& callback) override; |
| 59 | 60 |
| 60 NavigationFeatureDelegate* FindDelegate(const int tab_id); | 61 NavigationFeatureDelegate* FindDelegate(const int tab_id); |
| 61 | 62 |
| 62 typedef base::SmallMap<std::map<int, NavigationFeatureDelegate*>> DelegateMap; | 63 typedef base::SmallMap<std::map<int, NavigationFeatureDelegate*>> DelegateMap; |
| 63 | 64 |
| 64 DelegateMap delegates_; | 65 DelegateMap delegates_; |
| 65 | 66 |
| 67 BlimpConnectionDetails* connection_details_ = nullptr; |
| 68 |
| 66 // Used to send BlimpMessage::NAVIGATION messages to the engine. | 69 // Used to send BlimpMessage::NAVIGATION messages to the engine. |
| 67 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; | 70 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
| 68 | 71 |
| 69 DISALLOW_COPY_AND_ASSIGN(NavigationFeature); | 72 DISALLOW_COPY_AND_ASSIGN(NavigationFeature); |
| 70 }; | 73 }; |
| 71 | 74 |
| 72 } // namespace client | 75 } // namespace client |
| 73 } // namespace blimp | 76 } // namespace blimp |
| 74 | 77 |
| 75 #endif // BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ | 78 #endif // BLIMP_CLIENT_FEATURE_NAVIGATION_FEATURE_H_ |
| OLD | NEW |