Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 | 58 |
| 59 using base::UserMetricsAction; | 59 using base::UserMetricsAction; |
| 60 using content::WebContents; | 60 using content::WebContents; |
| 61 using content_settings::SettingInfo; | 61 using content_settings::SettingInfo; |
| 62 using content_settings::SettingSource; | 62 using content_settings::SettingSource; |
| 63 using content_settings::SETTING_SOURCE_USER; | 63 using content_settings::SETTING_SOURCE_USER; |
| 64 using content_settings::SETTING_SOURCE_NONE; | 64 using content_settings::SETTING_SOURCE_NONE; |
| 65 | 65 |
| 66 namespace { | 66 namespace { |
| 67 | 67 |
| 68 const int kAllowButtonIndex = 0; | |
| 69 | |
| 70 // These states must match the order of appearance of the radio buttons | 68 // These states must match the order of appearance of the radio buttons |
| 71 // in the XIB file for the Mac port. | 69 // in the XIB file for the Mac port. |
| 72 enum RPHState { | 70 enum RPHState { |
| 73 RPH_ALLOW = 0, | 71 RPH_ALLOW = 0, |
| 74 RPH_BLOCK, | 72 RPH_BLOCK, |
| 75 RPH_IGNORE, | 73 RPH_IGNORE, |
| 76 }; | 74 }; |
| 77 | 75 |
| 78 struct ContentSettingsTypeIdEntry { | 76 struct ContentSettingsTypeIdEntry { |
| 79 ContentSettingsType type; | 77 ContentSettingsType type; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 99 return device; | 97 return device; |
| 100 } | 98 } |
| 101 | 99 |
| 102 // A device with the |device_id| was not found. It is likely that the device | 100 // A device with the |device_id| was not found. It is likely that the device |
| 103 // has been unplugged from the OS. Return the first device as the default | 101 // has been unplugged from the OS. Return the first device as the default |
| 104 // device. | 102 // device. |
| 105 return *devices.begin(); | 103 return *devices.begin(); |
| 106 } | 104 } |
| 107 | 105 |
| 108 } // namespace | 106 } // namespace |
| 109 | 107 |
|
Nico
2017/01/03 14:34:07
// static
| |
| 108 const int ContentSettingBubbleModel::kAllowButtonIndex = 0; | |
| 109 | |
| 110 // ContentSettingSimpleBubbleModel --------------------------------------------- | 110 // ContentSettingSimpleBubbleModel --------------------------------------------- |
| 111 | 111 |
| 112 ContentSettingSimpleBubbleModel::ContentSettingSimpleBubbleModel( | 112 ContentSettingSimpleBubbleModel::ContentSettingSimpleBubbleModel( |
| 113 Delegate* delegate, | 113 Delegate* delegate, |
| 114 WebContents* web_contents, | 114 WebContents* web_contents, |
| 115 Profile* profile, | 115 Profile* profile, |
| 116 ContentSettingsType content_type) | 116 ContentSettingsType content_type) |
| 117 : ContentSettingBubbleModel(delegate, web_contents, profile), | 117 : ContentSettingBubbleModel(delegate, web_contents, profile), |
| 118 content_type_(content_type) { | 118 content_type_(content_type) { |
| 119 // Notifications do not have a bubble. | 119 // Notifications do not have a bubble. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 } | 183 } |
| 184 | 184 |
| 185 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() { | 185 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() { |
| 186 if (delegate()) | 186 if (delegate()) |
| 187 delegate()->ShowContentSettingsPage(content_type()); | 187 delegate()->ShowContentSettingsPage(content_type()); |
| 188 | 188 |
| 189 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { | 189 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 190 content_settings::RecordPluginsAction( | 190 content_settings::RecordPluginsAction( |
| 191 content_settings::PLUGINS_ACTION_CLICKED_MANAGE_PLUGIN_BLOCKING); | 191 content_settings::PLUGINS_ACTION_CLICKED_MANAGE_PLUGIN_BLOCKING); |
| 192 } | 192 } |
| 193 | |
| 194 if (content_type() == CONTENT_SETTINGS_TYPE_POPUPS) { | |
| 195 content_settings::RecordPopupsAction( | |
| 196 content_settings::POPUPS_ACTION_CLICKED_MANAGE_POPUPS_BLOCKING); | |
| 197 } | |
| 193 } | 198 } |
| 194 | 199 |
| 195 void ContentSettingSimpleBubbleModel::SetCustomLink() { | 200 void ContentSettingSimpleBubbleModel::SetCustomLink() { |
| 196 static const ContentSettingsTypeIdEntry kCustomIDs[] = { | 201 static const ContentSettingsTypeIdEntry kCustomIDs[] = { |
| 197 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_INFO}, | 202 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_INFO}, |
| 198 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_ALLOW_INSECURE_CONTENT_BUTTON}, | 203 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_ALLOW_INSECURE_CONTENT_BUTTON}, |
| 199 }; | 204 }; |
| 200 int custom_link_id = | 205 int custom_link_id = |
| 201 GetIdForContentType(kCustomIDs, arraysize(kCustomIDs), content_type()); | 206 GetIdForContentType(kCustomIDs, arraysize(kCustomIDs), content_type()); |
| 202 if (custom_link_id) | 207 if (custom_link_id) |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 ->set_load_plugins_link_enabled(false); | 544 ->set_load_plugins_link_enabled(false); |
| 540 } | 545 } |
| 541 | 546 |
| 542 // ContentSettingPopupBubbleModel ---------------------------------------------- | 547 // ContentSettingPopupBubbleModel ---------------------------------------------- |
| 543 | 548 |
| 544 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { | 549 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { |
| 545 public: | 550 public: |
| 546 ContentSettingPopupBubbleModel(Delegate* delegate, | 551 ContentSettingPopupBubbleModel(Delegate* delegate, |
| 547 WebContents* web_contents, | 552 WebContents* web_contents, |
| 548 Profile* profile); | 553 Profile* profile); |
| 549 ~ContentSettingPopupBubbleModel() override {} | 554 ~ContentSettingPopupBubbleModel() override; |
| 550 | 555 |
| 551 private: | 556 private: |
| 552 void OnListItemClicked(int index) override; | 557 void OnListItemClicked(int index) override; |
| 553 | 558 |
| 554 int32_t item_id_from_item_index(int index) const { | 559 int32_t item_id_from_item_index(int index) const { |
| 555 return bubble_content().list_items[index].item_id; | 560 return bubble_content().list_items[index].item_id; |
| 556 } | 561 } |
| 557 | 562 |
| 558 DISALLOW_COPY_AND_ASSIGN(ContentSettingPopupBubbleModel); | 563 DISALLOW_COPY_AND_ASSIGN(ContentSettingPopupBubbleModel); |
| 559 }; | 564 }; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 575 for (const std::pair<int32_t, GURL>& blocked_popup : blocked_popups) { | 580 for (const std::pair<int32_t, GURL>& blocked_popup : blocked_popups) { |
| 576 std::string title(blocked_popup.second.spec()); | 581 std::string title(blocked_popup.second.spec()); |
| 577 // The pop-up may not have a valid URL. | 582 // The pop-up may not have a valid URL. |
| 578 if (title.empty()) | 583 if (title.empty()) |
| 579 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); | 584 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); |
| 580 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 585 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 581 IDR_DEFAULT_FAVICON), | 586 IDR_DEFAULT_FAVICON), |
| 582 title, true, blocked_popup.first); | 587 title, true, blocked_popup.first); |
| 583 add_list_item(popup_item); | 588 add_list_item(popup_item); |
| 584 } | 589 } |
| 590 content_settings::RecordPopupsAction( | |
| 591 content_settings::POPUPS_ACTION_DISPLAYED_BUBBLE); | |
| 585 } | 592 } |
| 586 | 593 |
| 587 void ContentSettingPopupBubbleModel::OnListItemClicked(int index) { | 594 void ContentSettingPopupBubbleModel::OnListItemClicked(int index) { |
| 588 if (web_contents()) { | 595 if (web_contents()) { |
| 589 auto* helper = PopupBlockerTabHelper::FromWebContents(web_contents()); | 596 auto* helper = PopupBlockerTabHelper::FromWebContents(web_contents()); |
| 590 helper->ShowBlockedPopup(item_id_from_item_index(index)); | 597 helper->ShowBlockedPopup(item_id_from_item_index(index)); |
| 598 | |
| 599 content_settings::RecordPopupsAction( | |
| 600 content_settings::POPUPS_ACTION_CLICKED_LIST_ITEM_CLICKED); | |
| 591 } | 601 } |
| 592 } | 602 } |
| 593 | 603 |
| 604 ContentSettingPopupBubbleModel::~ContentSettingPopupBubbleModel(){ | |
| 605 // User selected to always allow pop-ups from. | |
| 606 if (settings_changed() && selected_item() == kAllowButtonIndex) { | |
| 607 // Increases the counter. | |
| 608 content_settings::RecordPopupsAction( | |
| 609 content_settings::POPUPS_ACTION_SELECTED_ALWAYS_ALLOW_POPUPS_FROM); | |
| 610 } | |
| 611 } | |
| 612 | |
| 594 // ContentSettingMediaStreamBubbleModel ---------------------------------------- | 613 // ContentSettingMediaStreamBubbleModel ---------------------------------------- |
| 595 | 614 |
| 596 ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( | 615 ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel( |
| 597 Delegate* delegate, | 616 Delegate* delegate, |
| 598 WebContents* web_contents, | 617 WebContents* web_contents, |
| 599 Profile* profile) | 618 Profile* profile) |
| 600 : ContentSettingBubbleModel(delegate, web_contents, profile), | 619 : ContentSettingBubbleModel(delegate, web_contents, profile), |
| 601 selected_item_(0), | 620 selected_item_(0), |
| 602 state_(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) { | 621 state_(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED) { |
| 603 // TODO(msramek): The media bubble has three states - mic only, camera only, | 622 // TODO(msramek): The media bubble has three states - mic only, camera only, |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1437 ContentSettingMediaStreamBubbleModel* | 1456 ContentSettingMediaStreamBubbleModel* |
| 1438 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { | 1457 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { |
| 1439 // In general, bubble models might not inherit from the media bubble model. | 1458 // In general, bubble models might not inherit from the media bubble model. |
| 1440 return nullptr; | 1459 return nullptr; |
| 1441 } | 1460 } |
| 1442 | 1461 |
| 1443 ContentSettingSubresourceFilterBubbleModel* | 1462 ContentSettingSubresourceFilterBubbleModel* |
| 1444 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() { | 1463 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() { |
| 1445 return nullptr; | 1464 return nullptr; |
| 1446 } | 1465 } |
| OLD | NEW |