Chromium Code Reviews| 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 base::SmallMap<std::map<int, NavigationFeatureDelegate*>>::iterator it = |
|
Kevin M
2016/08/01 23:41:58
You can use "auto it"
shaktisahu
2016/08/02 17:47:53
Done.
| |
| 39 delegates_.find(tab_id); | |
| 39 if (it != delegates_.end()) | 40 if (it != delegates_.end()) |
| 40 delegates_.erase(it); | 41 delegates_.erase(it); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void NavigationFeature::NavigateToUrlText(int tab_id, | 44 void NavigationFeature::NavigateToUrlText(int tab_id, |
| 44 const std::string& url_text) { | 45 const std::string& url_text) { |
| 45 // Fixes up url, e.g., convert "google.com" to "http://google.com". | 46 // 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 | 47 // 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 | 48 // 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 | 49 // 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()); | 121 delegate->OnTitleChanged(tab_id, details.title()); |
| 121 | 122 |
| 122 if (details.has_loading()) | 123 if (details.has_loading()) |
| 123 delegate->OnLoadingChanged(tab_id, details.loading()); | 124 delegate->OnLoadingChanged(tab_id, details.loading()); |
| 124 | 125 |
| 125 if (details.has_favicon()) { | 126 if (details.has_favicon()) { |
| 126 NOTIMPLEMENTED(); | 127 NOTIMPLEMENTED(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 if (details.has_page_load_completed()) { | 130 if (details.has_page_load_completed()) { |
| 130 delegate->OnPageLoadStatusUpdate(tab_id, | 131 delegate->OnPageLoadStatusUpdate(tab_id, details.page_load_completed()); |
| 131 details.page_load_completed()); | |
| 132 } | 132 } |
| 133 } break; | 133 } break; |
| 134 case NavigationMessage::LOAD_URL: | 134 case NavigationMessage::LOAD_URL: |
| 135 case NavigationMessage::GO_BACK: | 135 case NavigationMessage::GO_BACK: |
| 136 case NavigationMessage::GO_FORWARD: | 136 case NavigationMessage::GO_FORWARD: |
| 137 case NavigationMessage::RELOAD: | 137 case NavigationMessage::RELOAD: |
| 138 NOTREACHED() << "Client received unexpected navigation type."; | 138 NOTREACHED() << "Client received unexpected navigation type."; |
| 139 break; | 139 break; |
| 140 case NavigationMessage::UNKNOWN: | 140 case NavigationMessage::UNKNOWN: |
| 141 NOTREACHED(); | 141 NOTREACHED(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 callback.Run(net::OK); | 144 callback.Run(net::OK); |
| 145 } | 145 } |
| 146 | 146 |
| 147 NavigationFeature::NavigationFeatureDelegate* NavigationFeature::FindDelegate( | 147 NavigationFeature::NavigationFeatureDelegate* NavigationFeature::FindDelegate( |
| 148 const int tab_id) { | 148 const int tab_id) { |
| 149 DelegateMap::const_iterator it = delegates_.find(tab_id); | 149 base::SmallMap<std::map<int, NavigationFeatureDelegate*>>::const_iterator it = |
| 150 delegates_.find(tab_id); | |
| 150 if (it != delegates_.end()) | 151 if (it != delegates_.end()) |
| 151 return it->second; | 152 return it->second; |
| 152 return nullptr; | 153 return nullptr; |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace client | 156 } // namespace client |
| 156 } // namespace blimp | 157 } // namespace blimp |
| OLD | NEW |