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: content/browser/tab_contents/tab_contents.cc

Issue 9203001: Implement input type=color UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 8 years, 9 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
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/common/view_messages.h » ('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 "content/browser/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
31 #include "content/public/browser/resource_request_details.h" 31 #include "content/public/browser/resource_request_details.h"
32 #include "content/browser/site_instance_impl.h" 32 #include "content/browser/site_instance_impl.h"
33 #include "content/browser/tab_contents/interstitial_page_impl.h" 33 #include "content/browser/tab_contents/interstitial_page_impl.h"
34 #include "content/browser/tab_contents/navigation_entry_impl.h" 34 #include "content/browser/tab_contents/navigation_entry_impl.h"
35 #include "content/browser/webui/web_ui_impl.h" 35 #include "content/browser/webui/web_ui_impl.h"
36 #include "content/common/intents_messages.h" 36 #include "content/common/intents_messages.h"
37 #include "content/common/ssl_status_serialization.h" 37 #include "content/common/ssl_status_serialization.h"
38 #include "content/common/view_messages.h" 38 #include "content/common/view_messages.h"
39 #include "content/port/browser/render_widget_host_view_port.h" 39 #include "content/port/browser/render_widget_host_view_port.h"
40 #include "content/public/browser/browser_context.h" 40 #include "content/public/browser/browser_context.h"
41 #include "content/public/browser/color_chooser.h"
41 #include "content/public/browser/content_browser_client.h" 42 #include "content/public/browser/content_browser_client.h"
42 #include "content/public/browser/devtools_agent_host_registry.h" 43 #include "content/public/browser/devtools_agent_host_registry.h"
43 #include "content/public/browser/download_manager.h" 44 #include "content/public/browser/download_manager.h"
44 #include "content/public/browser/invalidate_type.h" 45 #include "content/public/browser/invalidate_type.h"
45 #include "content/public/browser/javascript_dialogs.h" 46 #include "content/public/browser/javascript_dialogs.h"
46 #include "content/public/browser/load_notification_details.h" 47 #include "content/public/browser/load_notification_details.h"
47 #include "content/public/browser/navigation_details.h" 48 #include "content/public/browser/navigation_details.h"
48 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/user_metrics.h" 50 #include "content/public/browser/user_metrics.h"
50 #include "content/public/browser/web_contents_delegate.h" 51 #include "content/public/browser/web_contents_delegate.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 is_showing_before_unload_dialog_(false), 266 is_showing_before_unload_dialog_(false),
266 opener_web_ui_type_(WebUI::kNoWebUI), 267 opener_web_ui_type_(WebUI::kNoWebUI),
267 closed_by_user_gesture_(false), 268 closed_by_user_gesture_(false),
268 minimum_zoom_percent_( 269 minimum_zoom_percent_(
269 static_cast<int>(content::kMinimumZoomFactor * 100)), 270 static_cast<int>(content::kMinimumZoomFactor * 100)),
270 maximum_zoom_percent_( 271 maximum_zoom_percent_(
271 static_cast<int>(content::kMaximumZoomFactor * 100)), 272 static_cast<int>(content::kMaximumZoomFactor * 100)),
272 temporary_zoom_settings_(false), 273 temporary_zoom_settings_(false),
273 content_restrictions_(0), 274 content_restrictions_(0),
274 view_type_(content::VIEW_TYPE_TAB_CONTENTS), 275 view_type_(content::VIEW_TYPE_TAB_CONTENTS),
275 has_opener_(false) { 276 has_opener_(false),
277 color_chooser_(NULL) {
276 render_manager_.Init(browser_context, site_instance, routing_id); 278 render_manager_.Init(browser_context, site_instance, routing_id);
277 279
278 view_.reset(content::GetContentClient()->browser()-> 280 view_.reset(content::GetContentClient()->browser()->
279 OverrideCreateWebContentsView(this)); 281 OverrideCreateWebContentsView(this));
280 if (!view_.get()) { 282 if (!view_.get()) {
281 content::WebContentsViewDelegate* delegate = 283 content::WebContentsViewDelegate* delegate =
282 content::GetContentClient()->browser()->GetWebContentsViewDelegate( 284 content::GetContentClient()->browser()->GetWebContentsViewDelegate(
283 this); 285 this);
284 #if defined(OS_WIN) && !defined(USE_AURA) 286 #if defined(OS_WIN) && !defined(USE_AURA)
285 view_.reset(new TabContentsViewWin(this, delegate)); 287 view_.reset(new TabContentsViewWin(this, delegate));
(...skipping 19 matching lines...) Expand all
305 #endif 307 #endif
306 } 308 }
307 309
308 TabContents::~TabContents() { 310 TabContents::~TabContents() {
309 is_being_destroyed_ = true; 311 is_being_destroyed_ = true;
310 312
311 // Clear out any JavaScript state. 313 // Clear out any JavaScript state.
312 if (dialog_creator_) 314 if (dialog_creator_)
313 dialog_creator_->ResetJavaScriptState(this); 315 dialog_creator_->ResetJavaScriptState(this);
314 316
317 if (color_chooser_)
318 color_chooser_->End();
319
315 NotifyDisconnected(); 320 NotifyDisconnected();
316 321
317 // Notify any observer that have a reference on this tab contents. 322 // Notify any observer that have a reference on this tab contents.
318 content::NotificationService::current()->Notify( 323 content::NotificationService::current()->Notify(
319 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 324 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
320 content::Source<WebContents>(this), 325 content::Source<WebContents>(this),
321 content::NotificationService::NoDetails()); 326 content::NotificationService::NoDetails());
322 327
323 // TODO(brettw) this should be moved to the view. 328 // TODO(brettw) this should be moved to the view.
324 #if defined(OS_WIN) && !defined(USE_AURA) 329 #if defined(OS_WIN) && !defined(USE_AURA)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) 556 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset)
552 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) 557 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
553 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) 558 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL)
554 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) 559 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory)
555 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) 560 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory)
556 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, 561 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler,
557 OnRegisterProtocolHandler) 562 OnRegisterProtocolHandler)
558 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) 563 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply)
559 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) 564 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin)
560 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) 565 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
566 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser)
567 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser)
568 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser,
569 OnSetSelectedColorInColorChooser)
561 IPC_MESSAGE_UNHANDLED(handled = false) 570 IPC_MESSAGE_UNHANDLED(handled = false)
562 IPC_END_MESSAGE_MAP_EX() 571 IPC_END_MESSAGE_MAP_EX()
563 572
564 if (!message_is_ok) { 573 if (!message_is_ok) {
565 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); 574 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD"));
566 GetRenderProcessHost()->ReceivedBadMessage(); 575 GetRenderProcessHost()->ReceivedBadMessage();
567 } 576 }
568 577
569 return handled; 578 return handled;
570 } 579 }
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 1383
1375 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { 1384 bool TabContents::GotResponseToLockMouseRequest(bool allowed) {
1376 return GetRenderViewHost() ? 1385 return GetRenderViewHost() ?
1377 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false; 1386 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false;
1378 } 1387 }
1379 1388
1380 bool TabContents::HasOpener() const { 1389 bool TabContents::HasOpener() const {
1381 return has_opener_; 1390 return has_opener_;
1382 } 1391 }
1383 1392
1393 void TabContents::DidChooseColorInColorChooser(int color_chooser_id,
1394 const SkColor& color) {
1395 GetRenderViewHost()->Send(new ViewMsg_DidChooseColorResponse(
1396 GetRenderViewHost()->GetRoutingID(), color_chooser_id, color));
1397 }
1398
1399 void TabContents::DidEndColorChooser(int color_chooser_id) {
1400 GetRenderViewHost()->Send(new ViewMsg_DidEndColorChooser(
1401 GetRenderViewHost()->GetRoutingID(), color_chooser_id));
1402 if (delegate_)
1403 delegate_->DidEndColorChooser();
1404 color_chooser_ = NULL;
1405 }
1406
1384 bool TabContents::FocusLocationBarByDefault() { 1407 bool TabContents::FocusLocationBarByDefault() {
1385 content::WebUI* web_ui = GetWebUIForCurrentState(); 1408 content::WebUI* web_ui = GetWebUIForCurrentState();
1386 if (web_ui) 1409 if (web_ui)
1387 return web_ui->ShouldFocusLocationBarByDefault(); 1410 return web_ui->ShouldFocusLocationBarByDefault();
1388 NavigationEntry* entry = controller_.GetActiveEntry(); 1411 NavigationEntry* entry = controller_.GetActiveEntry();
1389 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) 1412 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL))
1390 return true; 1413 return true;
1391 return false; 1414 return false;
1392 } 1415 }
1393 1416
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 delegate_->CrashedPlugin(this, plugin_path); 1706 delegate_->CrashedPlugin(this, plugin_path);
1684 } 1707 }
1685 1708
1686 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, 1709 void TabContents::OnAppCacheAccessed(const GURL& manifest_url,
1687 bool blocked_by_policy) { 1710 bool blocked_by_policy) {
1688 // Notify observers about navigation. 1711 // Notify observers about navigation.
1689 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1712 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1690 AppCacheAccessed(manifest_url, blocked_by_policy)); 1713 AppCacheAccessed(manifest_url, blocked_by_policy));
1691 } 1714 }
1692 1715
1716 void TabContents::OnOpenColorChooser(int color_chooser_id,
1717 const SkColor& color) {
1718 color_chooser_ = delegate_->OpenColorChooser(this, color_chooser_id, color);
1719 }
1720
1721 void TabContents::OnEndColorChooser(int color_chooser_id) {
1722 if (color_chooser_ &&
1723 color_chooser_id == color_chooser_->identifier())
1724 color_chooser_->End();
1725 }
1726
1727 void TabContents::OnSetSelectedColorInColorChooser(int color_chooser_id,
1728 const SkColor& color) {
1729 if (color_chooser_ &&
1730 color_chooser_id == color_chooser_->identifier())
1731 color_chooser_->SetSelectedColor(color);
1732 }
1733
1693 // Notifies the RenderWidgetHost instance about the fact that the page is 1734 // Notifies the RenderWidgetHost instance about the fact that the page is
1694 // loading, or done loading and calls the base implementation. 1735 // loading, or done loading and calls the base implementation.
1695 void TabContents::SetIsLoading(bool is_loading, 1736 void TabContents::SetIsLoading(bool is_loading,
1696 LoadNotificationDetails* details) { 1737 LoadNotificationDetails* details) {
1697 if (is_loading == is_loading_) 1738 if (is_loading == is_loading_)
1698 return; 1739 return;
1699 1740
1700 if (!is_loading) { 1741 if (!is_loading) {
1701 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); 1742 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16());
1702 load_state_host_.clear(); 1743 load_state_host_.clear();
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2572 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2532 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2573 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2533 // Can be NULL during tests. 2574 // Can be NULL during tests.
2534 if (rwh_view) 2575 if (rwh_view)
2535 rwh_view->SetSize(GetView()->GetContainerSize()); 2576 rwh_view->SetSize(GetView()->GetContainerSize());
2536 } 2577 }
2537 2578
2538 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() { 2579 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() {
2539 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 2580 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
2540 } 2581 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698