OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/ui/login_web_dialog.h" | 5 #include "chrome/browser/chromeos/login/ui/login_web_dialog.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/login/helper.h" | 11 #include "chrome/browser/chromeos/login/helper.h" |
12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/ui/browser_dialogs.h" | 12 #include "chrome/browser/ui/browser_dialogs.h" |
| 13 #include "content/public/browser/browser_context.h" |
15 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
18 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
20 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
21 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
22 | 21 |
23 using content::WebContents; | 22 using content::WebContents; |
24 using content::WebUIMessageHandler; | 23 using content::WebUIMessageHandler; |
(...skipping 14 matching lines...) Expand all Loading... |
39 g_web_contents_stack = LAZY_INSTANCE_INITIALIZER; | 38 g_web_contents_stack = LAZY_INSTANCE_INITIALIZER; |
40 | 39 |
41 } // namespace | 40 } // namespace |
42 | 41 |
43 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
44 // LoginWebDialog, public: | 43 // LoginWebDialog, public: |
45 | 44 |
46 void LoginWebDialog::Delegate::OnDialogClosed() { | 45 void LoginWebDialog::Delegate::OnDialogClosed() { |
47 } | 46 } |
48 | 47 |
49 LoginWebDialog::LoginWebDialog(Profile* profile, | 48 LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context, |
50 Delegate* delegate, | 49 Delegate* delegate, |
51 gfx::NativeWindow parent_window, | 50 gfx::NativeWindow parent_window, |
52 const base::string16& title, | 51 const base::string16& title, |
53 const GURL& url, | 52 const GURL& url, |
54 Style style) | 53 Style style) |
55 : profile_(profile), | 54 : browser_context_(browser_context), |
56 parent_window_(parent_window), | 55 parent_window_(parent_window), |
57 delegate_(delegate), | 56 delegate_(delegate), |
58 title_(title), | 57 title_(title), |
59 url_(url), | 58 url_(url), |
60 style_(style), | 59 style_(style), |
61 is_open_(false) { | 60 is_open_(false) { |
62 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 61 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
63 width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width()); | 62 width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width()); |
64 height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height()); | 63 height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height()); |
65 } | 64 } |
66 | 65 |
67 LoginWebDialog::~LoginWebDialog() { | 66 LoginWebDialog::~LoginWebDialog() { |
68 delegate_ = NULL; | 67 delegate_ = NULL; |
69 } | 68 } |
70 | 69 |
71 void LoginWebDialog::Show() { | 70 void LoginWebDialog::Show() { |
72 chrome::ShowWebDialog(parent_window_, | 71 chrome::ShowWebDialog(parent_window_, browser_context_, this); |
73 profile_, | |
74 this); | |
75 is_open_ = true; | 72 is_open_ = true; |
76 } | 73 } |
77 | 74 |
78 void LoginWebDialog::SetDialogSize(int width, int height) { | 75 void LoginWebDialog::SetDialogSize(int width, int height) { |
79 DCHECK(width >= 0 && height >= 0); | 76 DCHECK(width >= 0 && height >= 0); |
80 width_ = width; | 77 width_ = width; |
81 height_ = height; | 78 height_ = height; |
82 } | 79 } |
83 | 80 |
84 void LoginWebDialog::SetDialogTitle(const base::string16& title) { | 81 void LoginWebDialog::SetDialogTitle(const base::string16& title) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 161 |
165 void LoginWebDialog::Observe(int type, | 162 void LoginWebDialog::Observe(int type, |
166 const content::NotificationSource& source, | 163 const content::NotificationSource& source, |
167 const content::NotificationDetails& details) { | 164 const content::NotificationDetails& details) { |
168 DCHECK(type == content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME); | 165 DCHECK(type == content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME); |
169 // TODO(saintlou): Do we need a throbber for Aura? | 166 // TODO(saintlou): Do we need a throbber for Aura? |
170 NOTIMPLEMENTED(); | 167 NOTIMPLEMENTED(); |
171 } | 168 } |
172 | 169 |
173 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |