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

Side by Side Diff: chrome/browser/extensions/api/app_window/app_window_api.cc

Issue 10917274: Re-enable native UI for {frame:'chrome'} in app windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/app_window/app_window_api.h" 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h"
6 6
7 #include "base/command_line.h"
7 #include "base/time.h" 8 #include "base/time.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/extensions/window_controller.h" 10 #include "chrome/browser/extensions/window_controller.h"
10 #include "chrome/browser/ui/extensions/shell_window.h" 11 #include "chrome/browser/ui/extensions/shell_window.h"
12 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/api/app_window.h" 13 #include "chrome/common/extensions/api/app_window.h"
12 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
15 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
16 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
17 19
18 namespace app_window = extensions::api::app_window; 20 namespace app_window = extensions::api::app_window;
19 namespace Create = app_window::Create; 21 namespace Create = app_window::Create;
20 22
21 namespace extensions { 23 namespace extensions {
22 24
23 namespace app_window_constants { 25 namespace app_window_constants {
24 const char kInvalidWindowId[] = 26 const char kInvalidWindowId[] =
25 "The window id can not be more than 256 characters long."; 27 "The window id can not be more than 256 characters long.";
26 }; 28 };
27 29
28 const char kNoneFrameOption[] = "none"; 30 const char kNoneFrameOption[] = "none";
31 const char kHtmlFrameOption[] = "experimental-html";
29 32
30 bool AppWindowCreateFunction::RunImpl() { 33 bool AppWindowCreateFunction::RunImpl() {
31 scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); 34 scoped_ptr<Create::Params> params(Create::Params::Create(*args_));
32 EXTENSION_FUNCTION_VALIDATE(params.get()); 35 EXTENSION_FUNCTION_VALIDATE(params.get());
33 36
34 GURL url = GetExtension()->GetResourceURL(params->url); 37 GURL url = GetExtension()->GetResourceURL(params->url);
35 38
39 bool inject_html_titlebar = false;
40
36 // TODO(jeremya): figure out a way to pass the opening WebContents through to 41 // TODO(jeremya): figure out a way to pass the opening WebContents through to
37 // ShellWindow::Create so we can set the opener at create time rather than 42 // ShellWindow::Create so we can set the opener at create time rather than
38 // with a hack in AppWindowCustomBindings::GetView(). 43 // with a hack in AppWindowCustomBindings::GetView().
39 ShellWindow::CreateParams create_params; 44 ShellWindow::CreateParams create_params;
40 app_window::CreateWindowOptions* options = params->options.get(); 45 app_window::CreateWindowOptions* options = params->options.get();
41 if (options) { 46 if (options) {
42 if (options->id.get()) { 47 if (options->id.get()) {
43 // TODO(mek): use URL if no id specified? 48 // TODO(mek): use URL if no id specified?
44 // Limit length of id to 256 characters. 49 // Limit length of id to 256 characters.
45 if (options->id->length() > 256) { 50 if (options->id->length() > 256) {
(...skipping 23 matching lines...) Expand all
69 } 74 }
70 75
71 if (options->left.get() || options->top.get()) { 76 if (options->left.get() || options->top.get()) {
72 if (options->left.get()) 77 if (options->left.get())
73 create_params.bounds.set_x(*options->left.get()); 78 create_params.bounds.set_x(*options->left.get());
74 if (options->top.get()) 79 if (options->top.get())
75 create_params.bounds.set_y(*options->top.get()); 80 create_params.bounds.set_y(*options->top.get());
76 create_params.restore_position = false; 81 create_params.restore_position = false;
77 } 82 }
78 83
84 if (options->frame.get()) {
85 if (*options->frame == kHtmlFrameOption &&
86 CommandLine::ForCurrentProcess()->HasSwitch(
87 switches::kEnableExperimentalExtensionApis)) {
88 create_params.frame = ShellWindow::CreateParams::FRAME_NONE;
89 inject_html_titlebar = true;
90 } else if (*options->frame == kNoneFrameOption) {
91 create_params.frame = ShellWindow::CreateParams::FRAME_NONE;
92 } else {
93 create_params.frame = ShellWindow::CreateParams::FRAME_CHROME;
94 }
95 }
96
79 gfx::Size& minimum_size = create_params.minimum_size; 97 gfx::Size& minimum_size = create_params.minimum_size;
80 if (options->min_width.get()) 98 if (options->min_width.get())
81 minimum_size.set_width(*options->min_width); 99 minimum_size.set_width(*options->min_width);
82 if (options->min_height.get()) 100 if (options->min_height.get())
83 minimum_size.set_height(*options->min_height); 101 minimum_size.set_height(*options->min_height);
84 gfx::Size& maximum_size = create_params.maximum_size; 102 gfx::Size& maximum_size = create_params.maximum_size;
85 if (options->max_width.get()) 103 if (options->max_width.get())
86 maximum_size.set_width(*options->max_width); 104 maximum_size.set_width(*options->max_width);
87 if (options->max_height.get()) 105 if (options->max_height.get())
88 maximum_size.set_height(*options->max_height); 106 maximum_size.set_height(*options->max_height);
(...skipping 16 matching lines...) Expand all
105 if (create_params.bounds.height() < minimum_size.height()) 123 if (create_params.bounds.height() < minimum_size.height())
106 create_params.bounds.set_height(minimum_size.height()); 124 create_params.bounds.set_height(minimum_size.height());
107 } 125 }
108 ShellWindow* shell_window = 126 ShellWindow* shell_window =
109 ShellWindow::Create(profile(), GetExtension(), url, create_params); 127 ShellWindow::Create(profile(), GetExtension(), url, create_params);
110 shell_window->GetBaseWindow()->Show(); 128 shell_window->GetBaseWindow()->Show();
111 129
112 content::WebContents* created_contents = shell_window->web_contents(); 130 content::WebContents* created_contents = shell_window->web_contents();
113 int view_id = created_contents->GetRenderViewHost()->GetRoutingID(); 131 int view_id = created_contents->GetRenderViewHost()->GetRoutingID();
114 132
115 SetResult(base::Value::CreateIntegerValue(view_id)); 133 base::DictionaryValue* result = new base::DictionaryValue;
134 result->Set("viewId", base::Value::CreateIntegerValue(view_id));
135 result->Set("injectTitlebar",
136 base::Value::CreateBooleanValue(inject_html_titlebar));
137 SetResult(result);
116 return true; 138 return true;
117 } 139 }
118 140
119 } // namespace extensions 141 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698