Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: chrome/browser/ssl/ssl_policy_backend.cc

Issue 3127009: Convert infobar APIs to UTF-16. (Closed)
Patch Set: works Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/ssl/ssl_policy_backend.h" 5 #include "chrome/browser/ssl/ssl_policy_backend.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
9 #include "chrome/browser/ssl/ssl_host_state.h" 10 #include "chrome/browser/ssl/ssl_host_state.h"
10 #include "chrome/browser/tab_contents/infobar_delegate.h" 11 #include "chrome/browser/tab_contents/infobar_delegate.h"
11 #include "chrome/browser/tab_contents/navigation_controller.h" 12 #include "chrome/browser/tab_contents/navigation_controller.h"
12 #include "chrome/browser/tab_contents/navigation_entry.h" 13 #include "chrome/browser/tab_contents/navigation_entry.h"
13 #include "chrome/browser/tab_contents/tab_contents.h" 14 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
15 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
16 17
17 class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { 18 class SSLInfoBarDelegate : public ConfirmInfoBarDelegate {
18 public: 19 public:
19 SSLInfoBarDelegate(TabContents* contents, 20 SSLInfoBarDelegate(TabContents* contents,
20 const std::wstring message, 21 const string16& message,
21 const std::wstring& button_label, 22 const string16& button_label,
22 Task* task) 23 Task* task)
23 : ConfirmInfoBarDelegate(contents), 24 : ConfirmInfoBarDelegate(contents),
24 message_(message), 25 message_(message),
25 button_label_(button_label), 26 button_label_(button_label),
26 task_(task) { 27 task_(task) {
27 } 28 }
28 virtual ~SSLInfoBarDelegate() {} 29 virtual ~SSLInfoBarDelegate() {}
29 30
30 // Overridden from ConfirmInfoBarDelegate: 31 // Overridden from ConfirmInfoBarDelegate:
31 virtual void InfoBarClosed() { 32 virtual void InfoBarClosed() {
32 delete this; 33 delete this;
33 } 34 }
34 virtual std::wstring GetMessageText() const { 35 virtual string16 GetMessageText() const {
35 return message_; 36 return message_;
36 } 37 }
37 virtual SkBitmap* GetIcon() const { 38 virtual SkBitmap* GetIcon() const {
38 return ResourceBundle::GetSharedInstance().GetBitmapNamed( 39 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
39 IDR_INFOBAR_SSL_WARNING); 40 IDR_INFOBAR_SSL_WARNING);
40 } 41 }
41 virtual int GetButtons() const { 42 virtual int GetButtons() const {
42 return !button_label_.empty() ? BUTTON_OK : BUTTON_NONE; 43 return !button_label_.empty() ? BUTTON_OK : BUTTON_NONE;
43 } 44 }
44 virtual std::wstring GetButtonLabel(InfoBarButton button) const { 45 virtual string16 GetButtonLabel(InfoBarButton button) const {
45 return button_label_; 46 return button_label_;
46 } 47 }
47 virtual bool Accept() { 48 virtual bool Accept() {
48 if (task_.get()) { 49 if (task_.get()) {
49 task_->Run(); 50 task_->Run();
50 task_.reset(); // Ensures we won't run the task again. 51 task_.reset(); // Ensures we won't run the task again.
51 } 52 }
52 return true; 53 return true;
53 } 54 }
54 55
55 private: 56 private:
56 // Labels for the InfoBar's message and button. 57 // Labels for the InfoBar's message and button.
57 std::wstring message_; 58 string16 message_;
58 std::wstring button_label_; 59 string16 button_label_;
59 60
60 // A task to run when the InfoBar is accepted. 61 // A task to run when the InfoBar is accepted.
61 scoped_ptr<Task> task_; 62 scoped_ptr<Task> task_;
62 63
63 DISALLOW_COPY_AND_ASSIGN(SSLInfoBarDelegate); 64 DISALLOW_COPY_AND_ASSIGN(SSLInfoBarDelegate);
64 }; 65 };
65 66
66 SSLPolicyBackend::SSLPolicyBackend(NavigationController* controller) 67 SSLPolicyBackend::SSLPolicyBackend(NavigationController* controller)
67 : controller_(controller), 68 : controller_(controller),
68 ssl_host_state_(controller->profile()->GetSSLHostState()) { 69 ssl_host_state_(controller->profile()->GetSSLHostState()) {
(...skipping 20 matching lines...) Expand all
89 90
90 NavigationEntry* entry = controller_->GetActiveEntry(); 91 NavigationEntry* entry = controller_->GetActiveEntry();
91 if (!entry) 92 if (!entry)
92 return; 93 return;
93 94
94 // Don't show the message if the user doesn't expect an authenticated session. 95 // Don't show the message if the user doesn't expect an authenticated session.
95 if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED) 96 if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED)
96 return; 97 return;
97 98
98 if (controller_->tab_contents()) { 99 if (controller_->tab_contents()) {
100 // TODO(evanm): remove base/utf_string_conversions.h include after fixing
101 // below conversions.
99 controller_->tab_contents()->AddInfoBar( 102 controller_->tab_contents()->AddInfoBar(
100 new SSLInfoBarDelegate(controller_->tab_contents(), msg, link_text, 103 new SSLInfoBarDelegate(controller_->tab_contents(),
104 WideToUTF16Hack(msg),
105 WideToUTF16Hack(link_text),
101 task)); 106 task));
102 } 107 }
103 } 108 }
104 109
105 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, 110 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host,
106 int id) { 111 int id) {
107 ssl_host_state_->HostRanInsecureContent(host, id); 112 ssl_host_state_->HostRanInsecureContent(host, id);
108 SSLManager::NotifySSLInternalStateChanged(); 113 SSLManager::NotifySSLInternalStateChanged();
109 } 114 }
110 115
(...skipping 22 matching lines...) Expand all
133 for (iter = pending_messages_.begin(); 138 for (iter = pending_messages_.begin();
134 iter != pending_messages_.end(); ++iter) { 139 iter != pending_messages_.end(); ++iter) {
135 ShowMessageWithLink(iter->message, iter->link_text, iter->action); 140 ShowMessageWithLink(iter->message, iter->link_text, iter->action);
136 } 141 }
137 ClearPendingMessages(); 142 ClearPendingMessages();
138 } 143 }
139 144
140 void SSLPolicyBackend::ClearPendingMessages() { 145 void SSLPolicyBackend::ClearPendingMessages() {
141 pending_messages_.clear(); 146 pending_messages_.clear();
142 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698