| OLD | NEW | 
|    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/content_setting_bubble_model.h" |    5 #include "chrome/browser/content_setting_bubble_model.h" | 
|    6  |    6  | 
|    7 #include "app/l10n_util.h" |    7 #include "app/l10n_util.h" | 
|    8 #include "base/command_line.h" |    8 #include "base/command_line.h" | 
|    9 #include "base/utf_string_conversions.h" |    9 #include "base/utf_string_conversions.h" | 
|   10 #include "chrome/browser/blocked_content_container.h" |   10 #include "chrome/browser/blocked_content_container.h" | 
|   11 #include "chrome/browser/content_settings/host_content_settings_map.h" |   11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 
|   12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |   12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 
|   13 #include "chrome/browser/metrics/user_metrics.h" |   13 #include "chrome/browser/metrics/user_metrics.h" | 
|   14 #include "chrome/browser/prefs/pref_service.h" |   14 #include "chrome/browser/prefs/pref_service.h" | 
|   15 #include "chrome/browser/profiles/profile.h" |   15 #include "chrome/browser/profiles/profile.h" | 
|   16 #include "chrome/browser/renderer_host/render_view_host.h" |   16 #include "chrome/browser/renderer_host/render_view_host.h" | 
|   17 #include "chrome/browser/tab_contents/tab_contents.h" |   17 #include "chrome/browser/tab_contents/tab_contents.h" | 
|   18 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |   18 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 
|   19 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" |   19 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" | 
|   20 #include "chrome/common/chrome_switches.h" |   20 #include "chrome/common/chrome_switches.h" | 
|   21 #include "chrome/common/notification_service.h" |   21 #include "chrome/common/notification_service.h" | 
|   22 #include "chrome/common/pref_names.h" |   22 #include "chrome/common/pref_names.h" | 
|   23 #include "grit/generated_resources.h" |   23 #include "grit/generated_resources.h" | 
|   24 #include "net/base/net_util.h" |   24 #include "net/base/net_util.h" | 
|   25  |   25  | 
|   26 class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { |   26 class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { | 
|   27  public: |   27  public: | 
|   28   ContentSettingTitleAndLinkModel(TabContents* tab_contents, Profile* profile, |   28   ContentSettingTitleAndLinkModel(TabContents* tab_contents, | 
|   29       ContentSettingsType content_type) |   29                                   Profile* profile, | 
 |   30                                   ContentSettingsType content_type) | 
|   30       : ContentSettingBubbleModel(tab_contents, profile, content_type) { |   31       : ContentSettingBubbleModel(tab_contents, profile, content_type) { | 
|   31      // Notifications do not have a bubble. |   32      // Notifications do not have a bubble. | 
|   32      DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |   33      DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 
|   33      SetBlockedResources(); |   34      SetBlockedResources(); | 
|   34      SetTitle(); |   35      SetTitle(); | 
|   35      SetManageLink(); |   36      SetManageLink(); | 
|   36   } |   37   } | 
|   37  |   38  | 
|   38  private: |   39  private: | 
|   39   void SetBlockedResources() { |   40   void SetBlockedResources() { | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  111                    Need_a_setting_for_every_content_settings_type); |  112                    Need_a_setting_for_every_content_settings_type); | 
|  112     set_manage_link(l10n_util::GetStringUTF8(kLinkIDs[content_type()])); |  113     set_manage_link(l10n_util::GetStringUTF8(kLinkIDs[content_type()])); | 
|  113   } |  114   } | 
|  114  |  115  | 
|  115   virtual void OnManageLinkClicked() { |  116   virtual void OnManageLinkClicked() { | 
|  116     if (tab_contents()) |  117     if (tab_contents()) | 
|  117       tab_contents()->delegate()->ShowContentSettingsWindow(content_type()); |  118       tab_contents()->delegate()->ShowContentSettingsWindow(content_type()); | 
|  118   } |  119   } | 
|  119 }; |  120 }; | 
|  120  |  121  | 
|  121 class ContentSettingTitleLinkAndInfoModel |  122 class ContentSettingTitleLinkAndCustomModel | 
|  122     : public ContentSettingTitleAndLinkModel { |  123     : public ContentSettingTitleAndLinkModel { | 
|  123  public: |  124  public: | 
|  124   ContentSettingTitleLinkAndInfoModel(TabContents* tab_contents, |  125   ContentSettingTitleLinkAndCustomModel(TabContents* tab_contents, | 
|  125                                       Profile* profile, |  126                                         Profile* profile, | 
|  126                                       ContentSettingsType content_type) |  127                                         ContentSettingsType content_type) | 
|  127       : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { |  128       : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { | 
|  128     SetInfoLink(); |  129     SetCustomLink(); | 
|  129   } |  130   } | 
|  130  |  131  | 
|  131  private: |  132  private: | 
|  132   void SetInfoLink() { |  133   void SetCustomLink() { | 
|  133     static const int kInfoIDs[] = { |  134     static const int kCustomIDs[] = { | 
|  134       IDS_BLOCKED_COOKIES_INFO, |  135       IDS_BLOCKED_COOKIES_INFO, | 
|  135       0,  // Images do not have an info link. |  136       0,  // Images do not have a custom link. | 
|  136       0,  // Javascript doesn't have an info link. |  137       0,  // Javascript doesn't have a custom link. | 
|  137       0,  // Plugins do not have an info link. |  138       IDS_BLOCKED_PLUGINS_LOAD_ALL, | 
|  138       0,  // Popups do not have an info link. |  139       0,  // Popups do not have a custom link. | 
|  139       0,  // Geolocation does not have an info link. |  140       0,  // Geolocation custom links are set within that class. | 
|  140       0,  // Notifications do not have a bubble. |  141       0,  // Notifications do not have a bubble. | 
|  141     }; |  142     }; | 
|  142     COMPILE_ASSERT(arraysize(kInfoIDs) == CONTENT_SETTINGS_NUM_TYPES, |  143     COMPILE_ASSERT(arraysize(kCustomIDs) == CONTENT_SETTINGS_NUM_TYPES, | 
|  143                    Need_a_setting_for_every_content_settings_type); |  144                    Need_a_setting_for_every_content_settings_type); | 
|  144     if (kInfoIDs[content_type()]) |  145     if (kCustomIDs[content_type()]) | 
|  145       set_info_link(l10n_util::GetStringUTF8(kInfoIDs[content_type()])); |  146       set_custom_link(l10n_util::GetStringUTF8(kCustomIDs[content_type()])); | 
|  146   } |  147   } | 
|  147  |  148  | 
|  148   virtual void OnInfoLinkClicked() { |  149   virtual void OnCustomLinkClicked() {} | 
|  149     DCHECK(content_type() == CONTENT_SETTINGS_TYPE_COOKIES); |  | 
|  150     if (tab_contents()) { |  | 
|  151       NotificationService::current()->Notify( |  | 
|  152           NotificationType::COLLECTED_COOKIES_SHOWN, |  | 
|  153           Source<TabSpecificContentSettings>( |  | 
|  154               tab_contents()->GetTabSpecificContentSettings()), |  | 
|  155           NotificationService::NoDetails()); |  | 
|  156       tab_contents()->delegate()->ShowCollectedCookiesDialog(tab_contents()); |  | 
|  157     } |  | 
|  158   } |  | 
|  159 }; |  150 }; | 
|  160  |  151  | 
|  161  |  152  | 
|  162 class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel { |  153 class ContentSettingSingleRadioGroup | 
 |  154     : public ContentSettingTitleLinkAndCustomModel { | 
|  163  public: |  155  public: | 
|  164   ContentSettingSingleRadioGroup(TabContents* tab_contents, Profile* profile, |  156   ContentSettingSingleRadioGroup(TabContents* tab_contents, | 
|  165       ContentSettingsType content_type) |  157                                  Profile* profile, | 
|  166       : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type), |  158                                  ContentSettingsType content_type) | 
 |  159       : ContentSettingTitleLinkAndCustomModel(tab_contents, profile, | 
 |  160                                               content_type), | 
|  167         block_setting_(CONTENT_SETTING_BLOCK) { |  161         block_setting_(CONTENT_SETTING_BLOCK) { | 
|  168     SetRadioGroup(); |  162     SetRadioGroup(); | 
|  169   } |  163   } | 
|  170  |  164  | 
|  171  private: |  165  private: | 
|  172   ContentSetting block_setting_; |  166   ContentSetting block_setting_; | 
|  173  |  167  | 
|  174   // Initialize the radio group by setting the appropriate labels for the |  168   // Initialize the radio group by setting the appropriate labels for the | 
|  175   // content type and setting the default value based on the content setting. |  169   // content type and setting the default value based on the content setting. | 
|  176   void SetRadioGroup() { |  170   void SetRadioGroup() { | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  279       AddException(setting, std::string()); |  273       AddException(setting, std::string()); | 
|  280     } else { |  274     } else { | 
|  281       for (std::set<std::string>::const_iterator it = resources.begin(); |  275       for (std::set<std::string>::const_iterator it = resources.begin(); | 
|  282            it != resources.end(); ++it) { |  276            it != resources.end(); ++it) { | 
|  283         AddException(setting, *it); |  277         AddException(setting, *it); | 
|  284       } |  278       } | 
|  285     } |  279     } | 
|  286   } |  280   } | 
|  287 }; |  281 }; | 
|  288  |  282  | 
 |  283 class ContentSettingCookiesBubbleModel | 
 |  284     : public ContentSettingTitleLinkAndCustomModel { | 
 |  285  public: | 
 |  286   ContentSettingCookiesBubbleModel(TabContents* tab_contents, | 
 |  287                                    Profile* profile, | 
 |  288                                    ContentSettingsType content_type) | 
 |  289       : ContentSettingTitleLinkAndCustomModel(tab_contents, profile, | 
 |  290                                               content_type) { | 
 |  291     DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type); | 
 |  292     set_custom_link_enabled(true); | 
 |  293   } | 
 |  294  | 
 |  295  private: | 
 |  296   virtual void OnCustomLinkClicked() OVERRIDE { | 
 |  297     if (tab_contents()) { | 
 |  298       NotificationService::current()->Notify( | 
 |  299           NotificationType::COLLECTED_COOKIES_SHOWN, | 
 |  300           Source<TabSpecificContentSettings>( | 
 |  301               tab_contents()->GetTabSpecificContentSettings()), | 
 |  302           NotificationService::NoDetails()); | 
 |  303       tab_contents()->delegate()->ShowCollectedCookiesDialog(tab_contents()); | 
 |  304     } | 
 |  305   } | 
 |  306 }; | 
 |  307  | 
