| 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 #include "blimp/client/feature/navigation_feature.h" | 5 #include "blimp/client/core/contents/navigation_feature.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "blimp/common/create_blimp_message.h" | 10 #include "blimp/common/create_blimp_message.h" |
| 11 #include "blimp/common/proto/blimp_message.pb.h" | 11 #include "blimp/common/proto/blimp_message.pb.h" |
| 12 #include "blimp/common/proto/navigation.pb.h" | 12 #include "blimp/common/proto/navigation.pb.h" |
| 13 #include "components/url_formatter/url_fixer.h" | 13 #include "components/url_formatter/url_fixer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 28 outgoing_message_processor_ = std::move(processor); | 28 outgoing_message_processor_ = std::move(processor); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void NavigationFeature::SetDelegate(int tab_id, | 31 void NavigationFeature::SetDelegate(int tab_id, |
| 32 NavigationFeatureDelegate* delegate) { | 32 NavigationFeatureDelegate* delegate) { |
| 33 DCHECK(!FindDelegate(tab_id)); | 33 DCHECK(!FindDelegate(tab_id)); |
| 34 delegates_[tab_id] = delegate; | 34 delegates_[tab_id] = delegate; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void NavigationFeature::RemoveDelegate(int tab_id) { | 37 void NavigationFeature::RemoveDelegate(int tab_id) { |
| 38 DelegateMap::iterator it = delegates_.find(tab_id); | 38 auto it = delegates_.find(tab_id); |
| 39 if (it != delegates_.end()) | 39 if (it != delegates_.end()) |
| 40 delegates_.erase(it); | 40 delegates_.erase(it); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void NavigationFeature::NavigateToUrlText(int tab_id, | 43 void NavigationFeature::NavigateToUrlText(int tab_id, |
| 44 const std::string& url_text) { | 44 const std::string& url_text) { |
| 45 // Fixes up url, e.g., convert "google.com" to "http://google.com". | 45 // Fixes up url, e.g., convert "google.com" to "http://google.com". |
| 46 // It also converts "example" to "http://example/" (a valid GURL but no | 46 // It also converts "example" to "http://example/" (a valid GURL but no |
| 47 // website). In order to use search instead in this case, we check | 47 // website). In order to use search instead in this case, we check |
| 48 // the host part of the URL to see if it contains '.', and use search | 48 // the host part of the URL to see if it contains '.', and use search |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 delegate->OnTitleChanged(tab_id, details.title()); | 120 delegate->OnTitleChanged(tab_id, details.title()); |
| 121 | 121 |
| 122 if (details.has_loading()) | 122 if (details.has_loading()) |
| 123 delegate->OnLoadingChanged(tab_id, details.loading()); | 123 delegate->OnLoadingChanged(tab_id, details.loading()); |
| 124 | 124 |
| 125 if (details.has_favicon()) { | 125 if (details.has_favicon()) { |
| 126 NOTIMPLEMENTED(); | 126 NOTIMPLEMENTED(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 if (details.has_page_load_completed()) { | 129 if (details.has_page_load_completed()) { |
| 130 delegate->OnPageLoadStatusUpdate(tab_id, | 130 delegate->OnPageLoadStatusUpdate(tab_id, details.page_load_completed()); |
| 131 details.page_load_completed()); | |
| 132 } | 131 } |
| 133 } break; | 132 } break; |
| 134 case NavigationMessage::LOAD_URL: | 133 case NavigationMessage::LOAD_URL: |
| 135 case NavigationMessage::GO_BACK: | 134 case NavigationMessage::GO_BACK: |
| 136 case NavigationMessage::GO_FORWARD: | 135 case NavigationMessage::GO_FORWARD: |
| 137 case NavigationMessage::RELOAD: | 136 case NavigationMessage::RELOAD: |
| 138 NOTREACHED() << "Client received unexpected navigation type."; | 137 NOTREACHED() << "Client received unexpected navigation type."; |
| 139 break; | 138 break; |
| 140 case NavigationMessage::UNKNOWN: | 139 case NavigationMessage::UNKNOWN: |
| 141 NOTREACHED(); | 140 NOTREACHED(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 callback.Run(net::OK); | 143 callback.Run(net::OK); |
| 145 } | 144 } |
| 146 | 145 |
| 147 NavigationFeature::NavigationFeatureDelegate* NavigationFeature::FindDelegate( | 146 NavigationFeature::NavigationFeatureDelegate* NavigationFeature::FindDelegate( |
| 148 const int tab_id) { | 147 const int tab_id) { |
| 149 DelegateMap::const_iterator it = delegates_.find(tab_id); | 148 base::SmallMap<std::map<int, NavigationFeatureDelegate*>>::const_iterator it = |
| 149 delegates_.find(tab_id); |
| 150 if (it != delegates_.end()) | 150 if (it != delegates_.end()) |
| 151 return it->second; | 151 return it->second; |
| 152 return nullptr; | 152 return nullptr; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace client | 155 } // namespace client |
| 156 } // namespace blimp | 156 } // namespace blimp |
| OLD | NEW |