| 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/media_gallery/media_galleries_dialog_controller.h" | 5 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" | 9 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" |
| 10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 10 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/browser/web_contents_view.h" | 15 #include "content/public/browser/web_contents_view.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 | 18 |
| 19 using extensions::Extension; | 19 using extensions::Extension; |
| 20 | 20 |
| 21 namespace chrome { | 21 namespace chrome { |
| 22 | 22 |
| 23 MediaGalleriesDialogController::MediaGalleriesDialogController( | 23 MediaGalleriesDialogController::MediaGalleriesDialogController( |
| 24 TabContents* tab_contents, | 24 content::WebContents* web_contents, |
| 25 const Extension& extension, | 25 const Extension& extension, |
| 26 const base::Closure& on_finish) | 26 const base::Closure& on_finish) |
| 27 : tab_contents_(tab_contents), | 27 : web_contents_(web_contents), |
| 28 extension_(&extension), | 28 extension_(&extension), |
| 29 on_finish_(on_finish), | 29 on_finish_(on_finish), |
| 30 preferences_(MediaGalleriesPreferencesFactory::GetForProfile( | 30 preferences_(MediaGalleriesPreferencesFactory::GetForProfile( |
| 31 tab_contents_->profile())) { | 31 Profile::FromBrowserContext(web_contents->GetBrowserContext()))) { |
| 32 LookUpPermissions(); | 32 LookUpPermissions(); |
| 33 | 33 |
| 34 dialog_.reset(MediaGalleriesDialog::Create(this)); | 34 dialog_.reset(MediaGalleriesDialog::Create(this)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 MediaGalleriesDialogController::MediaGalleriesDialogController() | 37 MediaGalleriesDialogController::MediaGalleriesDialogController() |
| 38 : tab_contents_(NULL), | 38 : web_contents_(NULL), |
| 39 extension_(NULL), | 39 extension_(NULL), |
| 40 preferences_(NULL) {} | 40 preferences_(NULL) {} |
| 41 | 41 |
| 42 MediaGalleriesDialogController::~MediaGalleriesDialogController() { | 42 MediaGalleriesDialogController::~MediaGalleriesDialogController() { |
| 43 if (select_folder_dialog_.get()) | 43 if (select_folder_dialog_.get()) |
| 44 select_folder_dialog_->ListenerDestroyed(); | 44 select_folder_dialog_->ListenerDestroyed(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 string16 MediaGalleriesDialogController::GetHeader() const { | 47 string16 MediaGalleriesDialogController::GetHeader() const { |
| 48 std::string extension_name(extension_ ? extension_->name() : ""); | 48 std::string extension_name(extension_ ? extension_->name() : ""); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 void MediaGalleriesDialogController::OnAddFolderClicked() { | 68 void MediaGalleriesDialogController::OnAddFolderClicked() { |
| 69 FilePath user_data_dir; | 69 FilePath user_data_dir; |
| 70 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 70 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 71 select_folder_dialog_ = | 71 select_folder_dialog_ = |
| 72 ui::SelectFileDialog::Create(this, new ChromeSelectFilePolicy(NULL)); | 72 ui::SelectFileDialog::Create(this, new ChromeSelectFilePolicy(NULL)); |
| 73 select_folder_dialog_->SelectFile( | 73 select_folder_dialog_->SelectFile( |
| 74 ui::SelectFileDialog::SELECT_FOLDER, | 74 ui::SelectFileDialog::SELECT_FOLDER, |
| 75 l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_DIALOG_ADD_GALLERY_TITLE), | 75 l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_DIALOG_ADD_GALLERY_TITLE), |
| 76 user_data_dir, | 76 user_data_dir, |
| 77 NULL, 0, FILE_PATH_LITERAL(""), | 77 NULL, 0, FILE_PATH_LITERAL(""), |
| 78 tab_contents_->web_contents()->GetView()->GetTopLevelNativeWindow(), | 78 web_contents_->GetView()->GetTopLevelNativeWindow(), |
| 79 NULL); | 79 NULL); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void MediaGalleriesDialogController::DidToggleGallery( | 82 void MediaGalleriesDialogController::DidToggleGallery( |
| 83 const MediaGalleryPrefInfo* gallery, | 83 const MediaGalleryPrefInfo* gallery, |
| 84 bool enabled) { | 84 bool enabled) { |
| 85 // Check known galleries. | 85 // Check known galleries. |
| 86 KnownGalleryPermissions::iterator iter = | 86 KnownGalleryPermissions::iterator iter = |
| 87 known_galleries_.find(gallery->pref_id); | 87 known_galleries_.find(gallery->pref_id); |
| 88 if (iter != known_galleries_.end()) { | 88 if (iter != known_galleries_.end()) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 preferences_->SetGalleryPermissionForExtension( | 191 preferences_->SetGalleryPermissionForExtension( |
| 192 *extension_, id, true); | 192 *extension_, id, true); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 // MediaGalleries dialog ------------------------------------------------------- | 196 // MediaGalleries dialog ------------------------------------------------------- |
| 197 | 197 |
| 198 MediaGalleriesDialog::~MediaGalleriesDialog() {} | 198 MediaGalleriesDialog::~MediaGalleriesDialog() {} |
| 199 | 199 |
| 200 } // namespace chrome | 200 } // namespace chrome |
| OLD | NEW |