|  289 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { |  308 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { | 
|  290  public: |  309  public: | 
|  291   ContentSettingPluginBubbleModel(TabContents* tab_contents, Profile* profile, |  310   ContentSettingPluginBubbleModel(TabContents* tab_contents, | 
 |  311                                   Profile* profile, | 
|  292                                   ContentSettingsType content_type) |  312                                   ContentSettingsType content_type) | 
|  293       : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { |  313       : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { | 
|  294     DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); |  314     DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); | 
|  295     SetLoadPluginsLinkTitle(); |  315     set_custom_link_enabled(tab_contents && tab_contents-> | 
 |  316         GetTabSpecificContentSettings()->load_plugins_link_enabled()); | 
|  296   } |  317   } | 
|  297  |  318  | 
|  298  private: |  319  private: | 
|  299   void SetLoadPluginsLinkTitle() { |  320   virtual void OnCustomLinkClicked() OVERRIDE { | 
|  300     set_load_plugins_link_title( |  | 
|  301         l10n_util::GetStringUTF8(IDS_BLOCKED_PLUGINS_LOAD_ALL)); |  | 
|  302    } |  | 
|  303  |  | 
|  304   virtual void OnLoadPluginsLinkClicked() { |  | 
|  305     UserMetrics::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble")); |  321     UserMetrics::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble")); | 
|  306     if (tab_contents()) { |  322     DCHECK(tab_contents()); | 
|  307       tab_contents()->render_view_host()->LoadBlockedPlugins(); |  323     tab_contents()->render_view_host()->LoadBlockedPlugins(); | 
|  308     } |  324     set_custom_link_enabled(false); | 
|  309     set_load_plugins_link_enabled(false); |  325     tab_contents()->GetTabSpecificContentSettings()-> | 
|  310     TabSpecificContentSettings* settings = |  326         set_load_plugins_link_enabled(false); | 
|  311         tab_contents()->GetTabSpecificContentSettings(); |  | 
|  312     settings->set_load_plugins_link_enabled(false); |  | 
|  313   } |  327   } | 
|  314 }; |  328 }; | 
|  315  |  329  | 
|  316 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { |  330 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { | 
|  317  public: |  331  public: | 
|  318   ContentSettingPopupBubbleModel(TabContents* tab_contents, Profile* profile, |  332   ContentSettingPopupBubbleModel(TabContents* tab_contents, | 
|  319       ContentSettingsType content_type) |  333                                  Profile* profile, | 
 |  334                                  ContentSettingsType content_type) | 
|  320       : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { |  335       : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { | 
|  321     SetPopups(); |  336     SetPopups(); | 
|  322   } |  337   } | 
|  323  |  338  | 
|  324  private: |  339  private: | 
|  325   void SetPopups() { |  340   void SetPopups() { | 
|  326     // check for crbug.com/53176 |  341     // check for crbug.com/53176 | 
|  327     if (!tab_contents()->blocked_content_container()) |  342     if (!tab_contents()->blocked_content_container()) | 
|  328       return; |  343       return; | 
|  329     std::vector<TabContents*> blocked_contents; |  344     std::vector<TabContents*> blocked_contents; | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|  354  |  369  | 
|  355 class ContentSettingDomainListBubbleModel |  370 class ContentSettingDomainListBubbleModel | 
|  356     : public ContentSettingTitleAndLinkModel { |  371     : public ContentSettingTitleAndLinkModel { | 
|  357  public: |  372  public: | 
|  358   ContentSettingDomainListBubbleModel(TabContents* tab_contents, |  373   ContentSettingDomainListBubbleModel(TabContents* tab_contents, | 
|  359                                       Profile* profile, |  374                                       Profile* profile, | 
|  360                                       ContentSettingsType content_type) |  375                                       ContentSettingsType content_type) | 
|  361       : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { |  376       : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { | 
|  362     DCHECK_EQ(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) << |  377     DCHECK_EQ(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) << | 
|  363         "SetDomains currently only supports geolocation content type"; |  378         "SetDomains currently only supports geolocation content type"; | 
|  364     SetDomainsAndClearLink(); |  379     SetDomainsAndCustomLink(); | 
|  365   } |  380   } | 
|  366  |  381  | 
|  367  private: |  382  private: | 
|  368   void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id) { |  383   void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id) { | 
|  369     if (!hosts.empty()) { |  384     if (!hosts.empty()) { | 
|  370       DomainList domain_list; |  385       DomainList domain_list; | 
|  371       domain_list.title = l10n_util::GetStringUTF8(title_id); |  386       domain_list.title = l10n_util::GetStringUTF8(title_id); | 
|  372       domain_list.hosts = hosts; |  387       domain_list.hosts = hosts; | 
|  373       add_domain_list(domain_list); |  388       add_domain_list(domain_list); | 
|  374     } |  389     } | 
|  375   } |  390   } | 
|  376   void SetDomainsAndClearLink() { |  391   void SetDomainsAndCustomLink() { | 
|  377     TabSpecificContentSettings* content_settings = |  392     TabSpecificContentSettings* content_settings = | 
|  378         tab_contents()->GetTabSpecificContentSettings(); |  393         tab_contents()->GetTabSpecificContentSettings(); | 
|  379     const GeolocationSettingsState& settings = |  394     const GeolocationSettingsState& settings = | 
|  380         content_settings->geolocation_settings_state(); |  395         content_settings->geolocation_settings_state(); | 
|  381     GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; |  396     GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; | 
|  382     unsigned int tab_state_flags = 0; |  397     unsigned int tab_state_flags = 0; | 
|  383     settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); |  398     settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags); | 
|  384     // Divide the tab's current geolocation users into sets according to their |  399     // Divide the tab's current geolocation users into sets according to their | 
|  385     // permission state. |  400     // permission state. | 
|  386     MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], |  401     MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_ALLOW], | 
|  387                        IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); |  402                        IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED); | 
|  388  |  403  | 
|  389     MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], |  404     MaybeAddDomainList(formatted_hosts_per_state[CONTENT_SETTING_BLOCK], | 
|  390                        IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); |  405                        IDS_GEOLOCATION_BUBBLE_SECTION_DENIED); | 
|  391  |  406  | 
|  392     if (tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_EXCEPTION) { |  407     if (tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_EXCEPTION) { | 
|  393       set_clear_link( |  408       set_custom_link(l10n_util::GetStringUTF8( | 
|  394           l10n_util::GetStringUTF8(IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); |  409                       IDS_GEOLOCATION_BUBBLE_CLEAR_LINK)); | 
 |  410       set_custom_link_enabled(true); | 
|  395     } else if (tab_state_flags & |  411     } else if (tab_state_flags & | 
|  396                GeolocationSettingsState::TABSTATE_HAS_CHANGED) { |  412                GeolocationSettingsState::TABSTATE_HAS_CHANGED) { | 
|  397       // It is a slight abuse of the domain list field to use it for the reload |  413       set_custom_link(l10n_util::GetStringUTF8( | 
|  398       // hint, but works fine for now. TODO(joth): If we need to style it |  414                       IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR)); | 
|  399       // differently, consider adding an explicit field, or generalize the |  | 
|  400       // domain list to be a flat list of style formatted lines. |  | 
|  401       DomainList reload_section; |  | 
|  402       reload_section.title = l10n_util::GetStringUTF8( |  | 
|  403           IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR); |  | 
|  404       add_domain_list(reload_section); |  | 
|  405     } |  415     } | 
|  406   } |  416   } | 
|  407   virtual void OnClearLinkClicked() { |  417   virtual void OnCustomLinkClicked() OVERRIDE { | 
|  408     if (!tab_contents()) |  418     if (!tab_contents()) | 
|  409       return; |  419       return; | 
|  410     // Reset this embedder's entry to default for each of the requesting |  420     // Reset this embedder's entry to default for each of the requesting | 
|  411     // origins currently on the page. |  421     // origins currently on the page. | 
|  412     const GURL& embedder_url = tab_contents()->GetURL(); |  422     const GURL& embedder_url = tab_contents()->GetURL(); | 
|  413     TabSpecificContentSettings* content_settings = |  423     TabSpecificContentSettings* content_settings = | 
|  414         tab_contents()->GetTabSpecificContentSettings(); |  424         tab_contents()->GetTabSpecificContentSettings(); | 
|  415     const GeolocationSettingsState::StateMap& state_map = |  425     const GeolocationSettingsState::StateMap& state_map = | 
|  416         content_settings->geolocation_settings_state().state_map(); |  426         content_settings->geolocation_settings_state().state_map(); | 
|  417     GeolocationContentSettingsMap* settings_map = |  427     GeolocationContentSettingsMap* settings_map = | 
|  418         profile()->GetGeolocationContentSettingsMap(); |  428         profile()->GetGeolocationContentSettingsMap(); | 
|  419     for (GeolocationSettingsState::StateMap::const_iterator it = |  429     for (GeolocationSettingsState::StateMap::const_iterator it = | 
|  420          state_map.begin(); it != state_map.end(); ++it) { |  430          state_map.begin(); it != state_map.end(); ++it) { | 
|  421       settings_map->SetContentSetting(it->first, embedder_url, |  431       settings_map->SetContentSetting(it->first, embedder_url, | 
|  422                                       CONTENT_SETTING_DEFAULT); |  432                                       CONTENT_SETTING_DEFAULT); | 
|  423     } |  433     } | 
|  424   } |  434   } | 
|  425 }; |  435 }; | 
|  426  |  436  | 
|  427 // static |  437 // static | 
|  428 ContentSettingBubbleModel* |  438 ContentSettingBubbleModel* | 
|  429     ContentSettingBubbleModel::CreateContentSettingBubbleModel( |  439     ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 
|  430         TabContents* tab_contents, |  440         TabContents* tab_contents, | 
|  431         Profile* profile, |  441         Profile* profile, | 
|  432         ContentSettingsType content_type) { |  442         ContentSettingsType content_type) { | 
|  433   if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |  443   if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 
|  434     return new ContentSettingTitleLinkAndInfoModel(tab_contents, profile, |  444     return new ContentSettingCookiesBubbleModel(tab_contents, profile, | 
|  435                                                    content_type); |  445                                                 content_type); | 
|  436   } |  446   } | 
|  437   if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { |  447   if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { | 
|  438     return new ContentSettingPopupBubbleModel(tab_contents, profile, |  448     return new ContentSettingPopupBubbleModel(tab_contents, profile, | 
|  439                                               content_type); |  449                                               content_type); | 
|  440   } |  450   } | 
|  441   if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |  451   if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 
|  442     return new ContentSettingDomainListBubbleModel(tab_contents, profile, |  452     return new ContentSettingDomainListBubbleModel(tab_contents, profile, | 
|  443                                                    content_type); |  453                                                    content_type); | 
|  444   } |  454   } | 
|  445   if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { |  455   if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 
|  446     return new ContentSettingPluginBubbleModel(tab_contents, profile, |  456     return new ContentSettingPluginBubbleModel(tab_contents, profile, | 
|  447                                                content_type); |  457                                                content_type); | 
|  448   } |  458   } | 
|  449   return new ContentSettingSingleRadioGroup(tab_contents, profile, |  459   return new ContentSettingSingleRadioGroup(tab_contents, profile, | 
|  450                                             content_type); |  460                                             content_type); | 
|  451 } |  461 } | 
|  452  |  462  | 
|  453 ContentSettingBubbleModel::ContentSettingBubbleModel( |  463 ContentSettingBubbleModel::ContentSettingBubbleModel( | 
|  454     TabContents* tab_contents, Profile* profile, |  464     TabContents* tab_contents, | 
 |  465     Profile* profile, | 
|  455     ContentSettingsType content_type) |  466     ContentSettingsType content_type) | 
|  456     : tab_contents_(tab_contents), profile_(profile), |  467     : tab_contents_(tab_contents), | 
 |  468       profile_(profile), | 
