Chromium Code Reviews| 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/gfx/vector_icons_public.h" |
| 14 | 14 |
| 15 #if defined(OS_MACOSX) | |
| 16 #include "chrome/grit/theme_resources.h" | |
| 17 #endif | |
| 18 | |
| 19 namespace { | 15 namespace { |
| 20 | 16 |
| 21 base::string16 GetProtocolName( | 17 base::string16 GetProtocolName( |
| 22 const ProtocolHandler& handler) { | 18 const ProtocolHandler& handler) { |
| 23 if (handler.protocol() == "mailto") | 19 if (handler.protocol() == "mailto") |
| 24 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); | 20 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); |
| 25 if (handler.protocol() == "webcal") | 21 if (handler.protocol() == "webcal") |
| 26 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); | 22 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); |
| 27 return base::UTF8ToUTF16(handler.protocol()); | 23 return base::UTF8ToUTF16(handler.protocol()); |
| 28 } | 24 } |
| 29 | 25 |
| 30 } // namespace | 26 } // namespace |
| 31 | 27 |
| 32 RegisterProtocolHandlerPermissionRequest | 28 RegisterProtocolHandlerPermissionRequest |
| 33 ::RegisterProtocolHandlerPermissionRequest( | 29 ::RegisterProtocolHandlerPermissionRequest( |
| 34 ProtocolHandlerRegistry* registry, | 30 ProtocolHandlerRegistry* registry, |
| 35 const ProtocolHandler& handler, | 31 const ProtocolHandler& handler, |
| 36 GURL url, | 32 GURL url, |
| 37 bool user_gesture) | 33 bool user_gesture) |
| 38 : registry_(registry), | 34 : registry_(registry), |
| 39 handler_(handler), | 35 handler_(handler), |
| 40 origin_(url.GetOrigin()) {} | 36 origin_(url.GetOrigin()) {} |
| 41 | 37 |
| 42 RegisterProtocolHandlerPermissionRequest:: | 38 RegisterProtocolHandlerPermissionRequest:: |
| 43 ~RegisterProtocolHandlerPermissionRequest() {} | 39 ~RegisterProtocolHandlerPermissionRequest() {} |
| 44 | 40 |
| 45 gfx::VectorIconId RegisterProtocolHandlerPermissionRequest::GetVectorIconId() | 41 PermissionRequest::IconId RegisterProtocolHandlerPermissionRequest::GetIconId() |
| 46 const { | 42 const { |
| 47 #if defined(OS_MACOSX) | |
| 48 return gfx::VectorIconId::VECTOR_ICON_NONE; | |
|
lshang
2016/10/11 12:26:57
Did you remove this because this file will never g
Evan Stade
2016/10/12 15:12:36
vector icons work fine on osx. At the time these i
lshang
2016/10/13 05:03:10
Are the visual representation of gfx::VectorIconId
Evan Stade
2016/10/14 14:58:29
any difference is an intentional update to better
| |
| 49 #else | |
| 50 return gfx::VectorIconId::PROTOCOL_HANDLER; | 43 return gfx::VectorIconId::PROTOCOL_HANDLER; |
| 51 #endif | |
| 52 } | |
| 53 | |
| 54 int RegisterProtocolHandlerPermissionRequest::GetIconId() const { | |
| 55 #if defined(OS_MACOSX) | |
| 56 return IDR_REGISTER_PROTOCOL_HANDLER; | |
| 57 #else | |
| 58 return 0; | |
| 59 #endif | |
| 60 } | 44 } |
| 61 | 45 |
| 62 base::string16 | 46 base::string16 |
| 63 RegisterProtocolHandlerPermissionRequest::GetMessageTextFragment() const { | 47 RegisterProtocolHandlerPermissionRequest::GetMessageTextFragment() const { |
| 64 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); | 48 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); |
| 65 return old_handler.IsEmpty() ? | 49 return old_handler.IsEmpty() ? |
| 66 l10n_util::GetStringFUTF16( | 50 l10n_util::GetStringFUTF16( |
| 67 IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, | 51 IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, |
| 68 GetProtocolName(handler_)) : | 52 GetProtocolName(handler_)) : |
| 69 l10n_util::GetStringFUTF16( | 53 l10n_util::GetStringFUTF16( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 95 } | 79 } |
| 96 | 80 |
| 97 void RegisterProtocolHandlerPermissionRequest::RequestFinished() { | 81 void RegisterProtocolHandlerPermissionRequest::RequestFinished() { |
| 98 delete this; | 82 delete this; |
| 99 } | 83 } |
| 100 | 84 |
| 101 PermissionRequestType | 85 PermissionRequestType |
| 102 RegisterProtocolHandlerPermissionRequest::GetPermissionRequestType() const { | 86 RegisterProtocolHandlerPermissionRequest::GetPermissionRequestType() const { |
| 103 return PermissionRequestType::REGISTER_PROTOCOL_HANDLER; | 87 return PermissionRequestType::REGISTER_PROTOCOL_HANDLER; |
| 104 } | 88 } |
| OLD | NEW |