| 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/views/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 16 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 17 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
| 18 #include "chrome/browser/plugins/plugin_metadata.h" | 18 #include "chrome/browser/plugins/plugin_metadata.h" |
| 19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 20 #include "chrome/browser/ui/layout_constants.h" | 20 #include "chrome/browser/ui/layout_constants.h" |
| 21 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 21 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
| 22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/content_settings/core/browser/host_content_settings_map.h" | 23 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 24 #include "components/strings/grit/components_strings.h" | 24 #include "components/strings/grit/components_strings.h" |
| 25 #include "content/public/browser/navigation_handle.h" |
| 25 #include "content/public/browser/plugin_service.h" | 26 #include "content/public/browser/plugin_service.h" |
| 26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 27 #include "ui/base/cursor/cursor.h" | 28 #include "ui/base/cursor/cursor.h" |
| 28 #include "ui/base/default_style.h" | 29 #include "ui/base/default_style.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/models/simple_menu_model.h" | 31 #include "ui/base/models/simple_menu_model.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/font_list.h" | 33 #include "ui/gfx/font_list.h" |
| 33 #include "ui/gfx/text_utils.h" | 34 #include "ui/gfx/text_utils.h" |
| 34 #include "ui/views/controls/button/label_button_border.h" | 35 #include "ui/views/controls/button/label_button_border.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 456 |
| 456 int ContentSettingBubbleContents::GetDialogButtons() const { | 457 int ContentSettingBubbleContents::GetDialogButtons() const { |
| 457 return ui::DIALOG_BUTTON_OK; | 458 return ui::DIALOG_BUTTON_OK; |
| 458 } | 459 } |
| 459 | 460 |
| 460 base::string16 ContentSettingBubbleContents::GetDialogButtonLabel( | 461 base::string16 ContentSettingBubbleContents::GetDialogButtonLabel( |
| 461 ui::DialogButton button) const { | 462 ui::DialogButton button) const { |
| 462 return l10n_util::GetStringUTF16(IDS_DONE); | 463 return l10n_util::GetStringUTF16(IDS_DONE); |
| 463 } | 464 } |
| 464 | 465 |
| 465 void ContentSettingBubbleContents::DidNavigateMainFrame( | 466 void ContentSettingBubbleContents::DidFinishNavigation( |
| 466 const content::LoadCommittedDetails& details, | 467 content::NavigationHandle* navigation_handle) { |
| 467 const content::FrameNavigateParams& params) { | 468 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 469 return; |
| 470 |
| 468 // Content settings are based on the main frame, so if it switches then | 471 // Content settings are based on the main frame, so if it switches then |
| 469 // close up shop. | 472 // close up shop. |
| 470 GetWidget()->Close(); | 473 GetWidget()->Close(); |
| 471 } | 474 } |
| 472 | 475 |
| 473 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, | 476 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, |
| 474 const ui::Event& event) { | 477 const ui::Event& event) { |
| 475 if (manage_button_ == sender) { | 478 if (manage_button_ == sender) { |
| 476 GetWidget()->Close(); | 479 GetWidget()->Close(); |
| 477 content_setting_bubble_model_->OnManageLinkClicked(); | 480 content_setting_bubble_model_->OnManageLinkClicked(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 507 DCHECK(i != list_item_links_.end()); | 510 DCHECK(i != list_item_links_.end()); |
| 508 content_setting_bubble_model_->OnListItemClicked(i->second); | 511 content_setting_bubble_model_->OnListItemClicked(i->second); |
| 509 } | 512 } |
| 510 | 513 |
| 511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 514 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
| 512 MediaComboboxModel* model = | 515 MediaComboboxModel* model = |
| 513 static_cast<MediaComboboxModel*>(combobox->model()); | 516 static_cast<MediaComboboxModel*>(combobox->model()); |
| 514 content_setting_bubble_model_->OnMediaMenuClicked( | 517 content_setting_bubble_model_->OnMediaMenuClicked( |
| 515 model->type(), model->GetDevices()[combobox->selected_index()].id); | 518 model->type(), model->GetDevices()[combobox->selected_index()].id); |
| 516 } | 519 } |
| OLD | NEW |