Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/webui/constrained_web_dialog_delegate_base.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/property_bag.h" 9 #include "base/property_bag.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/constrained_window.h" 11 #include "chrome/browser/ui/constrained_window.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/browser/ui/webui/web_dialog_delegate.h"
14 #include "chrome/browser/ui/webui/web_dialog_ui.h"
15 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h"
16 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "ui/web_dialogs/web_dialog_delegate.h"
15 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
16 #include "ui/web_dialogs/web_dialog_ui.h"
17 17
18 using content::WebContents; 18 using content::WebContents;
19 19
20 ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( 20 ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase(
21 Profile* profile, 21 Profile* profile,
22 WebDialogDelegate* delegate, 22 web_dialogs::WebDialogDelegate* delegate,
23 WebDialogWebContentsDelegate* tab_delegate) 23 web_dialogs::WebDialogWebContentsDelegate* tab_delegate)
24 : WebDialogWebContentsDelegate(profile), 24 : ChromeWebDialogWebContentsDelegate(profile),
25 web_dialog_delegate_(delegate), 25 web_dialog_delegate_(delegate),
26 window_(NULL), 26 window_(NULL),
27 closed_via_webui_(false), 27 closed_via_webui_(false),
28 release_tab_on_close_(false) { 28 release_tab_on_close_(false) {
29 CHECK(delegate); 29 CHECK(delegate);
30 WebContents* web_contents = 30 WebContents* web_contents =
31 WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); 31 WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL, NULL);
32 tab_.reset(new TabContentsWrapper(web_contents)); 32 tab_.reset(new TabContentsWrapper(web_contents));
33 if (tab_delegate) { 33 if (tab_delegate) {
34 override_tab_delegate_.reset(tab_delegate); 34 override_tab_delegate_.reset(tab_delegate);
35 web_contents->SetDelegate(tab_delegate); 35 web_contents->SetDelegate(tab_delegate);
36 } else { 36 } else {
37 web_contents->SetDelegate(this); 37 web_contents->SetDelegate(this);
38 } 38 }
39 // Set |this| as a property so the ConstrainedWebDialogUI can retrieve it. 39 // Set |this| as a property so the ConstrainedWebDialogUI can retrieve it.
40 ConstrainedWebDialogUI::GetPropertyAccessor().SetProperty( 40 ConstrainedWebDialogUI::GetPropertyAccessor().SetProperty(
41 web_contents->GetPropertyBag(), this); 41 web_contents->GetPropertyBag(), this);
42 42
43 web_contents->GetController().LoadURL(delegate->GetDialogContentURL(), 43 web_contents->GetController().LoadURL(delegate->GetDialogContentURL(),
44 content::Referrer(), 44 content::Referrer(),
45 content::PAGE_TRANSITION_START_PAGE, 45 content::PAGE_TRANSITION_START_PAGE,
46 std::string()); 46 std::string());
47 } 47 }
48 48
49 ConstrainedWebDialogDelegateBase::~ConstrainedWebDialogDelegateBase() { 49 ConstrainedWebDialogDelegateBase::~ConstrainedWebDialogDelegateBase() {
50 if (release_tab_on_close_) 50 if (release_tab_on_close_)
51 ignore_result(tab_.release()); 51 ignore_result(tab_.release());
52 } 52 }
53 53
54 const WebDialogDelegate* 54 const web_dialogs::WebDialogDelegate*
55 ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() const { 55 ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() const {
56 return web_dialog_delegate_; 56 return web_dialog_delegate_;
57 } 57 }
58 58
59 WebDialogDelegate* 59 web_dialogs::WebDialogDelegate*
60 ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() { 60 ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() {
61 return web_dialog_delegate_; 61 return web_dialog_delegate_;
62 } 62 }
63 63
64 void ConstrainedWebDialogDelegateBase::OnDialogCloseFromWebUI() { 64 void ConstrainedWebDialogDelegateBase::OnDialogCloseFromWebUI() {
65 closed_via_webui_ = true; 65 closed_via_webui_ = true;
66 window_->CloseConstrainedWindow(); 66 window_->CloseConstrainedWindow();
67 } 67 }
68 68
69 void ConstrainedWebDialogDelegateBase::set_window(ConstrainedWindow* window) { 69 void ConstrainedWebDialogDelegateBase::set_window(ConstrainedWindow* window) {
70 window_ = window; 70 window_ = window;
71 } 71 }
72 72
73 void ConstrainedWebDialogDelegateBase::set_override_tab_delegate( 73 void ConstrainedWebDialogDelegateBase::set_override_tab_delegate(
74 WebDialogWebContentsDelegate* override_tab_delegate) { 74 web_dialogs::WebDialogWebContentsDelegate* override_tab_delegate) {
75 override_tab_delegate_.reset(override_tab_delegate); 75 override_tab_delegate_.reset(override_tab_delegate);
76 } 76 }
77 77
78 bool ConstrainedWebDialogDelegateBase::closed_via_webui() const { 78 bool ConstrainedWebDialogDelegateBase::closed_via_webui() const {
79 return closed_via_webui_; 79 return closed_via_webui_;
80 } 80 }
81 81
82 void ConstrainedWebDialogDelegateBase::ReleaseTabContentsOnDialogClose() { 82 void ConstrainedWebDialogDelegateBase::ReleaseTabContentsOnDialogClose() {
83 release_tab_on_close_ = true; 83 release_tab_on_close_ = true;
84 } 84 }
85 85
86 ConstrainedWindow* ConstrainedWebDialogDelegateBase::window() { 86 ConstrainedWindow* ConstrainedWebDialogDelegateBase::window() {
87 return window_; 87 return window_;
88 } 88 }
89 89
90 TabContentsWrapper* ConstrainedWebDialogDelegateBase::tab() { 90 TabContentsWrapper* ConstrainedWebDialogDelegateBase::tab() {
91 return tab_.get(); 91 return tab_.get();
92 } 92 }
93 93
94 void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent( 94 void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent(
95 const NativeWebKeyboardEvent& event) { 95 const NativeWebKeyboardEvent& event) {
96 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698