|  457       content_type_(content_type) { |  469       content_type_(content_type) { | 
|  458   if (tab_contents) { |  | 
|  459     TabSpecificContentSettings* settings = |  | 
|  460         tab_contents->GetTabSpecificContentSettings(); |  | 
|  461     set_load_plugins_link_enabled(settings->load_plugins_link_enabled()); |  | 
|  462   } else { |  | 
|  463     set_load_plugins_link_enabled(true); |  | 
|  464   } |  | 
|  465   registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, |  470   registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, | 
|  466                  Source<TabContents>(tab_contents)); |  471                  Source<TabContents>(tab_contents)); | 
|  467 } |  472 } | 
|  468  |  473  | 
|  469 ContentSettingBubbleModel::~ContentSettingBubbleModel() { |  474 ContentSettingBubbleModel::~ContentSettingBubbleModel() { | 
|  470 } |  475 } | 
|  471  |  476  | 
|  472 ContentSettingBubbleModel::RadioGroup::RadioGroup() : default_item(0) {} |  477 ContentSettingBubbleModel::RadioGroup::RadioGroup() : default_item(0) {} | 
|  473  |  478  | 
|  474 ContentSettingBubbleModel::RadioGroup::~RadioGroup() {} |  479 ContentSettingBubbleModel::RadioGroup::~RadioGroup() {} | 
|  475  |  480  | 
|  476 ContentSettingBubbleModel::DomainList::DomainList() {} |  481 ContentSettingBubbleModel::DomainList::DomainList() {} | 
|  477  |  482  | 
|  478 ContentSettingBubbleModel::DomainList::~DomainList() {} |  483 ContentSettingBubbleModel::DomainList::~DomainList() {} | 
|  479  |  484  | 
|  480 ContentSettingBubbleModel::BubbleContent::BubbleContent() |  485 ContentSettingBubbleModel::BubbleContent::BubbleContent() | 
|  481     : load_plugins_link_enabled(false) { |  486     : custom_link_enabled(false) { | 
|  482 } |  487 } | 
|  483  |  488  | 
|  484 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {} |  489 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {} | 
|  485  |  490  | 
|  486  |  491  | 
|  487 void ContentSettingBubbleModel::AddBlockedResource( |  492 void ContentSettingBubbleModel::AddBlockedResource( | 
|  488     const std::string& resource_identifier) { |  493     const std::string& resource_identifier) { | 
|  489   bubble_content_.resource_identifiers.insert(resource_identifier); |  494   bubble_content_.resource_identifiers.insert(resource_identifier); | 
|  490 } |  495 } | 
|  491  |  496  | 
|  492 void ContentSettingBubbleModel::Observe(NotificationType type, |  497 void ContentSettingBubbleModel::Observe(NotificationType type, | 
|  493                                         const NotificationSource& source, |  498                                         const NotificationSource& source, | 
|  494                                         const NotificationDetails& details) { |  499                                         const NotificationDetails& details) { | 
|  495   DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |  500   DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 
|  496   DCHECK(source == Source<TabContents>(tab_contents_)); |  501   DCHECK(source == Source<TabContents>(tab_contents_)); | 
|  497   tab_contents_ = NULL; |  502   tab_contents_ = NULL; | 
|  498 } |  503 } | 
| OLD | NEW |