OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/bookmark_all_tabs_dialog.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "chrome/browser/ui/browser.h" | |
11 #include "chrome/browser/ui/browser_list.h" | |
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
13 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | |
14 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" | |
15 #include "grit/generated_resources.h" | |
16 #include "ui/base/l10n/l10n_util.h" | |
17 | |
18 const char* kBookmarkAllTabsURL = | |
19 "chrome-extension://" | |
20 "eemcgdkfndhakfknompkggombfjjjeno/" | |
21 "bookmark_all_tabs.html"; | |
22 | |
23 const int kDialogWidth = 640; | |
24 const int kDialogHeight = 480; | |
25 | |
26 // **************************************************** | |
27 // BookmarkAllTabsDialogBuilder class | |
28 | |
29 class BookmarkAllTabsDialogBuilder : public ExtensionDialogObserver { | |
30 public: | |
31 explicit BookmarkAllTabsDialogBuilder(Profile* profile); | |
32 | |
33 // ExtensionDialog::Observer implementation. | |
34 virtual void ExtensionDialogIsClosing(ExtensionDialog* dialog); | |
35 | |
36 void Show(); | |
37 | |
38 private: | |
39 Profile* profile_; | |
40 | |
41 // Host for the extension that implements this dialog. | |
42 scoped_refptr<ExtensionDialog> extension_dialog_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(BookmarkAllTabsDialogBuilder); | |
45 }; | |
46 | |
47 BookmarkAllTabsDialogBuilder::BookmarkAllTabsDialogBuilder(Profile* profile) { | |
mazda
2011/11/09 04:49:43
BookmarkAllTabsDialogBuilder::BookmarkAllTabsDialo
yoshiki
2011/11/09 15:06:39
Done.
| |
48 profile_ = profile; | |
49 } | |
50 | |
51 void BookmarkAllTabsDialogBuilder::ExtensionDialogIsClosing( | |
52 ExtensionDialog* dialog) { | |
53 extension_dialog_ = NULL; | |
54 } | |
55 | |
56 void BookmarkAllTabsDialogBuilder::Show() { | |
57 // Extension background pages may not supply an owner_window. | |
58 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | |
59 if (!browser) { | |
60 NOTREACHED() << "Can't find owning browser"; | |
mazda
2011/11/09 04:49:43
LOG(ERROR) is more appropriate?
yoshiki
2011/11/09 15:06:39
Done.
| |
61 return; | |
62 } | |
63 GURL url(kBookmarkAllTabsURL); | |
64 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); | |
65 | |
66 std::string title = | |
67 l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_BOOKMARK_ALL_TABS); | |
68 | |
69 ExtensionDialog* dialog = ExtensionDialog::Show( | |
70 url, | |
71 browser, tab->tab_contents(), | |
72 kDialogWidth, kDialogHeight, | |
73 title, | |
74 this ); | |
75 if (!dialog) { | |
76 LOG(ERROR) << "Unable to create extension dialog"; | |
77 return; | |
78 } | |
79 extension_dialog_ = dialog; | |
80 } | |
81 | |
82 // **************************************************** | |
83 // BookmarkAllTabsDialog class | |
84 | |
85 // static | |
86 void BookmarkAllTabsDialog::Show(Profile* profile) { | |
87 BookmarkAllTabsDialogBuilder *dialog | |
88 = new BookmarkAllTabsDialogBuilder(profile); | |
mazda
2011/11/09 04:49:43
Is this deleted?
yoshiki
2011/11/09 15:06:39
Done.
| |
89 dialog->Show(); | |
90 } | |
91 | |
OLD | NEW |