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 "base/memory/scoped_ptr.h" | |
8 #include "chrome/browser/ui/browser.h" | |
9 #include "chrome/browser/ui/browser_list.h" | |
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
11 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | |
12 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" | |
13 #include "grit/generated_resources.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 | |
16 const char* kBookmarkAllTabsURL = | |
tfarina
2011/11/14 17:33:05
nit: const char kBookmarkAllTabsURL[]
yoshiki
2011/11/17 04:09:38
Done.
| |
17 "chrome-extension://" | |
18 "eemcgdkfndhakfknompkggombfjjjeno/" | |
tfarina
2011/11/14 17:33:05
can you save one line and fold this into the above
yoshiki
2011/11/17 04:09:38
Done.
| |
19 "bookmark_all_tabs.html"; | |
20 | |
21 const int kDialogWidth = 640; | |
22 const int kDialogHeight = 480; | |
23 | |
24 // **************************************************** | |
25 // BookmarkAllTabsDialogBuilder class | |
26 | |
27 class BookmarkAllTabsDialogBuilder : public ExtensionDialogObserver { | |
28 public: | |
29 explicit BookmarkAllTabsDialogBuilder(Profile* profile); | |
30 virtual ~BookmarkAllTabsDialogBuilder(); | |
31 | |
32 // ExtensionDialog::Observer implementation. | |
33 virtual void ExtensionDialogIsClosing(ExtensionDialog* dialog); | |
tfarina
2011/11/14 17:33:05
Add OVERRIDE and compiler_specific.h
yoshiki
2011/11/17 04:09:38
Done.
| |
34 | |
35 void Show(); | |
36 | |
37 private: | |
38 Profile* profile_; | |
39 | |
40 // Host for the extension that implements this dialog. | |
41 scoped_refptr<ExtensionDialog> extension_dialog_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(BookmarkAllTabsDialogBuilder); | |
44 }; | |
45 | |
46 BookmarkAllTabsDialogBuilder::BookmarkAllTabsDialogBuilder(Profile* profile) | |
47 : profile_(profile) { | |
48 } | |
49 | |
50 BookmarkAllTabsDialogBuilder::~BookmarkAllTabsDialogBuilder() { | |
51 if (extension_dialog_) | |
52 extension_dialog_->ObserverDestroyed(); | |
53 } | |
54 | |
55 void BookmarkAllTabsDialogBuilder::ExtensionDialogIsClosing( | |
56 ExtensionDialog* dialog) { | |
57 extension_dialog_ = NULL; | |
58 delete this; | |
59 } | |
60 | |
61 void BookmarkAllTabsDialogBuilder::Show() { | |
62 // Extension background pages may not supply an owner_window. | |
63 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | |
64 if (!browser) { | |
65 LOG(ERROR) << "Can't find owning browser"; | |
66 return; | |
67 } | |
68 GURL url(kBookmarkAllTabsURL); | |
69 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); | |
70 | |
71 string16 title = | |
72 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_BOOKMARK_ALL_TABS); | |
73 | |
74 ExtensionDialog* dialog = ExtensionDialog::Show( | |
75 url, | |
76 browser, tab->tab_contents(), | |
77 kDialogWidth, kDialogHeight, | |
78 title, | |
79 this ); | |
80 if (!dialog) { | |
81 LOG(ERROR) << "Unable to create extension dialog"; | |
82 return; | |
83 } | |
84 extension_dialog_ = dialog; | |
85 } | |
86 | |
87 // **************************************************** | |
tfarina
2011/11/14 17:33:05
weird :(
| |
88 // BookmarkAllTabsDialog class | |
89 | |
90 // static | |
91 void BookmarkAllTabsDialog::Show(Profile* profile) { | |
92 BookmarkAllTabsDialogBuilder *dialog | |
93 = new BookmarkAllTabsDialogBuilder(profile); | |
94 dialog->Show(); | |
95 } | |
96 | |
tfarina
2011/11/14 17:33:05
remove this blank line.
| |
OLD | NEW |