OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 | 141 |
142 void ParsePartitionParam(const base::DictionaryValue& create_params, | 142 void ParsePartitionParam(const base::DictionaryValue& create_params, |
143 std::string* storage_partition_id, | 143 std::string* storage_partition_id, |
144 bool* persist_storage) { | 144 bool* persist_storage) { |
145 std::string partition_str; | 145 std::string partition_str; |
146 if (!create_params.GetString(webview::kStoragePartitionId, &partition_str)) { | 146 if (!create_params.GetString(webview::kStoragePartitionId, &partition_str)) { |
147 return; | 147 return; |
148 } | 148 } |
149 | 149 |
150 // Since the "persist:" prefix is in ASCII, StartsWith will work fine on | 150 // Since the "persist:" prefix is in ASCII, base::StartsWith will work fine on |
151 // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely | 151 // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely |
152 // remove the prefix without splicing in the middle of a multi-byte codepoint. | 152 // remove the prefix without splicing in the middle of a multi-byte codepoint. |
153 // We can use the rest of the string as UTF-8 encoded one. | 153 // We can use the rest of the string as UTF-8 encoded one. |
154 if (StartsWithASCII(partition_str, "persist:", true)) { | 154 if (base::StartsWithASCII(partition_str, "persist:", true)) { |
155 size_t index = partition_str.find(":"); | 155 size_t index = partition_str.find(":"); |
156 CHECK(index != std::string::npos); | 156 CHECK(index != std::string::npos); |
157 // It is safe to do index + 1, since we tested for the full prefix above. | 157 // It is safe to do index + 1, since we tested for the full prefix above. |
158 *storage_partition_id = partition_str.substr(index + 1); | 158 *storage_partition_id = partition_str.substr(index + 1); |
159 | 159 |
160 if (storage_partition_id->empty()) { | 160 if (storage_partition_id->empty()) { |
161 // TODO(lazyboy): Better way to deal with this error. | 161 // TODO(lazyboy): Better way to deal with this error. |
162 return; | 162 return; |
163 } | 163 } |
164 *persist_storage = true; | 164 *persist_storage = true; |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1452 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
1453 DispatchEventToView( | 1453 DispatchEventToView( |
1454 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); | 1454 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); |
1455 } | 1455 } |
1456 // Since we changed fullscreen state, sending a Resize message ensures that | 1456 // Since we changed fullscreen state, sending a Resize message ensures that |
1457 // renderer/ sees the change. | 1457 // renderer/ sees the change. |
1458 web_contents()->GetRenderViewHost()->WasResized(); | 1458 web_contents()->GetRenderViewHost()->WasResized(); |
1459 } | 1459 } |
1460 | 1460 |
1461 } // namespace extensions | 1461 } // namespace extensions |
OLD | NEW |