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