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