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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 10577028: Move the mixed scripting infobar to a page action icon / content setting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/content_settings_utils.h" 8 #include "chrome/browser/content_settings/content_settings_utils.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 } 85 }
86 86
87 void SetTitle() { 87 void SetTitle() {
88 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { 88 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = {
89 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, 89 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE},
90 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, 90 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE},
91 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, 91 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE},
92 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, 92 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE},
93 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, 93 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE},
94 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
95 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT},
94 }; 96 };
95 // Fields as for kBlockedTitleIDs, above. 97 // Fields as for kBlockedTitleIDs, above.
96 static const ContentSettingsTypeIdEntry 98 static const ContentSettingsTypeIdEntry
97 kResourceSpecificBlockedTitleIDs[] = { 99 kResourceSpecificBlockedTitleIDs[] = {
98 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, 100 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE},
99 }; 101 };
100 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { 102 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = {
101 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, 103 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE},
102 }; 104 };
103 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; 105 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs;
(...skipping 14 matching lines...) Expand all
118 } 120 }
119 121
120 void SetManageLink() { 122 void SetManageLink() {
121 static const ContentSettingsTypeIdEntry kLinkIDs[] = { 123 static const ContentSettingsTypeIdEntry kLinkIDs[] = {
122 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, 124 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK},
123 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, 125 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK},
124 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, 126 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK},
125 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, 127 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK},
126 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, 128 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK},
127 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, 129 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK},
130 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE},
128 }; 131 };
129 set_manage_link(l10n_util::GetStringUTF8( 132 set_manage_link(l10n_util::GetStringUTF8(
130 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); 133 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type())));
131 } 134 }
132 135
133 virtual void OnManageLinkClicked() { 136 virtual void OnManageLinkClicked() {
134 if (delegate_) 137 if (delegate_)
135 delegate_->ShowContentSettingsPage(content_type()); 138 delegate_->ShowContentSettingsPage(content_type());
136 } 139 }
137 140
(...skipping 12 matching lines...) Expand all
150 SetCustomLink(); 153 SetCustomLink();
151 } 154 }
152 155
153 virtual ~ContentSettingTitleLinkAndCustomModel() {} 156 virtual ~ContentSettingTitleLinkAndCustomModel() {}
154 157
155 private: 158 private:
156 void SetCustomLink() { 159 void SetCustomLink() {
157 static const ContentSettingsTypeIdEntry kCustomIDs[] = { 160 static const ContentSettingsTypeIdEntry kCustomIDs[] = {
158 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_INFO}, 161 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_INFO},
159 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LOAD_ALL}, 162 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LOAD_ALL},
163 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_ALLOW_INSECURE_CONTENT_BUTTON},
160 }; 164 };
161 int custom_link_id = 165 int custom_link_id =
162 GetIdForContentType(kCustomIDs, arraysize(kCustomIDs), content_type()); 166 GetIdForContentType(kCustomIDs, arraysize(kCustomIDs), content_type());
163 if (custom_link_id) 167 if (custom_link_id)
164 set_custom_link(l10n_util::GetStringUTF8(custom_link_id)); 168 set_custom_link(l10n_util::GetStringUTF8(custom_link_id));
165 } 169 }
166 170
167 virtual void OnCustomLinkClicked() {} 171 virtual void OnCustomLinkClicked() {}
168 }; 172 };
169 173
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 settings_map->SetContentSetting( 507 settings_map->SetContentSetting(
504 ContentSettingsPattern::FromURLNoWildcard(it->first), 508 ContentSettingsPattern::FromURLNoWildcard(it->first),
505 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 509 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
506 CONTENT_SETTINGS_TYPE_GEOLOCATION, 510 CONTENT_SETTINGS_TYPE_GEOLOCATION,
507 std::string(), 511 std::string(),
508 CONTENT_SETTING_DEFAULT); 512 CONTENT_SETTING_DEFAULT);
509 } 513 }
510 } 514 }
511 }; 515 };
512 516
517 class ContentSettingMixedScriptBubbleModel
518 : public ContentSettingTitleLinkAndCustomModel {
519 public:
520 ContentSettingMixedScriptBubbleModel(Delegate* delegate,
521 TabContents* tab_contents,
522 Profile* profile,
523 ContentSettingsType content_type)
524 : ContentSettingTitleLinkAndCustomModel(
525 delegate, tab_contents, profile, content_type) {
526 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_MIXEDSCRIPT);
527 set_custom_link_enabled(true);
528 }
529
530 virtual ~ContentSettingMixedScriptBubbleModel() {}
531
532 private:
533 virtual void OnCustomLinkClicked() OVERRIDE {
534 content::RecordAction(UserMetricsAction("MixedScript_LoadAnyway_Bubble"));
535 DCHECK(tab_contents());
536 content::RenderViewHost* host =
537 tab_contents()->web_contents()->GetRenderViewHost();
538 host->Send(new ChromeViewMsg_SetAllowRunningInsecureContent(
539 host->GetRoutingID(), true));
540 }
541 };
542
513 // static 543 // static
514 ContentSettingBubbleModel* 544 ContentSettingBubbleModel*
515 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 545 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
516 Delegate* delegate, 546 Delegate* delegate,
517 TabContents* tab_contents, 547 TabContents* tab_contents,
518 Profile* profile, 548 Profile* profile,
519 ContentSettingsType content_type) { 549 ContentSettingsType content_type) {
520 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 550 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
521 return new ContentSettingCookiesBubbleModel(delegate, tab_contents, profile, 551 return new ContentSettingCookiesBubbleModel(delegate, tab_contents, profile,
522 content_type); 552 content_type);
523 } 553 }
524 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { 554 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) {
525 return new ContentSettingPopupBubbleModel(delegate, tab_contents, profile, 555 return new ContentSettingPopupBubbleModel(delegate, tab_contents, profile,
526 content_type); 556 content_type);
527 } 557 }
528 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 558 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
529 return new ContentSettingDomainListBubbleModel(delegate, tab_contents, 559 return new ContentSettingDomainListBubbleModel(delegate, tab_contents,
530 profile, content_type); 560 profile, content_type);
531 } 561 }
532 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { 562 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) {
533 return new ContentSettingPluginBubbleModel(delegate, tab_contents, profile, 563 return new ContentSettingPluginBubbleModel(delegate, tab_contents, profile,
534 content_type); 564 content_type);
535 } 565 }
566 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
567 return new ContentSettingMixedScriptBubbleModel(delegate, tab_contents,
568 profile, content_type);
569 }
536 return new ContentSettingSingleRadioGroup(delegate, tab_contents, profile, 570 return new ContentSettingSingleRadioGroup(delegate, tab_contents, profile,
537 content_type); 571 content_type);
538 } 572 }
539 573
540 ContentSettingBubbleModel::ContentSettingBubbleModel( 574 ContentSettingBubbleModel::ContentSettingBubbleModel(
541 TabContents* tab_contents, 575 TabContents* tab_contents,
542 Profile* profile, 576 Profile* profile,
543 ContentSettingsType content_type) 577 ContentSettingsType content_type)
544 : tab_contents_(tab_contents), 578 : tab_contents_(tab_contents),
545 profile_(profile), 579 profile_(profile),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 const content::NotificationDetails& details) { 614 const content::NotificationDetails& details) {
581 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) { 615 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) {
582 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr()); 616 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr());
583 tab_contents_ = NULL; 617 tab_contents_ = NULL;
584 } else { 618 } else {
585 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 619 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
586 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 620 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
587 profile_ = NULL; 621 profile_ = NULL;
588 } 622 }
589 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698