Index: chrome/browser/ui/webui/bookmark_all_tabs_dialog.cc |
diff --git a/chrome/browser/ui/webui/bookmark_all_tabs_dialog.cc b/chrome/browser/ui/webui/bookmark_all_tabs_dialog.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7f5176e6f4dff3d4c26ac4b840ae24afe4cc5176 |
--- /dev/null |
+++ b/chrome/browser/ui/webui/bookmark_all_tabs_dialog.cc |
@@ -0,0 +1,91 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/webui/bookmark_all_tabs_dialog.h" |
+ |
+#include <string> |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
+#include "chrome/browser/ui/views/extensions/extension_dialog.h" |
+#include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" |
+#include "grit/generated_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
+ |
+const char* kBookmarkAllTabsURL = |
+ "chrome-extension://" |
+ "eemcgdkfndhakfknompkggombfjjjeno/" |
+ "bookmark_all_tabs.html"; |
+ |
+const int kDialogWidth = 640; |
+const int kDialogHeight = 480; |
+ |
+// **************************************************** |
+// BookmarkAllTabsDialogBuilder class |
+ |
+class BookmarkAllTabsDialogBuilder : public ExtensionDialogObserver { |
+ public: |
+ explicit BookmarkAllTabsDialogBuilder(Profile* profile); |
+ |
+ // ExtensionDialog::Observer implementation. |
+ virtual void ExtensionDialogIsClosing(ExtensionDialog* dialog); |
+ |
+ void Show(); |
+ |
+ private: |
+ Profile* profile_; |
+ |
+ // Host for the extension that implements this dialog. |
+ scoped_refptr<ExtensionDialog> extension_dialog_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BookmarkAllTabsDialogBuilder); |
+}; |
+ |
+BookmarkAllTabsDialogBuilder::BookmarkAllTabsDialogBuilder(Profile* profile) { |
mazda
2011/11/09 04:49:43
BookmarkAllTabsDialogBuilder::BookmarkAllTabsDialo
yoshiki
2011/11/09 15:06:39
Done.
|
+ profile_ = profile; |
+} |
+ |
+void BookmarkAllTabsDialogBuilder::ExtensionDialogIsClosing( |
+ ExtensionDialog* dialog) { |
+ extension_dialog_ = NULL; |
+} |
+ |
+void BookmarkAllTabsDialogBuilder::Show() { |
+ // Extension background pages may not supply an owner_window. |
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
+ if (!browser) { |
+ 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.
|
+ return; |
+ } |
+ GURL url(kBookmarkAllTabsURL); |
+ TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); |
+ |
+ std::string title = |
+ l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_BOOKMARK_ALL_TABS); |
+ |
+ ExtensionDialog* dialog = ExtensionDialog::Show( |
+ url, |
+ browser, tab->tab_contents(), |
+ kDialogWidth, kDialogHeight, |
+ title, |
+ this ); |
+ if (!dialog) { |
+ LOG(ERROR) << "Unable to create extension dialog"; |
+ return; |
+ } |
+ extension_dialog_ = dialog; |
+} |
+ |
+// **************************************************** |
+// BookmarkAllTabsDialog class |
+ |
+// static |
+void BookmarkAllTabsDialog::Show(Profile* profile) { |
+ BookmarkAllTabsDialogBuilder *dialog |
+ = new BookmarkAllTabsDialogBuilder(profile); |
mazda
2011/11/09 04:49:43
Is this deleted?
yoshiki
2011/11/09 15:06:39
Done.
|
+ dialog->Show(); |
+} |
+ |