| 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 "chrome/browser/custom_handlers/register_protocol_handler_permission_re
quest.h" | 5 #include "chrome/browser/custom_handlers/register_protocol_handler_permission_re
quest.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 11 #include "content/public/browser/user_metrics.h" | 11 #include "content/public/browser/user_metrics.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/gfx/vector_icons_public.h" | 13 #include "ui/vector_icons/vector_icons.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 base::string16 GetProtocolName( | 17 base::string16 GetProtocolName( |
| 18 const ProtocolHandler& handler) { | 18 const ProtocolHandler& handler) { |
| 19 if (handler.protocol() == "mailto") | 19 if (handler.protocol() == "mailto") |
| 20 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); | 20 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); |
| 21 if (handler.protocol() == "webcal") | 21 if (handler.protocol() == "webcal") |
| 22 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); | 22 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); |
| 23 return base::UTF8ToUTF16(handler.protocol()); | 23 return base::UTF8ToUTF16(handler.protocol()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 RegisterProtocolHandlerPermissionRequest | 28 RegisterProtocolHandlerPermissionRequest |
| 29 ::RegisterProtocolHandlerPermissionRequest( | 29 ::RegisterProtocolHandlerPermissionRequest( |
| 30 ProtocolHandlerRegistry* registry, | 30 ProtocolHandlerRegistry* registry, |
| 31 const ProtocolHandler& handler, | 31 const ProtocolHandler& handler, |
| 32 GURL url, | 32 GURL url, |
| 33 bool user_gesture) | 33 bool user_gesture) |
| 34 : registry_(registry), | 34 : registry_(registry), |
| 35 handler_(handler), | 35 handler_(handler), |
| 36 origin_(url.GetOrigin()) {} | 36 origin_(url.GetOrigin()) {} |
| 37 | 37 |
| 38 RegisterProtocolHandlerPermissionRequest:: | 38 RegisterProtocolHandlerPermissionRequest:: |
| 39 ~RegisterProtocolHandlerPermissionRequest() {} | 39 ~RegisterProtocolHandlerPermissionRequest() {} |
| 40 | 40 |
| 41 PermissionRequest::IconId RegisterProtocolHandlerPermissionRequest::GetIconId() | 41 PermissionRequest::IconId RegisterProtocolHandlerPermissionRequest::GetIconId() |
| 42 const { | 42 const { |
| 43 return gfx::VectorIconId::PROTOCOL_HANDLER; | 43 return ui::kProtocolHandlerIcon; |
| 44 } | 44 } |
| 45 | 45 |
| 46 base::string16 | 46 base::string16 |
| 47 RegisterProtocolHandlerPermissionRequest::GetMessageTextFragment() const { | 47 RegisterProtocolHandlerPermissionRequest::GetMessageTextFragment() const { |
| 48 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); | 48 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); |
| 49 return old_handler.IsEmpty() ? | 49 return old_handler.IsEmpty() ? |
| 50 l10n_util::GetStringFUTF16( | 50 l10n_util::GetStringFUTF16( |
| 51 IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, | 51 IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, |
| 52 GetProtocolName(handler_)) : | 52 GetProtocolName(handler_)) : |
| 53 l10n_util::GetStringFUTF16( | 53 l10n_util::GetStringFUTF16( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 void RegisterProtocolHandlerPermissionRequest::RequestFinished() { | 81 void RegisterProtocolHandlerPermissionRequest::RequestFinished() { |
| 82 delete this; | 82 delete this; |
| 83 } | 83 } |
| 84 | 84 |
| 85 PermissionRequestType | 85 PermissionRequestType |
| 86 RegisterProtocolHandlerPermissionRequest::GetPermissionRequestType() const { | 86 RegisterProtocolHandlerPermissionRequest::GetPermissionRequestType() const { |
| 87 return PermissionRequestType::REGISTER_PROTOCOL_HANDLER; | 87 return PermissionRequestType::REGISTER_PROTOCOL_HANDLER; |
| 88 } | 88 } |
| OLD | NEW |