| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/external_protocol_dialog_delegate.h" | 5 #include "chrome/browser/ui/external_protocol_dialog_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 7 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/tab_contents/tab_util.h" | 8 #include "chrome/browser/tab_contents/tab_util.h" |
| 10 #include "chrome/grit/chromium_strings.h" | 9 #include "chrome/grit/chromium_strings.h" |
| 11 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 12 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/gfx/text_elider.h" | 13 #include "ui/gfx/text_elider.h" |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 const size_t kMaxCommandSize = 32; | 17 const size_t kMaxCommandSize = 32; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 ElideCommandName(program_name_)); | 54 ElideCommandName(program_name_)); |
| 56 } | 55 } |
| 57 | 56 |
| 58 base::string16 ExternalProtocolDialogDelegate::GetTitleText() const { | 57 base::string16 ExternalProtocolDialogDelegate::GetTitleText() const { |
| 59 return l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_TITLE, | 58 return l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_TITLE, |
| 60 ElideCommandName(program_name_)); | 59 ElideCommandName(program_name_)); |
| 61 } | 60 } |
| 62 | 61 |
| 63 void ExternalProtocolDialogDelegate::DoAccept(const GURL& url, | 62 void ExternalProtocolDialogDelegate::DoAccept(const GURL& url, |
| 64 bool dont_block) const { | 63 bool dont_block) const { |
| 64 if (dont_block) { |
| 65 ExternalProtocolHandler::SetBlockState(url.scheme(), |
| 66 ExternalProtocolHandler::DONT_BLOCK); |
| 67 } |
| 68 |
| 65 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 69 content::WebContents* web_contents = tab_util::GetWebContentsByID( |
| 66 render_process_host_id_, render_view_routing_id_); | 70 render_process_host_id_, render_view_routing_id_); |
| 67 | 71 |
| 68 if (dont_block) { | |
| 69 Profile* profile = | |
| 70 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 71 | |
| 72 ExternalProtocolHandler::SetBlockState( | |
| 73 url.scheme(), ExternalProtocolHandler::DONT_BLOCK, profile); | |
| 74 } | |
| 75 | |
| 76 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); | 72 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
| 77 } | 73 } |
| 78 | 74 |
| 79 void ExternalProtocolDialogDelegate::DoCancel(const GURL& url, | 75 void ExternalProtocolDialogDelegate::DoCancel(const GURL& url, |
| 80 bool dont_block) const { | 76 bool dont_block) const { |
| 81 if (dont_block) { | 77 if (dont_block) { |
| 82 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 78 ExternalProtocolHandler::SetBlockState(url.scheme(), |
| 83 render_process_host_id_, render_view_routing_id_); | 79 ExternalProtocolHandler::BLOCK); |
| 84 Profile* profile = | |
| 85 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 86 | |
| 87 ExternalProtocolHandler::SetBlockState( | |
| 88 url.scheme(), ExternalProtocolHandler::BLOCK, profile); | |
| 89 } | 80 } |
| 90 } | 81 } |
| OLD | NEW |